mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
Chore: Review FrameContainer constructors for shared dimen objects
Nothing else seems problematic, this is mostly just cosmetic sanitization around Geom objects.
This commit is contained in:
@@ -753,7 +753,7 @@ function ReaderFooter:updateFooterContainer()
|
||||
}
|
||||
|
||||
self.footer_positioner = BottomContainer:new{
|
||||
dimen = Geom:new{},
|
||||
dimen = Geom:new(),
|
||||
self.footer_content,
|
||||
}
|
||||
self[1] = self.footer_positioner
|
||||
|
||||
@@ -35,7 +35,12 @@ local Geom = {
|
||||
}
|
||||
|
||||
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)
|
||||
self.__index = self
|
||||
return o
|
||||
|
||||
@@ -292,7 +292,7 @@ function ConfigOption:init()
|
||||
local name_text_max_width = name_widget_width
|
||||
local face = Font:getFace(name_font_face, name_font_size)
|
||||
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{
|
||||
text = name_text,
|
||||
@@ -828,7 +828,7 @@ function MenuBar:init()
|
||||
table.insert(menu_bar, spacing)
|
||||
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{
|
||||
line_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}
|
||||
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)
|
||||
y = y + (self.dimen.y or 0)
|
||||
if self.align == "top" then
|
||||
|
||||
@@ -194,7 +194,7 @@ function KeyValueItem:init()
|
||||
HorizontalGroup:new{
|
||||
dimen = content_dimen,
|
||||
LeftContainer:new{
|
||||
dimen = {
|
||||
dimen = Geom:new{
|
||||
w = key_w,
|
||||
h = content_dimen.h
|
||||
},
|
||||
|
||||
@@ -395,6 +395,7 @@ function MenuItem:init()
|
||||
vertical_align = "center",
|
||||
padding = 0,
|
||||
dimen = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = self.content_width,
|
||||
h = self.dimen.h
|
||||
},
|
||||
@@ -633,6 +634,7 @@ function Menu:_recalculateDimen()
|
||||
local item_height = math.floor(height_dim / self.perpage)
|
||||
self.span_width = math.floor((height_dim - (self.perpage * item_height)) / 2 - 1)
|
||||
self.item_dimen = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = self.inner_dimen.w,
|
||||
h = item_height,
|
||||
}
|
||||
@@ -864,6 +866,7 @@ function Menu:init()
|
||||
dimen = self.inner_dimen:copy(),
|
||||
WidgetContainer:new{
|
||||
dimen = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = self.screen_w,
|
||||
h = self.page_return_arrow:getSize().h,
|
||||
},
|
||||
|
||||
@@ -257,7 +257,7 @@ function SpinWidget:update(numberpicker_value, numberpicker_value_index)
|
||||
}
|
||||
self[1] = WidgetContainer:new{
|
||||
align = "center",
|
||||
dimen =Geom:new{
|
||||
dimen = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = self.screen_width,
|
||||
h = self.screen_height,
|
||||
|
||||
@@ -1012,7 +1012,7 @@ function TextBoxWidget:_renderImage(start_row_idx)
|
||||
margin = 0,
|
||||
padding = 0,
|
||||
RightContainer:new{
|
||||
dimen = {
|
||||
dimen = Geom:new{
|
||||
w = image.width,
|
||||
h = status_height,
|
||||
},
|
||||
@@ -1189,7 +1189,7 @@ function TextBoxWidget:getSize()
|
||||
self:_updateLayout()
|
||||
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
|
||||
|
||||
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_width = self.inner_dimen.w
|
||||
self.item_dimen = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = self.item_width,
|
||||
h = self.item_height
|
||||
}
|
||||
|
||||
@@ -419,6 +419,7 @@ function MosaicMenuItem:init()
|
||||
vertical_align = "top",
|
||||
padding = 0,
|
||||
dimen = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = self.width,
|
||||
h = self.height
|
||||
},
|
||||
@@ -523,8 +524,8 @@ function MosaicMenuItem:update()
|
||||
radius = Screen:scaleBySize(10),
|
||||
OverlapGroup:new{
|
||||
dimen = dimen_in,
|
||||
CenterContainer:new{ dimen=dimen_in, directory},
|
||||
BottomContainer:new{ dimen=dimen_in, nbitems},
|
||||
CenterContainer:new{ dimen = dimen_in, directory},
|
||||
BottomContainer:new{ dimen = dimen_in, nbitems},
|
||||
},
|
||||
}
|
||||
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_width = math.floor((self.inner_dimen.w - (1+self.nb_cols)*self.item_margin) / self.nb_cols)
|
||||
self.item_dimen = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = self.item_width,
|
||||
h = self.item_height
|
||||
}
|
||||
|
||||
@@ -139,7 +139,8 @@ Background = InputContainer:new{
|
||||
bordersize = 0,
|
||||
dimen = Screen:getSize(),
|
||||
Widget:new{
|
||||
dimen = {
|
||||
dimen = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = Screen:getWidth(),
|
||||
h = Screen:getHeight(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user