new layout system, new UI state/styles system

This commit is contained in:
Eduardo Bart
2011-08-26 12:06:52 -03:00
parent d31d32bf82
commit 7359370251
57 changed files with 1097 additions and 1099 deletions

View File

@@ -13,10 +13,10 @@ Module
require 'constants'
require 'util'
require 'widget'
require 'messagebox'
require 'ui'
require 'messagebox/messagebox'
require 'dispatcher'
rootWidget = getRootWidget()
return true
onUnload: |

View File

@@ -10,50 +10,33 @@ function MessageBox.create(title, text, flags)
setmetatable(box, MessageBox)
-- create messagebox window
local window = UIWindow.create()
window:setStyle('Window')
window:setId("messageBoxWindow")
local window = UI.loadAndDisplayLocked('/core/messagebox/messagebox.otui')
window:setTitle(title)
window:centerIn("parent")
rootWidget:addChild(window)
rootWidget:lockChild(window)
-- create messagebox label
local label = UILabel.create()
local label = window:getChildById('messageBoxLabel')
label:setStyle('Label')
label:setId("messageBoxLabel")
label:setText(text)
label:addAnchor(AnchorHorizontalCenter, window:getId(), AnchorHorizontalCenter)
label:addAnchor(AnchorTop, window:getId(), AnchorTop)
label:setMargin(27, 0)
label:resizeToText()
window:addChild(label)
-- set window size based on label size
window:setWidth(label:getWidth() + 60)
window:setHeight(label:getHeight() + 64)
window:updateParentLayout()
-- setup messagebox first button
local button1 = UIButton.create()
button1:setStyle('Button')
button1:setId("messageBoxButton1")
button1:addAnchor(AnchorBottom, window:getId(), AnchorBottom)
button1:addAnchor(AnchorRight, window:getId(), AnchorRight)
button1:setMargin(10)
button1:setWidth(64)
window:addChild(button1)
local buttonRight = window:getChildById('messageBoxRightButton')
if flags == MessageBoxOk then
button1:setText("Ok")
buttonRight:setText("Ok")
box.onOk = EmptyFunction
button1.onClick = function()
buttonRight.onClick = function()
box.onOk()
box:destroy()
end
elseif flags == MessageBoxCancel then
button1:setText("Cancel")
buttonRight:setText("Cancel")
box.onCancel = EmptyFunction
button1.onClick = function()
buttonRight.onClick = function()
box.onCancel()
box:destroy()
end

View File

@@ -0,0 +1,21 @@
Window
id: messageBoxWindow
anchors.centerIn: parent
height: 80
width: 120
Label
id: messageBoxLabel
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
margin.top: 27
margin.bottom : 27
Button
id: messageBoxRightButton
anchors.bottom: parent.bottom
anchors.right: parent.right
margin.right: 10
margin.bottom: 10
width: 64
visible: true