mirror of
https://github.com/airstruck/luigi.git
synced 2026-01-10 16:28:23 +00:00
improve auto dimensions
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
return { style = 'dialog',
|
return { style = 'dialog',
|
||||||
{ style = 'dialogHead', text = 'About LUIGI' },
|
{ style = 'dialogHead', text = 'About LUIGI' },
|
||||||
{ style = 'dialogBody', align = 'left middle', padding = 24, icon = 'logo.png', text = [[
|
{ style = 'dialogBody', padding = 24, icon = 'logo.png', text = [[
|
||||||
Lovely User Interfaces for Game Inventors
|
Lovely User Interfaces for Game Inventors
|
||||||
|
|
||||||
Copyright (c) 2015 airstruck
|
Copyright (c) 2015 airstruck
|
||||||
|
|||||||
@@ -36,24 +36,25 @@ return {
|
|||||||
height = 400,
|
height = 400,
|
||||||
},
|
},
|
||||||
dialogHead = {
|
dialogHead = {
|
||||||
type = 'panel',
|
|
||||||
height = 40,
|
|
||||||
size = 16,
|
|
||||||
align = 'middle center',
|
align = 'middle center',
|
||||||
|
height = 22,
|
||||||
|
size = 16,
|
||||||
|
type = 'panel',
|
||||||
},
|
},
|
||||||
dialogBody = {
|
dialogBody = {
|
||||||
wrap = true,
|
align = 'left middle',
|
||||||
padding = 4,
|
|
||||||
font = 'font/DejaVuSansMono.ttf',
|
font = 'font/DejaVuSansMono.ttf',
|
||||||
|
padding = 4,
|
||||||
|
wrap = true,
|
||||||
},
|
},
|
||||||
dialogFoot = {
|
dialogFoot = {
|
||||||
type = 'panel',
|
|
||||||
flow = 'x',
|
flow = 'x',
|
||||||
height = 40,
|
height = 'auto',
|
||||||
|
type = 'panel',
|
||||||
|
padding = 4,
|
||||||
},
|
},
|
||||||
dialogButton = {
|
dialogButton = {
|
||||||
type = 'button',
|
type = 'button',
|
||||||
width = 100,
|
width = 100,
|
||||||
margin = 4,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,7 +298,14 @@ Minimum width.
|
|||||||
Attribute.minwidth = {}
|
Attribute.minwidth = {}
|
||||||
|
|
||||||
function Attribute.minwidth.set (widget, value)
|
function Attribute.minwidth.set (widget, value)
|
||||||
widget.attributes.minwidth = value
|
local attributes = widget.attributes
|
||||||
|
attributes.minwidth = value
|
||||||
|
if type(value) == 'number' then
|
||||||
|
local current = attributes.width
|
||||||
|
if type(current) == 'number' then
|
||||||
|
attributes.width = math.max(current, value)
|
||||||
|
end
|
||||||
|
end
|
||||||
widget.reshape(widget.parent or widget)
|
widget.reshape(widget.parent or widget)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -310,7 +317,14 @@ Minimum height.
|
|||||||
Attribute.minheight = {}
|
Attribute.minheight = {}
|
||||||
|
|
||||||
function Attribute.minheight.set (widget, value)
|
function Attribute.minheight.set (widget, value)
|
||||||
widget.attributes.minheight = value
|
local attributes = widget.attributes
|
||||||
|
attributes.minheight = value
|
||||||
|
if type(value) == 'number' then
|
||||||
|
local current = attributes.height
|
||||||
|
if type(current) == 'number' then
|
||||||
|
attributes.height = math.max(current, value)
|
||||||
|
end
|
||||||
|
end
|
||||||
widget.reshape(widget.parent or widget)
|
widget.reshape(widget.parent or widget)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ return function (config)
|
|||||||
type = 'control',
|
type = 'control',
|
||||||
background = backColor,
|
background = backColor,
|
||||||
padding = 4,
|
padding = 4,
|
||||||
align = 'left middle',
|
align = 'left bottom',
|
||||||
|
height = 14,
|
||||||
},
|
},
|
||||||
menu = {
|
menu = {
|
||||||
height = 24,
|
height = 24,
|
||||||
|
|||||||
@@ -347,7 +347,9 @@ function Widget:calculateDimension (name)
|
|||||||
end
|
end
|
||||||
claimed = claimed + widget.dimensions[name]
|
claimed = claimed + widget.dimensions[name]
|
||||||
elseif value then
|
elseif value then
|
||||||
claimed = claimed + value
|
local min = (name == 'width') and (widget.minwidth or 0)
|
||||||
|
or (widget.minheight or 0)
|
||||||
|
claimed = claimed + math.max(value, min)
|
||||||
else
|
else
|
||||||
unsized = unsized + 1
|
unsized = unsized + 1
|
||||||
end
|
end
|
||||||
@@ -416,9 +418,15 @@ function Widget:calculatePosition (axis)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Widget:calculateDimensionMinimum (name)
|
function Widget:calculateDimensionMinimum (name)
|
||||||
local space = (self.margin or 0) * 2 + (self.padding or 0) * 2
|
local dim = self[name]
|
||||||
local min = name == 'width' and 'minwidth' or 'minheight'
|
local min = (name == 'width') and (self.minwidth or 0)
|
||||||
local value = space
|
or (self.minheight or 0)
|
||||||
|
|
||||||
|
if type(dim) == 'number' then
|
||||||
|
return math.max(dim, min)
|
||||||
|
end
|
||||||
|
|
||||||
|
local value = 0
|
||||||
|
|
||||||
for _, child in ipairs(self) do
|
for _, child in ipairs(self) do
|
||||||
if (name == 'width' and self.flow == 'x')
|
if (name == 'width' and self.flow == 'x')
|
||||||
@@ -428,9 +436,13 @@ function Widget:calculateDimensionMinimum (name)
|
|||||||
value = math.max(value, child:calculateDimensionMinimum(name))
|
value = math.max(value, child:calculateDimensionMinimum(name))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local dim = self[name]
|
|
||||||
dim = type(dim) == 'number' and dim
|
if value > 0 then
|
||||||
return math.max(value, dim or 0, self[min] or 0)
|
local space = (self.margin or 0) * 2 + (self.padding or 0) * 2
|
||||||
|
value = value + space
|
||||||
|
end
|
||||||
|
|
||||||
|
return math.max(value, min)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[--
|
--[[--
|
||||||
|
|||||||
Reference in New Issue
Block a user