Widgets: Fix a bunch of regressions after the FrameContainer change in #11364

FrameContainer now preserves its self.dimen, which means it cannot be
shared with another widget or container that might also modify it during
painting ;).

Fix #11370
Fix https://github.com/koreader/koreader/pull/11364#issuecomment-1894454657
Fix #11379
reviewable/pr11388/r1
NiLuJe 3 months ago
parent 5e4d182608
commit 65e22ceafc

@ -101,9 +101,6 @@ function FrameContainer:paintTo(bb, x, y)
else
self.dimen.x = x
self.dimen.y = y
-- Possibly redundant
self.dimen.w = my_size.w
self.dimen.h = my_size.h
end
local container_width = self.width or my_size.w
local container_height = self.height or my_size.h

@ -36,9 +36,6 @@ function UnderlineContainer:paintTo(bb, x, y)
else
self.dimen.x = x
self.dimen.y = y
-- Possibly redundant
self.dimen.w = container_size.w
self.dimen.h = container_size.h
end
local content_size = self[1]:getSize()
local p_y = y

@ -524,9 +524,6 @@ function ImageWidget:paintTo(bb, x, y)
else
self.dimen.x = x
self.dimen.y = y
-- Possibly redundant
self.dimen.w = size.w
self.dimen.h = size.h
end
logger.dbg("blitFrom", x, y, self._offset_x, self._offset_y, size.w, size.h)
local do_alpha = false

@ -41,7 +41,7 @@ local T = FFIUtil.template
Widget that displays a shortcut icon for menu item.
--]]
local ItemShortCutIcon = WidgetContainer:extend{
dimen = Geom:new{ w = Screen:scaleBySize(22), h = Screen:scaleBySize(22) },
dimen = Geom:new{ x = 0, y = 0, w = Screen:scaleBySize(22), h = Screen:scaleBySize(22) },
key = nil,
bordersize = Size.border.default,
radius = 0,
@ -74,7 +74,7 @@ function ItemShortCutIcon:init()
bordersize = self.bordersize,
radius = radius,
background = background,
dimen = self.dimen,
dimen = self.dimen:copy(),
CenterContainer:new{
dimen = self.dimen,
TextWidget:new{
@ -112,10 +112,14 @@ local MenuItem = InputContainer:extend{
function MenuItem:init()
self.content_width = self.dimen.w - 2 * Size.padding.fullscreen
local shortcut_icon_dimen = Geom:new()
local icon_width = math.floor(self.dimen.h * 4/5)
local shortcut_icon_dimen = Geom:new{
x = 0,
y = 0,
w = icon_width,
h = icon_width,
}
if self.shortcut then
shortcut_icon_dimen.w = math.floor(self.dimen.h * 4/5)
shortcut_icon_dimen.h = shortcut_icon_dimen.w
self.content_width = self.content_width - shortcut_icon_dimen.w - Size.span.horizontal_default
end
@ -1078,7 +1082,7 @@ function Menu:updateItems(select_number)
font_size = self.font_size,
infont = "infont",
infont_size = infont_size,
dimen = self.item_dimen:new(),
dimen = self.item_dimen:copy(),
shortcut = item_shortcut,
shortcut_style = shortcut_style,
table = self.item_table[i],

@ -119,9 +119,6 @@ function ProgressWidget:paintTo(bb, x, y)
else
self.dimen.x = x
self.dimen.y = y
-- Possibly redundant
self.dimen.w = my_size.w
self.dimen.h = my_size.h
end
if self.dimen.w == 0 or self.dimen.h == 0 then return end

@ -53,7 +53,7 @@ local scale_by_size = Screen:scaleBySize(1000000) * (1/1000000)
-- ItemShortCutIcon (for keyboard navigation) is private to menu.lua and can't be accessed,
-- so we need to redefine it
local ItemShortCutIcon = WidgetContainer:extend{
dimen = Geom:new{ w = Screen:scaleBySize(22), h = Screen:scaleBySize(22) },
dimen = Geom:new{ x = 0, y = 0, w = Screen:scaleBySize(22), h = Screen:scaleBySize(22) },
key = nil,
bordersize = Size.border.default,
radius = 0,
@ -82,7 +82,7 @@ function ItemShortCutIcon:init()
bordersize = self.bordersize,
radius = radius,
background = background,
dimen = self.dimen,
dimen = self.dimen:copy(),
CenterContainer:new{
dimen = self.dimen,
TextWidget:new{
@ -122,9 +122,13 @@ function ListMenuItem:init()
-- As done in MenuItem
-- Squared letter for keyboard navigation
if self.shortcut then
local shortcut_icon_dimen = Geom:new()
shortcut_icon_dimen.w = math.floor(self.dimen.h*2/5)
shortcut_icon_dimen.h = shortcut_icon_dimen.w
local icon_width = math.floor(self.dimen.h*2/5)
local shortcut_icon_dimen = Geom:new{
x = 0,
y = 0,
w = icon_width,
h = icon_width,
}
-- To keep a simpler widget structure, this shortcut icon will not
-- be part of it, but will be painted over the widget in our paintTo
self.shortcut_icon = ItemShortCutIcon:new{
@ -1015,7 +1019,7 @@ function ListMenu:_updateItemsBuildUI()
text = getMenuText(entry),
show_parent = self.show_parent,
mandatory = entry.mandatory,
dimen = self.item_dimen:new(),
dimen = self.item_dimen:copy(),
shortcut = item_shortcut,
shortcut_style = shortcut_style,
menu = self,

@ -52,7 +52,7 @@ local progress_widget
-- ItemShortCutIcon (for keyboard navigation) is private to menu.lua and can't be accessed,
-- so we need to redefine it
local ItemShortCutIcon = WidgetContainer:extend{
dimen = Geom:new{ w = Screen:scaleBySize(22), h = Screen:scaleBySize(22) },
dimen = Geom:new{ x = 0, y = 0, w = Screen:scaleBySize(22), h = Screen:scaleBySize(22) },
key = nil,
bordersize = Size.border.default,
radius = 0,
@ -81,7 +81,7 @@ function ItemShortCutIcon:init()
bordersize = self.bordersize,
radius = radius,
background = background,
dimen = self.dimen,
dimen = self.dimen:copy(),
CenterContainer:new{
dimen = self.dimen,
TextWidget:new{
@ -373,9 +373,12 @@ function MosaicMenuItem:init()
-- As done in MenuItem
-- Squared letter for keyboard navigation
if self.shortcut then
local shortcut_icon_dimen = Geom:new()
shortcut_icon_dimen.w = math.floor(self.dimen.h*1/5)
shortcut_icon_dimen.h = shortcut_icon_dimen.w
local icon_width = math.floor(self.dimen.h*1/5)
local shortcut_icon_dimen = Geom:new{
x = 0, y = 0,
w = icon_width,
h = icon_width,
}
-- To keep a simpler widget structure, this shortcut icon will not
-- be part of it, but will be painted over the widget in our paintTo
self.shortcut_icon = ItemShortCutIcon:new{
@ -979,7 +982,7 @@ function MosaicMenu:_updateItemsBuildUI()
text = getMenuText(entry),
show_parent = self.show_parent,
mandatory = entry.mandatory,
dimen = self.item_dimen:new(),
dimen = self.item_dimen:copy(),
shortcut = item_shortcut,
shortcut_style = shortcut_style,
menu = self,

Loading…
Cancel
Save