document widget: custom page drawing #849
Open
+666
−551
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New document widget which draws pages directly rather than using GtkGrid.
Resolves #826, resolves #580, resolves #657, resolves #785, resolves #795, resolves #736, and resolves #797. First step towards implementing per page zooming required for #289, #447, and #724. Implementing #103 is fairly simple with this new widget, but I'll add that separately since this PR is already long.
Implementation
Drawing is broken up into 3 steps.
zathura_document_widget_refresh_layoutand is called when the document or page layout is changed.zathura_document_widget_compute_layout. The positions depend on the zoom of the document/pages, so is called whenever the zoom changes. Also required to be called for the get values to be updated (e.g. document widget size).Issues
There is a minor issue with navigation for documents with non-uniform page sizes. In best-fit mode, when moving between pages with different sizes, the zoom level may change due to the different page sizes and the position doesn't end up at the start of a page.
This is something that'll need addressing for the best fit per page features. The current approach of storing position as a value from [0, 1] normalised by document size means the position is independent of scale But if we introduce per page scaling, the [0, 1] position now depends on the scale of the pages. E.g. if the scale of the first page changes, the [0, 1] position of the start of the second page changes. Maybe storing the position relative to the current page is the way to handle this? Since that change would touch a wide area for a small issue, I'll leave it for now.