|
|
@ -14,7 +14,6 @@
|
|
|
|
local BASE = (...):gsub('layout$', '')
|
|
|
|
local BASE = (...):gsub('layout$', '')
|
|
|
|
|
|
|
|
|
|
|
|
local Widget = require(BASE..'widget')
|
|
|
|
local Widget = require(BASE..'widget')
|
|
|
|
local core = require(BASE..'core')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local gear = require 'lib.gear'
|
|
|
|
local gear = require 'lib.gear'
|
|
|
|
|
|
|
|
|
|
|
@ -126,12 +125,21 @@ function Layout:layoutWidgets()
|
|
|
|
self.y = ry
|
|
|
|
self.y = ry
|
|
|
|
self.w = math.max(rw, 0)
|
|
|
|
self.w = math.max(rw, 0)
|
|
|
|
self.h = math.max(rh, 0)
|
|
|
|
self.h = math.max(rh, 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- A Layout ignores focus if empty or containing only nofocus widgets
|
|
|
|
|
|
|
|
self.nofocus = true
|
|
|
|
|
|
|
|
for _,w in ipairs(self) do
|
|
|
|
|
|
|
|
if not w.nofocus then
|
|
|
|
|
|
|
|
self.nofocus = false
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- Find layout's child containing the provided widget.
|
|
|
|
-- Find layout's child containing the provided widget.
|
|
|
|
local function childof(layout, widget)
|
|
|
|
local function childof(layout, widget)
|
|
|
|
local parent = widget.parent
|
|
|
|
local parent = widget.parent
|
|
|
|
while parent ~= layout do
|
|
|
|
while not rawequal(parent, layout) do
|
|
|
|
widget = parent
|
|
|
|
widget = parent
|
|
|
|
parent = widget.parent
|
|
|
|
parent = widget.parent
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -173,16 +181,6 @@ function Layout:new(args)
|
|
|
|
|
|
|
|
|
|
|
|
self.padding = self.padding or 0
|
|
|
|
self.padding = self.padding or 0
|
|
|
|
self.stack = {}
|
|
|
|
self.stack = {}
|
|
|
|
|
|
|
|
|
|
|
|
-- A Layout ignores focus if empty or containing only nofocus widgets
|
|
|
|
|
|
|
|
self.nofocus = true
|
|
|
|
|
|
|
|
for _,w in ipairs(self) do
|
|
|
|
|
|
|
|
if not w.nofocus then
|
|
|
|
|
|
|
|
self.nofocus = false
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return self
|
|
|
|
return self
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -201,7 +199,7 @@ function Layout:after(widget)
|
|
|
|
widget = childof(self, widget)
|
|
|
|
widget = childof(self, widget)
|
|
|
|
|
|
|
|
|
|
|
|
for i = 1,#self do
|
|
|
|
for i = 1,#self do
|
|
|
|
if self[i] == widget then
|
|
|
|
if rawequal(self[i], widget) then
|
|
|
|
-- Search to the right/down
|
|
|
|
-- Search to the right/down
|
|
|
|
return scanforward(self, i+1)
|
|
|
|
return scanforward(self, i+1)
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -213,7 +211,7 @@ function Layout:before(widget)
|
|
|
|
widget = childof(self, widget)
|
|
|
|
widget = childof(self, widget)
|
|
|
|
|
|
|
|
|
|
|
|
for i = 1,#self do
|
|
|
|
for i = 1,#self do
|
|
|
|
if self[i] == widget then
|
|
|
|
if rawequal(self[i], widget) then
|
|
|
|
-- Search to the left/up
|
|
|
|
-- Search to the left/up
|
|
|
|
return scanbackwards(self, i-1)
|
|
|
|
return scanbackwards(self, i-1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|