add status widget and attribute

This commit is contained in:
airstruck
2015-12-05 15:43:40 -05:00
parent 3daff0bcad
commit c21611748c
7 changed files with 62 additions and 55 deletions

View File

@@ -1,8 +1,10 @@
return { id = 'mainWindow', type = 'panel',
{ type = 'menu', id = 'menubar', flow = 'x',
{ text = 'File',
{ text = 'Save', id = 'menuSave', key = 'ctrl-s' },
{ text = 'Quit', id = 'menuQuit', key = 'escape' },
{ text = 'Save', id = 'menuSave', key = 'ctrl-s',
status = 'Save to disk' },
{ text = 'Quit', id = 'menuQuit', key = 'escape',
status = 'Quit the demo' },
},
{ text = 'Edit',
{ text = 'Cut', key = 'ctrl-c' },
@@ -27,11 +29,14 @@ return { id = 'mainWindow', type = 'panel',
},
{ type = 'panel', id = 'toolbar', style = 'toolbar', flow = 'x',
{ type = 'button', id = 'newButton', style = 'toolButton', key = 'z',
icon = 'icon/32px/Blueprint.png' },
icon = 'icon/32px/Blueprint.png',
status = 'Create a new thing' },
{ type = 'button', id = 'loadButton', style = 'toolButton',
icon = 'icon/32px/Calendar.png' },
icon = 'icon/32px/Calendar.png',
status = 'Load a thing' },
{ type = 'button', id = 'saveButton', style = 'toolButton',
icon = 'icon/32px/Harddrive.png' },
icon = 'icon/32px/Harddrive.png',
status = 'Save a thing' },
},
{ flow = 'x',
{ id = 'leftSideBox', width = 200, minwidth = 64, scroll = true, type = 'panel',
@@ -72,5 +77,5 @@ return { id = 'mainWindow', type = 'panel',
{ type = 'button', key='return', width = 80, id = 'aButton', text = 'Styling!',
font = 'font/DejaVuSansMono.ttf' },
},
{ type = 'panel', id = 'statusbar', height = 24, padding = 4, color = { 255, 0, 0 } },
{ type = 'status', id = 'statusbar', height = 24, padding = 4, color = { 255, 0, 0 } },
}

View File

@@ -5,31 +5,11 @@ local style = require 'style'
local layout = Layout(require 'layout.main')
layout:setStyle(style)
-- layout:setTheme(require 'luigi.theme.light')
layout.leftSideBox:addChild {
text = 'Alright man this is a great song\nwith a really long title...',
style = 'listThing',
align = 'middle right'
}
layout.slidey:onChange(function (event)
layout.progressBar.value = event.value
end)
layout:onMove(function (event)
local w = event.target
layout.statusbar.text = (tostring(w.type)) .. ' ' ..
(w.id or '(unnamed)') .. ' ' ..
w:getX() .. ', ' .. w:getY() .. ' | ' ..
w:getWidth() .. 'x' .. w:getHeight()
end)
layout.newButton:onMove(function (event)
layout.statusbar.text = 'Create a new thing'
return false
end)
layout.newButton:onPress(function (event)
print('creating a new thing!')
end)
@@ -60,31 +40,29 @@ layout.mainCanvas.align = 'top'
layout.mainCanvas.wrap = true
-- license dialog
-- help dialogs
local aboutDialog = Layout(require 'layout.about')
local licenseDialog = Layout(require 'layout.license')
aboutDialog:setStyle(style)
licenseDialog:setStyle(style)
aboutDialog.closeButton:onPress(function()
aboutDialog:hide()
end)
licenseDialog.closeButton:onPress(function()
licenseDialog:hide()
end)
layout.license:onPress(function()
aboutDialog:hide()
licenseDialog:show()
end)
-- about dialog
local aboutDialog = Layout(require 'layout.about')
aboutDialog:setStyle(style)
aboutDialog.closeButton:onPress(function()
aboutDialog:hide()
end)
layout.about:onPress(function()
licenseDialog:hide()
aboutDialog:show()
end)