30 lines
865 B
Lua

local Constraints = require "lib.simple_ui.core.constraints"
local SingleChildElement = require "lib.simple_ui.core.single_child_element"
--- @class ScreenArea : SingleChildElement
local element = setmetatable({}, SingleChildElement)
element.__index = element
element.type = "ScreenArea"
function element:layout()
local screenW, screenH = love.graphics.getWidth(), love.graphics.getHeight()
self._constraints_ = Constraints {
maxWidth = screenW,
maxHeight = screenH
}
self._size_ = Vec3 { screenW, screenH }
if not self.child then return end
self.child._constraints_ = Constraints(self._constraints_)
self.child:layout()
self.child._offset_ = Vec3 {}
end
--- @return ScreenArea
--- @param values {child: UIElement?}
function element:new(values)
return SingleChildElement.new(self, values)
end
return element