context menus working

This commit is contained in:
airstruck
2015-12-24 09:42:04 -05:00
parent 2d0dec2c70
commit 3abcce1615
9 changed files with 148 additions and 61 deletions

View File

@@ -40,13 +40,12 @@ return { id = 'mainWindow',
},
{ flow = 'x',
{ id = 'leftSideBox', minwidth = 200, width = 200, scroll = true, type = 'panel',
{ style = 'listThing', align = 'middle center',
text = 'Try the scroll wheel on this area.',
context = {
{ text = 'Use sans-serif font', id = 'sans' },
{ text = 'Use monospace font' }
}
context = {
{ text = 'Use sans-serif font', id = 'sans' },
{ text = 'Use monospace font', id = 'mono' }
},
{ style = 'listThing', align = 'middle center',
text = 'Try the scroll wheel on this area.', },
{ style = 'listThing', align = 'middle center',
text = 'This text is centered, and in the middle vertically.' },
{ style = 'listThing', align = 'middle left',
@@ -65,11 +64,15 @@ return { id = 'mainWindow',
{ id = 'flowTest', height = 'auto', minheight = 128,
{
{ type = 'label', text = 'Slider' },
{ type = 'slider', id = 'slidey', width = false },
{ type = 'slider', id = 'slidey', width = false, },
},
{
{ type = 'label', text = 'Stepper' },
{ type = 'stepper', id = 'stepper', width = false, wrap = true,
context = {
{ text = 'Use sans-serif font', id = 'sans2' },
{ text = 'Use monospace font', id = 'mono2' }
},
{ value = 1, text = 'Thing One' },
{ value = 2, text = 'Thing Two' },
{ value = 3, text = 'Thing Three' },

View File

@@ -80,6 +80,22 @@ end)
local Backend = require 'luigi.backend'
layout.menuQuit:onPress(Backend.quit)
layout.mono:onPress(function()
layout.leftSideBox.font = 'font/DejaVuSansMono.ttf'
end)
layout.sans:onPress(function()
layout.leftSideBox.font = false
end)
layout.mono2:onPress(function()
layout.stepper.font = 'font/DejaVuSansMono.ttf'
end)
layout.sans2:onPress(function()
layout.stepper.font = false
end)
-- show the main layout
layout:show()

View File

@@ -54,10 +54,10 @@ window.restore:onPress(function ()
window.root.maximized = false
end)
window:onReshape(function (event)
local w, h = Backend:getWindowSize()
-- local w, h = Backend:getWindowSize()
-- use widget.attributes to do a raw update, avoid firing onChange
window.width.attributes.value = tostring(w)
window.height.attributes.value = tostring(h)
window.width.attributes.value = tostring(event.width)
window.height.attributes.value = tostring(event.height)
end)
window:onChange(function (event)
local target = event.target