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