33 lines
1000 B
Lua
33 lines
1000 B
Lua
local Constraints = require "lib.simple_ui.core.constraints"
|
|
local SingleChildElement = require "lib.simple_ui.core.single_child_element"
|
|
|
|
--- @class Placeholder : SingleChildElement
|
|
local element = setmetatable({}, SingleChildElement)
|
|
element.__index = element
|
|
element.type = "Placeholder"
|
|
|
|
function element:layout()
|
|
self._size_ = Vec3 { self._constraints_.maxWidth, self._constraints_.maxHeight }
|
|
|
|
if not self._child_ then return end
|
|
self._child_._constraints_ = Constraints(self._constraints_)
|
|
self._child_:layout()
|
|
end
|
|
|
|
function element:draw()
|
|
love.graphics.setLineStyle("rough")
|
|
love.graphics.rectangle("line", 0, 0, self._size_.x, self._size_.y)
|
|
|
|
love.graphics.line(0, 0, self._size_.x, self._size_.y)
|
|
love.graphics.line(0, self._size_.y, self._size_.x, 0)
|
|
love.graphics.setLineStyle("smooth")
|
|
end
|
|
|
|
--- @return Placeholder
|
|
--- @param values {child: UIElement?}
|
|
function element:new(values)
|
|
return SingleChildElement.new(self, values)
|
|
end
|
|
|
|
return element
|