mirror of
https://github.com/airstruck/luigi.git
synced 2025-11-18 12:25:06 +00:00
improve auto dimensions
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
return { style = 'dialog',
|
||||
{ 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
|
||||
|
||||
Copyright (c) 2015 airstruck
|
||||
|
||||
@@ -36,24 +36,25 @@ return {
|
||||
height = 400,
|
||||
},
|
||||
dialogHead = {
|
||||
type = 'panel',
|
||||
height = 40,
|
||||
size = 16,
|
||||
align = 'middle center',
|
||||
height = 22,
|
||||
size = 16,
|
||||
type = 'panel',
|
||||
},
|
||||
dialogBody = {
|
||||
wrap = true,
|
||||
padding = 4,
|
||||
align = 'left middle',
|
||||
font = 'font/DejaVuSansMono.ttf',
|
||||
padding = 4,
|
||||
wrap = true,
|
||||
},
|
||||
dialogFoot = {
|
||||
type = 'panel',
|
||||
flow = 'x',
|
||||
height = 40,
|
||||
height = 'auto',
|
||||
type = 'panel',
|
||||
padding = 4,
|
||||
},
|
||||
dialogButton = {
|
||||
type = 'button',
|
||||
width = 100,
|
||||
margin = 4,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +298,14 @@ Minimum width.
|
||||
Attribute.minwidth = {}
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
@@ -310,7 +317,14 @@ Minimum height.
|
||||
Attribute.minheight = {}
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
|
||||
@@ -98,7 +98,8 @@ return function (config)
|
||||
type = 'control',
|
||||
background = backColor,
|
||||
padding = 4,
|
||||
align = 'left middle',
|
||||
align = 'left bottom',
|
||||
height = 14,
|
||||
},
|
||||
menu = {
|
||||
height = 24,
|
||||
|
||||
@@ -347,7 +347,9 @@ function Widget:calculateDimension (name)
|
||||
end
|
||||
claimed = claimed + widget.dimensions[name]
|
||||
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
|
||||
unsized = unsized + 1
|
||||
end
|
||||
@@ -416,9 +418,15 @@ function Widget:calculatePosition (axis)
|
||||
end
|
||||
|
||||
function Widget:calculateDimensionMinimum (name)
|
||||
local space = (self.margin or 0) * 2 + (self.padding or 0) * 2
|
||||
local min = name == 'width' and 'minwidth' or 'minheight'
|
||||
local value = space
|
||||
local dim = self[name]
|
||||
local min = (name == 'width') and (self.minwidth or 0)
|
||||
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
|
||||
if (name == 'width' and self.flow == 'x')
|
||||
@@ -428,9 +436,13 @@ function Widget:calculateDimensionMinimum (name)
|
||||
value = math.max(value, child:calculateDimensionMinimum(name))
|
||||
end
|
||||
end
|
||||
local dim = self[name]
|
||||
dim = type(dim) == 'number' and dim
|
||||
return math.max(value, dim or 0, self[min] or 0)
|
||||
|
||||
if value > 0 then
|
||||
local space = (self.margin or 0) * 2 + (self.padding or 0) * 2
|
||||
value = value + space
|
||||
end
|
||||
|
||||
return math.max(value, min)
|
||||
end
|
||||
|
||||
--[[--
|
||||
|
||||
Reference in New Issue
Block a user