------------------------------------------------------------------------------ -- Imports ------------------------------------------------------------------------------ local make_class = require 'src.utils.classes' local Layout = require 'src.ui.layout' ------------------------------------------------------------------------------ -- Class definitions ------------------------------------------------------------------------------ ---@class VBox: Layout local VBox = make_class(Layout) ------------------------------------------------------------------------------ -- Class methods ------------------------------------------------------------------------------ function VBox:_init(x, y, w, h, spacing, float) Layout._init(self, x, y, w, h, spacing, float) end function VBox:load() Layout.load(self) local _y = self.y -- Load required assets if needed and then compute the coordinates of each button. for _, v in pairs(self.elements) do if v.float_right then v.x = self.w - v.w else v.x = self.x end v.y = _y _y = _y + v.h + self.spacing end end function VBox:set_dimensions() if self.w == nil then self.w = 0 for _, v in pairs(self.elements) do if v.w > self.w then self.w = v.w end end end if self.h == nil then self.h = 0 for i, v in pairs(self.elements) do self.h = self.h + v.h if i < #self.elements then self.h = self.h + self.spacing end end end end ------------------------------------------------------------------------------ -- Module return ------------------------------------------------------------------------------ return VBox