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

page indicator for fixed layouts #1153

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Doublonmousse
Copy link
Collaborator

Partial fix for #639

Screencast_20240722_132148.webm

This does not include any page menu, only a page number indicator to show the current page number and change the page. For now this is only implemented for fixed layouts (infinite layouts would need a little more work as page positions and number depend on a little more than the current canvas size, like which pages include strokes. Having a page number might be a little more difficult as well).

There's probably a few things to improve (these are suggestions)

  • make it work for infinite layouts (?)
  • make it async ? (there's no need to halt some other calculations for the page number to be calculated, not sure it currently is the case)
  • show the total number of page (I would like to have a 1/xx inside the spinbutton but that might end up being hard to do with gtk. Having the total number of page on the right would be a little too much wasted space)

Comment on lines +511 to +517
// at the center of the viewport instead
let page_number = ((canvas.engine_ref().camera.offset().y + 0.01)
/ (canvas.engine_ref().document.format.height()
* canvas.engine_ref().camera.zoom()))
.ceil()
.max(1.0);
self.main_header().page_spin().set_value(page_number);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I should probably only trigger the set_value if the page number is actually different from the actual value

  • use block_signal/unblock_signal on the page_spin so that the function to change the page isn't called twice (thanks @Clemapfel for the idea)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Seems like doing this is harder than it seems because glib::signal::SignalHandlerId does not implement Clone, hence it's difficult to save the value and use it in another function to block/unblock things

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.

1 participant