mirror of https://gitea.it/1414codeforge/yui
[*] General code improvement.
* Rework navigation allowing direct management and triggering for grabkeyboard widgets. * Navigation code now behaves better with deeply nested layouts. * Allow widget hierarchies deeper than 2 (__call() is implemented for every Widget metatable). * Make BASE locals more secure (match '<filename>$' in regexp)master
parent
3b2b460012
commit
1d42498ee7
@ -1,21 +1,20 @@
|
|||||||
local BASE = (...):gsub('columns', '')
|
local BASE = (...):gsub('columns$', '')
|
||||||
|
|
||||||
local Layout = require(BASE..'layout')
|
local Layout = require(BASE..'layout')
|
||||||
|
|
||||||
|
|
||||||
-- Advance position to next column,
|
-- Advance position to next column,
|
||||||
-- given current position, widget dimensions and padding.
|
-- given current position, widget dimensions and padding.
|
||||||
local function columnadvance(x,y, ww,wh, padding)
|
local function columnadvance(x,y, ww,wh, padding)
|
||||||
return x + ww + padding, y
|
return x + ww + padding, y
|
||||||
end
|
end
|
||||||
|
|
||||||
function Columns(args)
|
local Columns = setmetatable({
|
||||||
local self = Layout.new(args)
|
advance = columnadvance,
|
||||||
|
__call = function(cls, args) return cls.new(args) end
|
||||||
|
}, Layout)
|
||||||
|
Columns.__index = Columns
|
||||||
|
|
||||||
self.advance = columnadvance
|
|
||||||
self.prev = 'left'
|
function Columns.new(args) return setmetatable(Layout.new(args), Columns) end
|
||||||
self.next = 'right'
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
return Columns
|
return Columns
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
local BASE = (...):gsub('rows', '')
|
local BASE = (...):gsub('rows$', '')
|
||||||
|
|
||||||
local Layout = require(BASE..'layout')
|
local Layout = require(BASE..'layout')
|
||||||
|
|
||||||
|
|
||||||
-- Advance position to next row,
|
-- Advance position to next row,
|
||||||
-- given current position, widget dimensions and padding.
|
-- given current position, widget dimensions and padding.
|
||||||
local function rowadvance(x,y, ww,wh, padding)
|
local function rowadvance(x,y, ww,wh, padding)
|
||||||
return x, y + wh + padding
|
return x, y + wh + padding
|
||||||
end
|
end
|
||||||
|
|
||||||
function Rows(args)
|
local Rows = setmetatable({
|
||||||
local self = Layout.new(args)
|
advance = rowadvance,
|
||||||
|
__call = function(cls, args) return cls.new(args) end
|
||||||
|
}, Layout)
|
||||||
|
Rows.__index = Rows
|
||||||
|
|
||||||
self.advance = rowadvance
|
|
||||||
self.prev = 'up'
|
function Rows.new(args) return setmetatable(Layout.new(args), Rows) end
|
||||||
self.next = 'down'
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
return Rows
|
return Rows
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
local BASE = (...):gsub('spacer', '')
|
local BASE = (...):gsub('spacer$', '')
|
||||||
|
|
||||||
local Widget = require(BASE..'widget')
|
local Widget = require(BASE..'widget')
|
||||||
|
|
||||||
-- Spacers don't accept focus
|
-- Spacers don't accept focus
|
||||||
local Spacer = setmetatable({ nofocus = true }, Widget)
|
local Spacer = setmetatable({
|
||||||
|
nofocus = true,
|
||||||
|
__call = function(cls, args) return cls.new(args) end
|
||||||
|
}, Widget)
|
||||||
Spacer.__index = Spacer
|
Spacer.__index = Spacer
|
||||||
|
|
||||||
|
|
||||||
function Spacer.new(args)
|
function Spacer.new(args) return setmetatable(args, Spacer) end
|
||||||
return setmetatable(args, Spacer)
|
|
||||||
end
|
|
||||||
|
|
||||||
return Spacer
|
return Spacer
|
||||||
|
Loading…
Reference in New Issue