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

Add Panning and Zooming #110

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Add Panning and Zooming #110

wants to merge 5 commits into from

Conversation

mattrobineau
Copy link

Description

This PR introduces changes to allow a user to pan and zoom the canvas in Satty and closes #93.

Changes made:

  • Adds zooming functionality
    • Adds two toolbar buttons for zoom in and zoom out
    • Adds scrollwheel up/down zooming
  • Adds panning functionality
    • Holding and dragging middle mouse button will pan the image

Notes

  • The scroll event gtk::EventControllerScroll needed to be added to the main window otherwise the event would only fire when scrolling on the toolbar.
  • handle_zoom zooms by an arbitrary value (+-0.1) chosen solely because I thought it was a good value. It might be worth considering allowing a user to modify this value in config.
  • Zooming does not currently support zooming based on the cursors location, it will always zoom from (0,0).

@gabm
Copy link
Owner

gabm commented Aug 6, 2024

I just tried your PR and the functionality works as advertised, great 👍

For the current feature-set I'd like to suggest the following changes

zoom

  • I think the center of zooming should be:
    • a) the center of the screen, if invoked by the toolbar buttons
    • b) the position of the mouse pointer, if invoked by the scroll wheel
  • to change the center of the zooming operation, you need to translate the chosen center to the left-top corner, then zoom and then translate back

pan

  • the pan speed should be equal to the mouse speed
  • on my screen it seems that the canvas moves "slower" than the mouse moves
  • that might have something to do with the scale factor (?)

Usability and UI

  • we need to discuss whether we want toolbar buttons, an extra toolbar or none
  • we may want to respond to the arrow buttons for panning
  • we may want to respond to the zooming gesture for zooming
  • I think we want a shortcut to reset all zoom and translation
  • we need to think how the background looks like - black or white (or any other color)
  • we do want to export/save the "smallest possible canvas", that still covers the image and all drawings. That allows users to draw outside the image
  • I didn't look at the code yet 🙈

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.

[feature] Allow for pan and zoom with the mouse/trackpad to move the (infinite) canvas around
2 participants