Skip to content

Invert progress bar direction, independently of UI layout (LTR/RTL) - #13382

Merged
Frenzie merged 15 commits into
koreader:masterfrom
Commodore64user:invert-pro-bar
Aug 29, 2025
Merged

Frenzie merged 15 commits into
koreader:masterfrom
Commodore64user:invert-pro-bar

Conversation

@Commodore64user

@Commodore64user Commodore64user commented Mar 8, 2025 •

Copy link
Copy Markdown
Member

what's new

  • Added a new invert_direction property to ProgressWidget and implemented logic to invert the direction of progress bars based on this property. This includes updates to the paintTo and getPercentageFromPosition methods to handle the inversion logic. (frontend/ui/widget/progresswidget.lua)

  • Updated ReaderFooter to initialize and toggle the invert_direction property based on a new invert_ui_layout_mirroring setting. Added the onToggleUILayoutMiroring method to handle toggling this feature. (frontend/apps/reader/modules/readerfooter.lua)

  • Added a new menu option to invert document-related dialogs for non-touch devices, including a callback to toggle the invert_ui_layout_mirroring setting. Updated the help text to clarify its purpose. (frontend/apps/reader/modules/readermenu.lua)

  • Updated the existing "Invert document-related dialogs" menu entry in page_turns.lua to use the new toggle event and adjusted the help text for consistency. (frontend/ui/elements/page_turns.lua)

  • Modified SkimToWidget to dynamically adjust button functionality, labels, and layout based on the invert_ui_layout_mirroring setting. This includes reversing button orders and D-Pad navigation layouts when inversion is enabled. (frontend/ui/widget/skimtowidget.lua)

  • Added the Event module to support broadcasting the toggle event for UI layout mirroring. (frontend/ui/elements/page_turns.lua)

  • Removed redundant logic in ReaderView:shouldInvertBiDiLayoutMirroring and added a new onToggleUILayoutMiroring method to handle setting updates. (frontend/apps/reader/modules/readerview.lua)

bug fix

screenshots

on non-touch devices


This change is Reviewable

@mergen3107

Copy link
Copy Markdown
Contributor

Tested on PW6 with manga folder directory defaults (KOReader v2024.11-224-g23ed86a0f). Works great!

Here is how my directory defaults looks like now:

return {--do NOT change this line
...(bunch of comments)
-- ADD YOUR DEFAULTS HERE:
    ["/mnt/us/books/[manga]"] = {
        ["inverse_reading_order"] = true,
        ["invert_progress_direction"] = true,
        ["kopt_zoom_direction"] = 0,
    },
}--do NOT change this line

Follow on (optional): is there a way to also have certain gestures flipped as well?
For example, I have bottom edge swipe right (next chapter) and bottom edge swipe left (previous chapter) in normal books.
With RTL, I would love to have them flipped, so they will follow the direction of now-flipped progress bar.

I tried adding those lines from gestures.lua to directory_defaults.lua, but it didn't work:

["one_finger_swipe_bottom_edge_left"] = {
            ["next_chapter"] = true,
            ["settings"] = {
                ["order"] = {
                    [1] = "prev_chapter",
                },
            },
        },
["one_finger_swipe_bottom_edge_right"] = {
            ["prev_chapter"] = true,
            ["settings"] = {
                ["order"] = {
                    [1] = "next_chapter",
                },
            },
        },

@mergen3107

Copy link
Copy Markdown
Contributor

For completeness, I had this super hacky way, but it looks sketchy :D #7917 (comment)

@mergen3107

Copy link
Copy Markdown
Contributor

Also because it is semi-manual - with those script, I'd need to keep switching files by running scripts each time I transition between RTL and LTR books

@mergen3107

Copy link
Copy Markdown
Contributor

As I understood so far from the code, directory_defaults are applied on the book level, whereas gesures are on a higher level, reader or fm. So currently there is no way to override gestures with directory_defaults...

@mergen3107

Copy link
Copy Markdown
Contributor

@Commodore64user
Oh-oh, I spoke too soon :D

  1. ["invert_progress_direction"] = true, doesn't even go to the book's metadata.lua. Is this by design?
  2. My directory_defaults tweak with invert_progress_direction actually doesn't work. I setting the setting manually first time to test, and left it on. Then I tried the tweak - and thought it has worked. But now I can see it persists even in LTR books.

