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:
NiLuJe
2021-02-02 04:27:14 +01:00
committed by GitHub
parent 4a89c93290
commit 285fc75aa7
10 changed files with 96 additions and 92 deletions

View File

@@ -119,9 +119,19 @@ function ScrollHtmlWidget:scrollToRatio(ratio)
self.htmlbox_widget:freeBb()
self.htmlbox_widget:_render()
UIManager:setDirty(self.dialog, function()
return "partial", self.dimen
end)
-- If our dialog is currently wrapped in a MovableContainer and that container has been made translucent,
-- reset the alpha and refresh the whole thing, because we assume that a scroll means the user actually wants to
-- *read* the content, which is kinda hard on a nearly transparent widget ;).
if self.dialog.movable and self.dialog.movable.alpha then
self.dialog.movable.alpha = nil
UIManager:setDirty(self.dialog, function()
return "partial", self.dialog.movable.dimen
end)
else
UIManager:setDirty(self.dialog, function()
return "partial", self.dimen
end)
end
end
function ScrollHtmlWidget:scrollText(direction)
@@ -147,9 +157,17 @@ function ScrollHtmlWidget:scrollText(direction)
self.htmlbox_widget:freeBb()
self.htmlbox_widget:_render()
UIManager:setDirty(self.dialog, function()
return "partial", self.dimen
end)
-- Handle the container's alpha as above...
if self.dialog.movable and self.dialog.movable.alpha then
self.dialog.movable.alpha = nil
UIManager:setDirty(self.dialog, function()
return "partial", self.dialog.movable.dimen
end)
else
UIManager:setDirty(self.dialog, function()
return "partial", self.dimen
end)
end
end
function ScrollHtmlWidget:onScrollText(arg, ges)