style system overhaul

This commit is contained in:
airstruck
2015-11-09 17:14:40 -05:00
parent f866442cf1
commit 058d9351e5
9 changed files with 86 additions and 83 deletions

View File

@@ -13,10 +13,11 @@ local function deactivateSiblings (target)
end
while sibling do
local layout = sibling.menuLayout
sibling.active = nil
local layout = sibling.menuLayout
if layout and layout.isShown then
wasSiblingOpen = true
layout:hide()
@@ -109,9 +110,12 @@ show = function (self)
menuLayout:onPressStart(function (event)
if not event.hit then
menuLayout:hide()
deactivateSiblings(self.rootMenu[1])
if self.parentMenu == self.rootMenu then
deactivateSiblings(self.rootMenu[1])
end
else
activate(event)
end
activate(event)
end)
menuLayout:onEnter(activate)
@@ -144,12 +148,22 @@ return function (self)
end
if isSubmenu then
key = #self.items > 0 and '>' or key
local tc = self.textColor or { 0, 0, 0 }
local keyColor = { tc[1], tc[2], tc[3], 0x90 }
local edgeType
if #self.items > 0 then
key = ' '
edgeType = 'menu.expander'
else
key = key:gsub('%f[%w].', string.upper)
end
self.height = self.fontData:getLineHeight() + pad * 2
self.flow = 'x'
self:addChild({ icon = icon, width = self.height })
self:addChild({ text = text, width = textWidth })
self:addChild({ text = key, align = 'right', minwidth = self.height })
self:addChild({ text = key, align = 'middle right',
minwidth = self.height,
textColor = keyColor, type = edgeType })
self.icon = nil
self.text = nil

View File

@@ -4,10 +4,7 @@ return function (self)
self.flow = 'x' -- TODO: support vertical stepper
local decrement = self:addChild {
type = 'button',
text = '<',
align = 'middle center',
margin = 0,
type = 'stepper.left',
}
local view = self:addChild {
@@ -18,10 +15,7 @@ return function (self)
}
local increment = self:addChild {
type = 'button',
text = '>',
align = 'middle center',
margin = 0,
type = 'stepper.right',
}
self:onReshape(function (event)