29 lines
857 B
Lua
29 lines
857 B
Lua
local Constraints = require "lib.simple_ui.constraints"
|
|
local SingleChildElement = require "lib.simple_ui.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 { -- force a child to be the same size as the screen
|
|
minWidth = screenW,
|
|
maxWidth = screenW,
|
|
minHeight = screenH,
|
|
maxHeight = screenH,
|
|
}
|
|
self.child:layout()
|
|
self.child.offset = Vec3 {}
|
|
end
|
|
|
|
return element
|