From 04c8bc903e6a1abce3203ad61d106b122e22ceb6 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 26 Dec 2022 19:23:05 +0100 Subject: [PATCH] IconButton: Fix RTL highlighting I'm not *quite* sure what's responsible for inverting the padding values, since the only Widget I can see doing that is FrameContainer, and I can't find any in that Widget chain, but, oh, well. Easily reproducible with the FileManager's TitleBar left/right buttons (i.e., Home & Plus). --- frontend/ui/widget/iconbutton.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/ui/widget/iconbutton.lua b/frontend/ui/widget/iconbutton.lua index 3a9cfbc64..9b0231b1b 100644 --- a/frontend/ui/widget/iconbutton.lua +++ b/frontend/ui/widget/iconbutton.lua @@ -2,6 +2,7 @@ Button with a big icon image! Designed for touch devices. --]] +local BD = require("ui/bidi") local Device = require("device") local HorizontalGroup = require("ui/widget/horizontalgroup") local HorizontalSpan = require("ui/widget/horizontalspan") @@ -102,6 +103,13 @@ function IconButton:onTapIconButton() if G_reader_settings:isFalse("flash_ui") or not self.allow_flash then self.callback() else + -- Mimic BiDi left/right switcheroos... + local h_padding + if BD.mirroredUILayout() then + h_padding = self.padding_right + else + h_padding = self.padding_left + end -- c.f., ui/widget/button for more gnarly details about the implementation, but the flow of the flash_ui codepath essentially goes like this: -- 1. Paint the highlight -- 2. Refresh the highlighted item (so we can see the highlight) @@ -113,7 +121,7 @@ function IconButton:onTapIconButton() -- Highlight -- self.image.invert = true - UIManager:widgetInvert(self.image, self.dimen.x + self.padding_left, self.dimen.y + self.padding_top) + UIManager:widgetInvert(self.image, self.dimen.x + h_padding, self.dimen.y + self.padding_top) UIManager:setDirty(nil, "fast", self.dimen) UIManager:forceRePaint() @@ -122,7 +130,7 @@ function IconButton:onTapIconButton() -- Unhighlight -- self.image.invert = false - UIManager:widgetInvert(self.image, self.dimen.x + self.padding_left, self.dimen.y + self.padding_top) + UIManager:widgetInvert(self.image, self.dimen.x + h_padding, self.dimen.y + self.padding_top) -- Callback --