25 lines
650 B
Lua
25 lines
650 B
Lua
--- @class SizedBox : SingleChildElement
|
|
local element = setmetatable({}, require "lib.simple_ui.single_child_element")
|
|
local Constraints = require("lib.simple_ui.constraints")
|
|
element.type = "SizedBox"
|
|
element.__index = element
|
|
|
|
function element:layout()
|
|
self.size = Vec3 { self.width, self.height }
|
|
|
|
if not self.child then return end
|
|
self.child.constraints = Constraints {
|
|
maxWidth = self.width,
|
|
maxHeight = self.height,
|
|
}
|
|
self.child:layout()
|
|
self.child.offset = self.offset:copy()
|
|
end
|
|
|
|
-- function element:draw()
|
|
-- print('hello2')
|
|
-- if self.child then self.child:draw() end
|
|
-- end
|
|
|
|
return element
|