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

Added Canvas UI #2326

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Added Canvas UI #2326

wants to merge 2 commits into from

Conversation

paulhoux
Copy link
Collaborator

@paulhoux paulhoux commented Jan 3, 2024

This is a 2D equivalent of CameraUi. It allows users to easily add pan and zoom to their 2D applications. CanvasUi is header-only.

This is a 2D equivalent of CameraUi. It allows users to easily add pan and zoom to their 2D applications. CanvasUi is header-only.
@paulhoux paulhoux requested a review from andrewfb January 3, 2024 14:39
@paulhoux paulhoux self-assigned this Jan 3, 2024
@andrewfb
Copy link
Collaborator

andrewfb commented Feb 1, 2024

Thanks for this - I think it could be a really nice addition to Cinder. Any thoughts on a mode - maybe a constructor parameter - that lets me opt-in to left / right / middle buttons serving as drag? My thought being, for many applications, I'd want the left and potentially right mouse buttons to be free for scene interaction, and the middle button for panning.

Also, thoughts on zoomIn( float percent ) and zoomOut( float percent ) function that a user could easily map to keyboard hotkeys or similar?

@paulhoux
Copy link
Collaborator Author

Those are good suggestions. Will make changes as soon as time permits.

@paulhoux
Copy link
Collaborator Author

Actually, while the suggestions are good, they are not straightforward to implement. I based this implementation upon the CameraUi, which also doesn't support custom mouse/keyboard mappings. If I am going to add that to CanvasUi, we should also add it to CameraUi and come up with a struct of some kind which handles the mapping.

Regarding zoomIn and zoomOut: scaling is done relative to the last recorded mouse position. Keeping track of this position is the most important part of CanvasUi, as it requires conversion to and from window position. Adding keyboard shortcuts to zoom in or out would not be sufficient: to use this intuitively would also require us to reposition the scale origin to the center of the window (I think). At the very least, we would have to think about the desired behavior.

Again, the CameraUi does not have support for assigning keys and mouse buttons. Can't we accept CanvasUi as-is and add those features later if needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants