Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Implement zooming #85

Closed
wants to merge 14 commits into from
Closed

Implement zooming #85

wants to merge 14 commits into from

Conversation

janopae
Copy link

@janopae janopae commented Nov 5, 2023

When ready, this fixes #20.

TODO

  • rename graphicsContext => drawingContext (or dc)
  • make mouse input work
  • text not aligned (horizontal spacing a bit off) when zoomed?
  • mouse wheel scrolling

By putting the Control into a ScrolledWindow, we get scroll bars whenever the Control's container is smaller than its minimum size.

Vertical scrolling of the ScrolledWindow currently is deactivated, as we still have our custom implementation for vertical scrolling.

This, however, raises some issues: At first, the vertical scroll bar gets scrolled away along with the Screenplay Control while scrolling horizontally, as it is part of the contents of the ScrolledWindow.

Also, the hand-made scrollbar lacks some features, such as auto-hiding or the "precise scrolling mode" on Gtk.

Eventually, the custom scrolling implementation is probably going to get in our way when implementing  limburgher#20 anyway, so we should try to port vertical scrolling to the ScrolledWindow scrolling mechanism.
Before this commit, horizontal scrolling also moves the vertical scroll bar.
I specifically implemented fd5c593 to make this comment not necessary
Using a GraphicsContext, drawings can be scaled using wxWidgets.

But attention: Logic that changes the layout based on certain pixel constants might still use the old constants.

Click events on the canvas don't respect the scale factor yet.

And there is still a bug that text is not aligned correctly.
Before this commit, the horizontal scrollbar wouldn't appear when the page was too wide because it was zoomed.
When calculating layout, we don't take zoom into account – instead, the zoom later gets added to the values that our layout code calculates.

When taking the available size into account, our layout code used the `GetClientSize` method of `MyCtrl`, which offered the real size of the rendered widget, which corresponds to the sizes *after* the zoom has been taken into account.

This caused things like the page not being centered when zoomed or the side-by-side layout mode refusing to show more pages when zooming out.

This commit introduces the `GetLogicalClientSize` method, which translates the actual client size to one that can be used when calculating the layout.
It's actually a DrawingContext drawing to a GraphicsContext
@limburgher
Copy link
Owner

Please close this PR and reopen again https://github.com/trelby/trelby, as the project is merging into that project. Thank you!

@limburgher limburgher closed this Dec 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

View options
2 participants