Chore: Review FrameContainer constructors for shared dimen objects

Nothing else seems problematic, this is mostly just cosmetic sanitization
around Geom objects.
reviewable/pr11388/r1
NiLuJe 4 months ago
parent 65e22ceafc
commit 90ae4acca6

@ -753,7 +753,7 @@ function ReaderFooter:updateFooterContainer()
} }
self.footer_positioner = BottomContainer:new{ self.footer_positioner = BottomContainer:new{
dimen = Geom:new{}, dimen = Geom:new(),
self.footer_content, self.footer_content,
} }
self[1] = self.footer_positioner self[1] = self.footer_positioner

@ -35,7 +35,12 @@ local Geom = {
} }
function Geom:new(o) function Geom:new(o)
if not o then o = {} end if not o then
o = {
x = 0, y = 0,
w = 0, h = 0,
}
end
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o

@ -292,7 +292,7 @@ function ConfigOption:init()
local name_text_max_width = name_widget_width local name_text_max_width = name_widget_width
local face = Font:getFace(name_font_face, name_font_size) local face = Font:getFace(name_font_face, name_font_size)
local option_name_container = RightContainer:new{ local option_name_container = RightContainer:new{
dimen = Geom:new{ w = name_widget_width, h = option_height}, dimen = Geom:new{ w = name_widget_width, h = option_height },
} }
local option_name = Button:new{ local option_name = Button:new{
text = name_text, text = name_text,
@ -828,7 +828,7 @@ function MenuBar:init()
table.insert(menu_bar, spacing) table.insert(menu_bar, spacing)
table.insert(line_bar, spacing_line) table.insert(line_bar, spacing_line)
self.dimen = Geom:new{ w = Screen:getWidth(), h = bar_height} self.dimen = Geom:new{ x = 0, y = 0, w = Screen:getWidth(), h = bar_height }
local vertical_menu = VerticalGroup:new{ local vertical_menu = VerticalGroup:new{
line_bar, line_bar,
menu_bar, menu_bar,

@ -55,6 +55,7 @@ function WidgetContainer:paintTo(bb, x, y)
self.dimen = Geom:new{x = 0, y = 0, w = content_size.w, h = content_size.h} self.dimen = Geom:new{x = 0, y = 0, w = content_size.w, h = content_size.h}
end end
-- NOTE: Clunky `or` left in on the off-chance we're passed a dimen that isn't a proper Geom object...
x = x + (self.dimen.x or 0) x = x + (self.dimen.x or 0)
y = y + (self.dimen.y or 0) y = y + (self.dimen.y or 0)
if self.align == "top" then if self.align == "top" then

@ -194,7 +194,7 @@ function KeyValueItem:init()
HorizontalGroup:new{ HorizontalGroup:new{
dimen = content_dimen, dimen = content_dimen,
LeftContainer:new{ LeftContainer:new{
dimen = { dimen = Geom:new{
w = key_w, w = key_w,
h = content_dimen.h h = content_dimen.h
}, },

@ -395,6 +395,7 @@ function MenuItem:init()
vertical_align = "center", vertical_align = "center",
padding = 0, padding = 0,
dimen = Geom:new{ dimen = Geom:new{
x = 0, y = 0,
w = self.content_width, w = self.content_width,
h = self.dimen.h h = self.dimen.h
}, },
@ -633,6 +634,7 @@ function Menu:_recalculateDimen()
local item_height = math.floor(height_dim / self.perpage) local item_height = math.floor(height_dim / self.perpage)
self.span_width = math.floor((height_dim - (self.perpage * item_height)) / 2 - 1) self.span_width = math.floor((height_dim - (self.perpage * item_height)) / 2 - 1)
self.item_dimen = Geom:new{ self.item_dimen = Geom:new{
x = 0, y = 0,
w = self.inner_dimen.w, w = self.inner_dimen.w,
h = item_height, h = item_height,
} }
@ -864,6 +866,7 @@ function Menu:init()
dimen = self.inner_dimen:copy(), dimen = self.inner_dimen:copy(),
WidgetContainer:new{ WidgetContainer:new{
dimen = Geom:new{ dimen = Geom:new{
x = 0, y = 0,
w = self.screen_w, w = self.screen_w,
h = self.page_return_arrow:getSize().h, h = self.page_return_arrow:getSize().h,
}, },

@ -257,7 +257,7 @@ function SpinWidget:update(numberpicker_value, numberpicker_value_index)
} }
self[1] = WidgetContainer:new{ self[1] = WidgetContainer:new{
align = "center", align = "center",
dimen =Geom:new{ dimen = Geom:new{
x = 0, y = 0, x = 0, y = 0,
w = self.screen_width, w = self.screen_width,
h = self.screen_height, h = self.screen_height,

@ -1012,7 +1012,7 @@ function TextBoxWidget:_renderImage(start_row_idx)
margin = 0, margin = 0,
padding = 0, padding = 0,
RightContainer:new{ RightContainer:new{
dimen = { dimen = Geom:new{
w = image.width, w = image.width,
h = status_height, h = status_height,
}, },
@ -1189,7 +1189,7 @@ function TextBoxWidget:getSize()
self:_updateLayout() self:_updateLayout()
end end
return Geom:new{w = self.width, h = self._bb:getHeight()} return Geom:new{x = 0, y = 0, w = self.width, h = self._bb:getHeight()}
end end
function TextBoxWidget:paintTo(bb, x, y) function TextBoxWidget:paintTo(bb, x, y)

@ -959,6 +959,7 @@ function ListMenu:_recalculateDimen()
self.item_height = math.floor(available_height / self.perpage) - Size.line.thin self.item_height = math.floor(available_height / self.perpage) - Size.line.thin
self.item_width = self.inner_dimen.w self.item_width = self.inner_dimen.w
self.item_dimen = Geom:new{ self.item_dimen = Geom:new{
x = 0, y = 0,
w = self.item_width, w = self.item_width,
h = self.item_height h = self.item_height
} }

@ -419,6 +419,7 @@ function MosaicMenuItem:init()
vertical_align = "top", vertical_align = "top",
padding = 0, padding = 0,
dimen = Geom:new{ dimen = Geom:new{
x = 0, y = 0,
w = self.width, w = self.width,
h = self.height h = self.height
}, },
@ -523,8 +524,8 @@ function MosaicMenuItem:update()
radius = Screen:scaleBySize(10), radius = Screen:scaleBySize(10),
OverlapGroup:new{ OverlapGroup:new{
dimen = dimen_in, dimen = dimen_in,
CenterContainer:new{ dimen=dimen_in, directory}, CenterContainer:new{ dimen = dimen_in, directory},
BottomContainer:new{ dimen=dimen_in, nbitems}, BottomContainer:new{ dimen = dimen_in, nbitems},
}, },
} }
else else
@ -890,6 +891,7 @@ function MosaicMenu:_recalculateDimen()
self.item_height = math.floor((self.inner_dimen.h - self.others_height - (1+self.nb_rows)*self.item_margin) / self.nb_rows) self.item_height = math.floor((self.inner_dimen.h - self.others_height - (1+self.nb_rows)*self.item_margin) / self.nb_rows)
self.item_width = math.floor((self.inner_dimen.w - (1+self.nb_cols)*self.item_margin) / self.nb_cols) self.item_width = math.floor((self.inner_dimen.w - (1+self.nb_cols)*self.item_margin) / self.nb_cols)
self.item_dimen = Geom:new{ self.item_dimen = Geom:new{
x = 0, y = 0,
w = self.item_width, w = self.item_width,
h = self.item_height h = self.item_height
} }

@ -139,7 +139,8 @@ Background = InputContainer:new{
bordersize = 0, bordersize = 0,
dimen = Screen:getSize(), dimen = Screen:getSize(),
Widget:new{ Widget:new{
dimen = { dimen = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(), w = Screen:getWidth(),
h = Screen:getHeight(), h = Screen:getHeight(),
} }

Loading…
Cancel
Save