Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copt deduplicate: line_spacing #10768

Merged
merged 5 commits into from Sep 8, 2023
Merged

Conversation

hius07
Copy link
Member

@hius07 hius07 commented Aug 1, 2023

Main discussion in #10763.


This change is Reviewable

@hius07
Copy link
Member Author

hius07 commented Aug 1, 2023

What is the order of event handling?

ReaderUI registers ReaderConfig prior to ReaderFont.
Does it guarantee that the "ReadSettings" event is handled by ReaderConfig before ReaderFont?

@poire-z
Copy link
Contributor

poire-z commented Aug 1, 2023

ReaderUI registers ReaderConfig prior to ReaderFont.
Does it guarantee that the "ReadSettings" event is handled by ReaderConfig before ReaderFont?

I think it does - I relied on that in the past, and even had to move self:registerModule() around to ensure that ordering.

@hius07
Copy link
Member Author

hius07 commented Aug 1, 2023

Very good, so we can use already initiated configurable settings in all the modules and avoid reading doc/global once more.

This PR is a prototype. If it is okay, other settings can be deduplicated step by step, some combined, some in separate PRs to not mess up.

local marker_h = Screen:scaleBySize(self.ui.font.font_size * 1.1 * self.ui.font.line_space_percent * (1/100))
local marker_h = Screen:scaleBySize(self.ui.font.font_size * 1.1 * self.configurable.line_spacing * (1/100))
Copy link
Contributor

Choose a reason for hiding this comment

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

(So, we won't know from reading the code which module handles line spacing - but we'll know it's a "configurable" from the bottom menu. So, I guess I'm ok with that.)

Comment on lines +286 to +287
space = math.max(50, math.min(space, 200))
self.configurable.line_spacing = space
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious: is this re-update of the self.configurable property enough for the updated value (which in practice is the same as the current one already stored by ReaderConfig) to be reflected in the bottom menu ?
I mean: if your math.max/min were ensuring other limits (ie. 110-120), would they reflect in the bottom widget (progress bar updated, later launch of NumberPicker from ... showing that value)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the clamped value is applied, saved and the bottom menu progress bar and spinwidget show it.

Copy link
Contributor

@poire-z poire-z Aug 1, 2023

Choose a reason for hiding this comment

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

Directly while the bottom menu is still opened ? Or do you need to close & reopen it?

Copy link
Member Author

Choose a reason for hiding this comment

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

On "Apply" the spinwidget is not updated (shows still unclamped value), the notification shows the clamped value applied, the bottom menu at this moment is hidden, then we close the spinwidget and the reappearing bottom menu shows actual (clamped) value.

Copy link
Contributor

Choose a reason for hiding this comment

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

What when you don't use the spinwidget, but just tap on the left or right most progress bar squares?

Copy link
Member Author

Choose a reason for hiding this comment

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

Bottom menu is updated after redrawing the page (with the new clamped value), and the progress bar shows it correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. So, all that sounds rather good to me :)
Dunno if it will be as clean and simple from some of the other bottom settngs (ie; view_mode page/scroll).

Copy link
Member Author

Choose a reason for hiding this comment

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

That's why "step by step".

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes :) But good to try a second step with a more complex case, to be sure this dance will look good and end well :)

@hius07
Copy link
Member Author

hius07 commented Aug 1, 2023

Can this be merged? To continue over.
Other PR for copt_font_ settings would conflict with this one.

@poire-z
Copy link
Contributor

poire-z commented Aug 1, 2023

Have you tried (on your side) this idea with another more complex setting?
Are you confident this is THE solution that will work with all cases - and that we won't have to find another better one?
Looks fine to me though. @yparitcher : fine with you?

@hius07
Copy link
Member Author

hius07 commented Aug 1, 2023

I've made for font size, weight, hinting, kerning.
The optimisation is rather good.

@yparitcher
Copy link
Member

Looks good to me.
As discussed in the issue we just have to decide what makes more sense, if we should convert everything to configurable, or move the configurable stuff to the modules.

@poire-z
Copy link
Contributor

poire-z commented Aug 1, 2023

Well, what would make more sense would still be that each module manage fully its settings - and that the bottom menu would not manage its own state. And that a unique setting could be made available in the top or in the bottom menu without much differences.

This PR make the bottom menu the main state and setting handler. It means that if tomorrow we want to move a setting from the bottom menu to a toggle in the top menu, we'd have to rewrite a bunch of stuff (and live with a setting named copt_something that is not managed by the bottom menu - or do a onetime migration).

or move the configurable stuff to the modules

Given the horror and complexity the bottom menu stuff is, I have no idea how feasible this is :/

@NiLuJe
Copy link
Member

NiLuJe commented Aug 1, 2023

Yup, @poire-z's perfectly summarized my thoughts on the subject. ConfigDialog is a nightmare, but it's a nightmare that sorta works ;p.

@poire-z
Copy link
Contributor

poire-z commented Aug 6, 2023

Another question, as I sometimes do that (for checking changes/regressions): what will happen if I open a doc with the future version of KOReader with this PR - and then go at launching an older version of KOReader and open that same doc ?

@hius07
Copy link
Member Author

hius07 commented Aug 6, 2023

The doc will take the default (global) values of the settings that have been deduplicated.

@hius07 hius07 merged commit 73378cd into koreader:master Sep 8, 2023
3 checks passed
@hius07 hius07 deleted the copt-line_spacing branch September 8, 2023 05:40
@hius07 hius07 added this to the 2023.09 milestone Sep 8, 2023
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.

None yet

4 participants