mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Button: Better handling of translucent MovableContainer (#7223)
* DictQuickLookup: Preserve alpha when switching dict, and scrolling inside a dict. * Start moving the NumberPicker alpha hack to Button itself This makes handling flash_ui easier and saner, avoiding flickering. * Handle the transparency hack entirely from within Button * Murder the now unnecessary NumberPicker update_callback hack * Tweak comments * And the Button handling made that redundant, too * Squish debug print * More comment tweaks * Reset transparency on scrolling instead of rpeserving it * Reset alpha when switching dictionaries * Simplify the pre/post callbakc transparency state handling And explain why we need to care. * Give a named reference to ButtonDialog's MovableContainer, so the Button alpha hack behaves with it * Document the "self.movable" convention * Amend that comment a bit e.g., we don't care much about MultiConfirmBox'w MpvableContainer, as any button action will close it. * And make SkimTo's MovableContainer accessible so that Button can grok that it's translucent
This commit is contained in:
@@ -234,6 +234,13 @@ function Button:showHide(show)
|
||||
end
|
||||
|
||||
function Button:onTapSelectButton()
|
||||
-- NOTE: We have a few tricks up our sleeve in case our parent is inside a translucent MovableContainer...
|
||||
local was_translucent = self.show_parent and self.show_parent.movable and self.show_parent.movable.alpha
|
||||
-- We make a distinction between transparency pre- and post- callback, because if a widget *was* transparent,
|
||||
-- but no longer is post-callback, we want to ensure that we refresh the *full* container,
|
||||
-- instead of just the button's frame, in order to avoid leaving bits of the widget transparent ;).
|
||||
local is_translucent = was_translucent
|
||||
|
||||
if self.enabled and self.callback then
|
||||
if G_reader_settings:isFalse("flash_ui") then
|
||||
self.callback()
|
||||
@@ -276,7 +283,13 @@ function Button:onTapSelectButton()
|
||||
UIManager:forceRePaint() -- Ensures we have a chance to see the highlight
|
||||
end
|
||||
self.callback()
|
||||
UIManager:forceRePaint() -- Ensures whatever the callback wanted to paint will be shown *now*...
|
||||
-- Check if the callback reset transparency...
|
||||
is_translucent = was_translucent and self.show_parent.movable.alpha
|
||||
-- We don't want to fence the callback when we're *still* translucent, because we want a *single* refresh post-callback *and* post-unhighlight,
|
||||
-- in order to avoid flickering.
|
||||
if not is_translucent then
|
||||
UIManager:forceRePaint() -- Ensures whatever the callback wanted to paint will be shown *now*...
|
||||
end
|
||||
if self.vsync then
|
||||
-- NOTE: This is mainly useful when the callback caused a REAGL update that we do not explicitly fence already,
|
||||
-- (i.e., Kobo Mk. 7).
|
||||
@@ -346,6 +359,16 @@ function Button:onTapSelectButton()
|
||||
elseif type(self.tap_input_func) == "function" then
|
||||
self:onInput(self.tap_input_func())
|
||||
end
|
||||
|
||||
-- If our parent belongs to a translucent MovableContainer, repaint all the things to honor alpha without layering glitches,
|
||||
-- and refresh the full container, because the widget might have inhibited its own setDirty call to avoid flickering (c.f., *SpinWidget).
|
||||
if was_translucent then
|
||||
-- If the callback reset the transparency, we only need to repaint our parent
|
||||
UIManager:setDirty(is_translucent and "all" or self.show_parent, function()
|
||||
return "ui", self.show_parent.movable.dimen
|
||||
end)
|
||||
end
|
||||
|
||||
if self.readonly ~= true then
|
||||
return true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user