I guess I will wait for directory_defaults implementation...

},
{
text = _("Invert progress bar direction"),
help_text = _("Invert the direction of the progress bar—useful for manga and right-to-left reading, even when using a left-to-right interface, or vice versa."),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bar—useful 
right-to-left 

Confusing to read for me French used to spaces. I don't think we use — anywhere, so can you try to use classic punctuation.

useful for manga and right-to-left reading, even when using a left-to-right interface
I think , even is uneeded, it is only useful in this case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for reference, that was supposed to be bar—useful and right-to-left. They are different

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just use a \n instead. (As an aside, en em-dash should be surrounded by hair spaces.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the long sentence in the end, I would just put full stop after progress bar.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I mean. A period at the end, followed by a newline.

Comment on lines +192 to +207
local marker_x, icon_x, icon_y
if _mirroredUI then
marker_x = x + self.margin_h + self.bordersize + (fill_width - (fill_width * self.initial_percentage))
else
marker_x = x + self.margin_h + self.bordersize + (fill_width * self.initial_percentage)
end
icon_x = marker_x - math.floor(self.initial_pos_icon:getSize().w / 2)
if self.height <= INITIAL_MARKER_HEIGHT_THRESHOLD then
self.initial_pos_icon:paintTo(bb, Math.round(fill_x + math.ceil(fill_width * self.initial_percentage) - self.height / 4), y - Math.round(self.height / 6))
icon_y = y - Math.round(self.height / 6)
else
self.initial_pos_icon:paintTo(bb, Math.round(fill_x + math.ceil(fill_width * self.initial_percentage) - self.height / 2), y)
icon_y = y
end
self.initial_pos_icon:paintTo(bb, icon_x, icon_y)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this fixing a but with the original mirroredUI ?
Or is is not, and in this case why it's needed for you but not for originally for mirroredUI?
(Just asking, I haven't tried to understand what all this is doing).

Also, any change of behaviour ? I don't see the / 4 from ...self.height / 4 anywhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it is fixing a bug with mirroredUI. the indicator wasn't placed in the correct coordinate. i'll add the 4 back to try and keeo it as it was, i was going to when testing but somehow escaped me.

Comment thread frontend/ui/widget/skimtowidget.lua Outdated
Comment on lines 95 to 102
-- Determine if we need to invert the button functionality and labels
local invert_buttons = self.progress_bar.invert_direction
-- Bottom row buttons
local button_minus = Button:new{
text = "-1",
text = invert_buttons and "+1" or "-1",
text_font_size = button_font_size,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travestizing the buttons is ugly and woke and adds noise in all of them.
Can't you just later reverse the buttons, ie with util.arrayRevers(bottom_buttons_row) before it is used?
(We do that with painting, I think you can do that after the widget is created, before it is used:

if _mirroredUI and self.allow_mirroring then
util.arrayReverse(self)
end

)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I know, I felt dirty doing it :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless I am misunderstanding what you are suggesting (which might as well be the case), I am trying and failing miserably. the only thing I was able to do was invert [somehow] the FocusManager cursor keys, so if you wanted to get your hands dirty ;)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--- a/frontend/ui/widget/skimtowidget.lua
+++ b/frontend/ui/widget/skimtowidget.lua
@@ -302,6 +302,10 @@ function SkimToWidget:init()
             button_plus_ten,
         }
         radius = Size.radius.window
+        if true then -- if your setting (but not if UI mirroredUI as this is handled by HorizontalGroup directly)
+            local util = require("util") -- at top
+            util.arrayReverse(bottom_buttons_row)
+        end
     else
         top_row_span = VerticalSpan:new{ width = Size.padding.default }
         top_buttons_row = HorizontalGroup:new{

image

(do that for the other top_buttons_row (in full_mode and in not full_mode))
bottom_buttons_row is a HorizontalGroup widget - but it's also just an array of subwidgets, and util.arrayReverse() will just reorder this array part.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is what I was doing, never mind I figured out why focus manager was losing it's marbles. we also need to update self.layout duh

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, as of 2024.11, the non-full skim widget is a disgrace in RTL

Screenshot 2025-03-08 at 13 56 48

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disgrace because of the different order than in center position?

@Commodore64user Commodore64user Mar 8, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, look at the difference. This is what you get inverting the progress bar in a LTR language

Screenshot 2025-03-08 at 23 24 45

the previous one is the normal mode in RTL. (the hour-glass marker has now been fixed though)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although maybe it is supposed to look like that...??? now I'm not sure

Screenshot 2025-03-08 at 23 36 27

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. It is the relative position of icons. Yeah, it doesn't seem right. For example, hollow arrow and the bar for chapter ones must be correct. Looks like now everything in compact Skim widget with KOReader's RTL is swapped left-right blindly.

@Commodore64user

Copy link
Copy Markdown
Member Author
  1. ["invert_progress_direction"] = true, doesn't even go to the book's metadata.lua. Is this by design?
  2. My directory_defaults tweak with invert_progress_direction actually doesn't work. I setting the setting manually first time to test, and left it on. Then I tried the tweak - and thought it has worked. But now I can see it persists even in LTR books.

I guess I will wait for directory_defaults implementation...

well, you might wait for a long time because the status bar is global. perhaps you could try running a profile

@mergen3107

Copy link
Copy Markdown
Contributor

frontend/dispatcher.lua: Added a new dispatcher event toggle_progress_bar_direction to manage the progress bar direction toggle.

Thanks @Commodore64user !

I just learned in a different thread about "check if book path contains specific string" on book opening/closing for auto-exec Profile triggers.

How feasible it is to add Dispatcher events with strictly Turn off Progress Bar Inversion and Turn on Progress Bar Inversion?

For now I can try the Toggle event.

@mergen3107

Copy link
Copy Markdown
Contributor

It works fine with auto-exec Profile!

Conditions: on book opening/closing either path check for [manga]

Actions:
Toggle Statistics
Toggle Progress bar RTL

My experience so far:

  1. Toggle Statistics has a nice notification "Statistics enabled/disabled" when fired. @Commodore64user would like to add such Notifications for Toggle RT Progress bar dispatcher event?
  2. This auto-exec is semi-blind. Meaning that I must rely on myself NOT to toggle Statistics/RTL outside [manga] books :D

It would be much more definitive if there were Turn ON, Turn OFF dispatcher events for both. Then I could make two separate profiles - one for book opening (Turn OFF), one for book closing (Turn ON).

@hius07 @Commodore64user
Thank you guys for making all these changes happen!

@mergen3107

Copy link
Copy Markdown
Contributor

I also created a new Profile to toggle statistics in Zotero documents.

This auto-exec is semi-blind. Meaning that I must rely on myself NOT to toggle Statistics/RTL outside [manga] books :D

That limitation also means I should AVOID switching between [manga] and Zotero books :D it will screw up Statistics and make RTL/Statistics toggles mismatch.

@Commodore64user

Commodore64user commented Mar 8, 2025 •

Copy link
Copy Markdown
Member Author

How feasible it is to add Dispatcher events with strictly Turn off Progress Bar Inversion and Turn on Progress Bar Inversion?

you should be able to do so now.

Toggle Statistics has a nice notification "Statistics enabled/disabled" when fired. would like to add such Notifications for Toggle RT Progress bar dispatcher event?

It is quite obvious if the gesture/hotkey did on did not invert it. do you really need a bit of text to tell you what you can already verify with your eyes?

Comment thread frontend/ui/widget/skimtowidget.lua Resolved
@mergen3107

Copy link
Copy Markdown
Contributor

you should be able to do so now.

Thank you! I'll give it a try soon.

As for notification, I was just asking :D
I shared what I saw, that's all. It is up to you to include them or not (for consistency).

I agree that it is quite obvious if RTL Progress bar toggled or not. However, a fired notification will make sure that it was the Profile who did it (compared to, say, leftover RTL Progress bar + failed Profile for some reason). Mostly useful during testing/debugging stage

@mergen3107

Copy link
Copy Markdown
Contributor

Cool, it works! Thank you!
I set up two profiles:

  • on book opening with path containing [manga]: inverted progress bar direction
  • on book closing with path containing [manga]: normal progress bar direction
    Both actions are definitive, no more guessing/remembering the toggle status.

The only question I have is regarding compatibility.
If a user switches KOReader itself to RTL, will normal progress bar mean RTL as well?
If so, then great! If not, then normal should be named LTR and inverted should be named RTL.

@Commodore64user

Copy link
Copy Markdown
Member Author

Cool, it works! Thank you! I set up two profiles:

Both actions are definitive, no more guessing/remembering the toggle status.

awesome ☺️

The only question I have is regarding compatibility. If a user switches KOReader itself to RTL, will normal progress bar mean RTL as well? If so, then great! If not, then normal should be named LTR and inverted should be named RTL.

inverted is always the opposite and normal is the same, so in rtl, normal is rtl, in ltr normal is ltr.

@mergen3107

Copy link
Copy Markdown
Contributor

the non-full skim widget

@Commodore64user Where is the non-full skim widget setting? I wasn't able to find it...

@Commodore64user

Copy link
Copy Markdown
Member Author

the non-full skim widget

Where is the non-full skim widget setting? I wasn't able to find it...

because is not in logical place, cog > navigation > skim dialogue pos

@mergen3107

Copy link
Copy Markdown
Contributor

Thanks!

(Side note: Skim dialog positions Top and Bottom should mentioned that they are compact. I was searching for "compact" in Help - Menu Search to no avail :D )

I tested Skim widget on all three positions, and everything else so far with RTL works OK.

@mergen3107

Copy link
Copy Markdown
Contributor

By the way, why Skim widget in the center doesn't have a back button? It is a circular arrow icon in compact versions. Very convenient!

@Commodore64user

Copy link
Copy Markdown
Member Author

By the way, why Skim widget in the center doesn't have a back button? It is a circular arrow icon in compact versions. Very convenient!

a long press on the page number should do it.

@mergen3107

Copy link
Copy Markdown
Contributor

Crazy!
Crazy convenient
Crazy inobvious :D
I keep unraveling some jewels from the UX earth :D
So far I have collected:

  1. In select folder/file dialog, long press Home to create a new folder
  2. Long-long-long press a word inside dictionary lookup to summon Wiki enquiry with it (and vice versa)
  3. Top menu has three tap zones (as I discussed in the other PR)
  4. Now this Skim Widget trick with page long press to go back
  5. Any multi swipe gesture closes Bookmarks window, but not swipe down like in many other windows (because I guess it is scrollable?)

@offset-torque
How many of those above you think should be added to the User Guide?

They are all from different places I thought we should add just "Tips and Tricks" mini-section :D

P.S. Sorry for hi-jacking this ticket, I'll move to a separate one soon

@Commodore64user

Copy link
Copy Markdown
Member Author

I think it was the poet who said it first:

"In KOReader, everything is long press-able, unless it isn't".

@offset-torque

Copy link
Copy Markdown

@mergen3107

  1. Already added - coming
  2. I will add now
  3. Already added - coming
  4. Already added - coming
  5. "Multi-swipe close" action is already mentioned in the Book Map and Panel Zoom. I will add it to the Bookmarks section too.

They are all from different places I thought we should add just "Tips and Tricks" mini-section

We already have a "User Interface tips" section. I will add these distributed tips also there.
Thanks for collecting them together like this, easier to track.

@mergen3107

Copy link
Copy Markdown
Contributor

In KOReader, everything is long press-able, unless it isn't

Yoda voice:

in KOReader 
long press you must
young padawan

@mergen3107

Copy link
Copy Markdown
Contributor

Thank you @offset-torque for maintaining the KOReader User Guide (and people's sanity)

@Commodore64user

Commodore64user commented Mar 11, 2025 •

Copy link
Copy Markdown
Member Author

polite reminder to @mergen3107 that you should bring all external stuff here, not the other way around. ;)

#8282 (comment)

May be the footer global setting should be named something like "flip progress bars when 'invert page turns taps and swipes' is enabled" - but shorter :)

Adding an idea to your #13382 :

  • Currently Top Menu - Gear - Taps and Gestures - Page turns has the option Invert page turn taps and swipes. (This is the same setting I replace by a directory default)
  • it has another option, grayed out if the above is unchecked, called Also invert document-related dialogs
  • How about adding a duplicate of your Invert progress bar here as Also invert progress bar? This would look like a very logical place for it. Maybe make it appear enabled as soon as you check Invert page turn taps and swipes?

I am not entirely convinced this is a good idea, it goes back those settings being set on a book by book basis and the status bar being global. Besides that, duplicating menu entries does not seem very appropriate either.

@offset-torque

Copy link
Copy Markdown

I thank you mergen3107 for the appreciation. Lots of effort (discussion, implementation, maintenance) is spent on nice features by our devs. If I don't explain them properly, much fewer users would be able to discover and use them which would be a pity for both sides.

@mergen3107

Copy link
Copy Markdown
Contributor

you should bring all external stuff here, not the other way around

Elaborate please? (Sorry, I am on a strong painkiller today, hard to think straight, I am trying :D )

@Frenzie
Frenzie merged commit 6c25d04 into koreader:master Aug 29, 2025
@Frenzie

Frenzie commented Aug 29, 2025

Copy link
Copy Markdown
Member

Invert page turns doesn't exist. What is it meant to refer to ? Invert page-turn buttons?

@Commodore64user

Commodore64user commented Aug 29, 2025 •

Copy link
Copy Markdown
Member Author

Invert page turns doesn't exist. What is it meant to refer to ? Invert page-turn buttons?

I'm not sure I understand the question, what exactly is it that you are asking... with some context ;)

@Commodore64user
Commodore64user deleted the invert-pro-bar branch August 29, 2025 17:13
@mergen3107

Copy link
Copy Markdown
Contributor

My guess is the question is what this inversion refers to: taps, buttons, swipes?

@Commodore64user

Copy link
Copy Markdown
Member Author

I see, touch based page turns then.

@Frenzie

Frenzie commented Aug 29, 2025

Copy link
Copy Markdown
Member

It's part of "used in conjunction with" where it's capitalized as if it's a specific named feature.

@Commodore64user

Copy link
Copy Markdown
Member Author

that should read "Invert page turn taps and swipes"

@gd4c

gd4c commented Sep 23, 2025

Copy link
Copy Markdown

Quick question: what is the settings to use in directory defaults (for RTL progress bar)? Thanks

@Commodore64user

Copy link
Copy Markdown
Member Author

Invert_ui_layout?
... it is in the help text

@gd4c

gd4c commented Sep 23, 2025

Copy link
Copy Markdown

I meant only the progress bar at the bottom (and maybe the skim widget). Isn't this PR about independence from whole UI inversion?

@Commodore64user

Copy link
Copy Markdown
Member Author

And weren't you the one who asked for it to be bundled together with inverting other widgets?

@gd4c

gd4c commented Sep 23, 2025 •

Copy link
Copy Markdown

And weren't you the one who asked for it to be bundled together with inverting other widgets?

With the inverse_reading_order, not the whole UI.

i.e. approximate the experience to how we read physical RTL books. Mirror imaging everything (icons, menus, ...) scrambles my brain

@mergen3107

Copy link
Copy Markdown
Contributor

Sorry, I forgot, is the "Invert document-related dialogs" in the Dispatcher?

I am trying to add it to the auto-execute profiles for manga:

  1. when opening books with [manga] in the path, it disables statistics, inverts taps and swipes, and now I want it to do the same for inverting progress bar.

  2. When closing, do the opposite of all three.

@mergen3107

Copy link
Copy Markdown
Contributor

invert_ui_layout seems not to work with the directory defaults. Besides, it seems that this setting is book-specific?

My preference would have been to have it as a dispatcher item (toggle, on, off), but directory defaults might work too

@gd4c

gd4c commented Sep 24, 2025

Copy link
Copy Markdown

Exactly. The way it makes sense to me as a reader of RTL:

  1. If the reading order (swipes/ taps) is inverted, so should any arrows (for example next/previous match in search should point to the appropriate progress direction) and the progress bars fill from right to left.
  2. If the app language is RTL, it makes sense to invert the whole layout.

My app is in English. I just read both LTR and RTL books.

Thanks

@Commodore64user

Copy link
Copy Markdown
Member Author

Well the button works, if it doesn't work with directory defaults, that needs looking into.

The dispatcher stuff was removed when the setting was switched to a per-book basis, which makes sense.

As for being bundled with the other widgets, is not a full inversion of ui, so nobody should be getting dizzy 🥴, it had to go there in order to control all progress bars (skim widget) so...

@gd4c

gd4c commented Sep 24, 2025 •

Copy link
Copy Markdown

Thanks for your work on this. I appreciate it.

ETA: and the button works for me in directory defaults.

@mergen3107

Copy link
Copy Markdown
Contributor

ETA: and the button works for me in directory defaults.

Oh! What string did you use? Could you please share? :D

@gd4c

gd4c commented Sep 24, 2025

Copy link
Copy Markdown

["invert_ui_layout"] = true, using build g735b6e983 (2025-09-20). Tried on Android and PW5, works on both. :)

@mergen3107

Copy link
Copy Markdown
Contributor

Huh, I’ll give it another try later

Are you sure you are not confusing it with already applied setting before directory defaults? I made this mistake before :D

@gd4c

gd4c commented Sep 25, 2025

Copy link
Copy Markdown

Are you sure you are not confusing it with already applied setting before directory defaults? I made this mistake before :D

I tried it with two new epubs.

#1 matches the directory defaults path. It showed the progress bar RTL
#2 doesn't match and it showed the bar LTR

@mergen3107

mergen3107 commented Oct 21, 2025 •

Copy link
Copy Markdown
Contributor

Thanks everyone! Especially @Commodore64user
I finally got my brain together and remembered that directory defaults apply the setting listed in the lua file on newly opened books only (hence the name with "defaults"...).
["invert_ui_layout"] = true, works great in directory defaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: Option to reverse direction of progress bar on the status bar FR: Progress bar - reverse order for RTL books

9 participants