30 lines
873 B
Lua
30 lines
873 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
|