Compare commits
2 Commits
fe5f08f62f
...
655ac6f4b2
Author | SHA1 | Date | |
---|---|---|---|
![]() |
655ac6f4b2 | ||
![]() |
3960eb0cd2 |
@ -1,7 +1,7 @@
|
|||||||
local Prop = require("gfx.prop")
|
local Prop = require("gfx.prop")
|
||||||
local Element = require("gfx.element")
|
local Element = require("gfx.element")
|
||||||
local Event = require("gfx.event")
|
local Event = require("gfx.event")
|
||||||
local Children = Prop:new{ defaultState = {} }
|
local Children = Prop:new{ defaultState = {}, uid = "CHILDREN" }
|
||||||
|
|
||||||
function Children:with(elementType)
|
function Children:with(elementType)
|
||||||
local propSelf = self
|
local propSelf = self
|
||||||
|
@ -2,11 +2,15 @@ local Prop = {}
|
|||||||
Prop.__index = Prop
|
Prop.__index = Prop
|
||||||
|
|
||||||
function Prop:getState(element)
|
function Prop:getState(element)
|
||||||
return element[self]
|
return element[self:getId()]
|
||||||
end
|
end
|
||||||
|
|
||||||
function Prop:setState(element, state)
|
function Prop:setState(element, state)
|
||||||
element[self] = state
|
element[self:getId()] = state
|
||||||
|
end
|
||||||
|
|
||||||
|
function Prop:getId()
|
||||||
|
return self.uid
|
||||||
end
|
end
|
||||||
|
|
||||||
function Prop.attach(elementType, prop, defaultState)
|
function Prop.attach(elementType, prop, defaultState)
|
||||||
@ -15,10 +19,12 @@ function Prop.attach(elementType, prop, defaultState)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Prop:new(o)
|
function Prop:new(o)
|
||||||
local obj = o or {}
|
if o.uid == nil then
|
||||||
setmetatable(obj, Prop)
|
error("Property must carry a unique identifier")
|
||||||
obj.__index = obj
|
end
|
||||||
return obj
|
setmetatable(o, Prop)
|
||||||
|
o.__index = o
|
||||||
|
return o
|
||||||
end
|
end
|
||||||
|
|
||||||
return Prop
|
return Prop
|
@ -1,5 +1,5 @@
|
|||||||
local Prop = require("gfx.prop")
|
local Prop = require("gfx.prop")
|
||||||
local Orientation = Prop:new{ defaultState = false }
|
local Orientation = Prop:new{ defaultState = false, uid = "ORIENTATION" }
|
||||||
|
|
||||||
function Orientation:with(elementType)
|
function Orientation:with(elementType)
|
||||||
local propSelf = self
|
local propSelf = self
|
||||||
|
@ -6,6 +6,7 @@ local List = require("gfx.list")
|
|||||||
local Event = require("gfx.event")
|
local Event = require("gfx.event")
|
||||||
local Padding = require("gfx.padding")
|
local Padding = require("gfx.padding")
|
||||||
local Container = require("gfx.container")
|
local Container = require("gfx.container")
|
||||||
|
local Children = require("gfx.prop.children")
|
||||||
|
|
||||||
|
|
||||||
local CACHE_FILE = "/.storage.cache"
|
local CACHE_FILE = "/.storage.cache"
|
||||||
@ -125,7 +126,7 @@ local function itemList(groups, wBudget, hBudget, savedState, onClick, setPage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
local tabLine = List:new{
|
local tabLine = List:new{
|
||||||
children = {
|
[Children:getId()] = {
|
||||||
btnPrev,
|
btnPrev,
|
||||||
padImport,
|
padImport,
|
||||||
padNext
|
padNext
|
||||||
@ -173,7 +174,7 @@ local function itemList(groups, wBudget, hBudget, savedState, onClick, setPage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
local list = List:new{
|
local list = List:new{
|
||||||
children = {
|
[Children:getId()] = {
|
||||||
paddedText,
|
paddedText,
|
||||||
countLabel
|
countLabel
|
||||||
},
|
},
|
||||||
@ -193,7 +194,7 @@ local function itemList(groups, wBudget, hBudget, savedState, onClick, setPage,
|
|||||||
table.insert(entries, tabLinePad)
|
table.insert(entries, tabLinePad)
|
||||||
|
|
||||||
return List:new{
|
return List:new{
|
||||||
children = entries,
|
[Children:getId()] = entries,
|
||||||
vertical = true
|
vertical = true
|
||||||
}, state
|
}, state
|
||||||
end
|
end
|
||||||
@ -310,7 +311,7 @@ local PAGES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local stuffContainer = Container:new{
|
local stuffContainer = Container:new{
|
||||||
children = {
|
[Children:getId()] = {
|
||||||
paddedTitle
|
paddedTitle
|
||||||
},
|
},
|
||||||
width = state.width,
|
width = state.width,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user