mirror of
https://github.com/airstruck/luigi.git
synced 2025-12-19 02:16:43 +00:00
more window stuff
This commit is contained in:
@@ -3,6 +3,7 @@ local Backend = require 'luigi.backend'
|
||||
|
||||
local window = Layout {
|
||||
type = 'window',
|
||||
background = { 255, 255, 255 },
|
||||
icon = 'logo.png',
|
||||
title = 'Test window',
|
||||
width = 300,
|
||||
@@ -11,9 +12,37 @@ local window = Layout {
|
||||
minheight = 100,
|
||||
maxwidth = 640,
|
||||
maxheight = 480,
|
||||
{ type = 'button', id = 'maximize', text = 'Maximize' },
|
||||
{ type = 'button', id = 'minimize', text = 'Minimize' },
|
||||
{ type = 'button', id = 'restore', text = 'Restore' },
|
||||
left = 400,
|
||||
top = 400,
|
||||
{ type = 'panel',
|
||||
{
|
||||
text = 'This is an example of the "window" widget type.',
|
||||
align = 'middle center', wrap = true,
|
||||
},
|
||||
{ flow = 'x', height = 'auto',
|
||||
{ type = 'button', id = 'maximize', text = 'Maximize' },
|
||||
{ type = 'button', id = 'minimize', text = 'Minimize' },
|
||||
{ type = 'button', id = 'restore', text = 'Restore' },
|
||||
},
|
||||
{ flow = 'x', height = 'auto',
|
||||
{
|
||||
{ type = 'label', text = 'Left' },
|
||||
{ type = 'text', id = 'left' },
|
||||
},
|
||||
{
|
||||
{ type = 'label', text = 'Top' },
|
||||
{ type = 'text', id = 'top' },
|
||||
},
|
||||
{
|
||||
{ type = 'label', text = 'Width' },
|
||||
{ type = 'text', id = 'width' },
|
||||
},
|
||||
{
|
||||
{ type = 'label', text = 'Height' },
|
||||
{ type = 'text', id = 'height' },
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
window.maximize:onPress(function ()
|
||||
@@ -25,6 +54,20 @@ end)
|
||||
window.restore:onPress(function ()
|
||||
window.root.maximized = false
|
||||
end)
|
||||
window:onReshape(function (event)
|
||||
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)
|
||||
end)
|
||||
window:onChange(function (event)
|
||||
local target = event.target
|
||||
if target.type ~= 'text' then return end
|
||||
local id = target.id
|
||||
if id and window.root.attributeDescriptors[id] then
|
||||
window.root[id] = tonumber(event.value)
|
||||
end
|
||||
end)
|
||||
|
||||
window:show()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user