miroiu / nodify

Highly performant and modular controls for node-based editors designed for data-binding and MVVM.
https://miroiu.github.io/nodify
MIT License
1.27k stars 205 forks source link

Fix reset of viewport does not set the origin to (0, 0) #89

Open jpk6789 opened 6 months ago

jpk6789 commented 6 months ago

Describe the bug If the ResetViewportLocation gesture is performed, the viewport is not reset to (0, 0) as stated in the summary. Instead, the point (0, 0) is centered.

To Reproduce

  1. Move the viewport to any location
  2. Hit the "Home" button / call OnBringIntoView

This PR fixes this behavior by changing the PringIntoView point to a nullable and use this info to decide if the ViewportSize shall be taken into account or not.

miroiu commented 6 months ago

Hi! The NodifyEditor.BringIntoView method centers the viewport to the specified location (as written in the summary: Moves the viewport center at the specified location.), and it's working as intended. However, the editor command bound to the ResetViewportLocation gesture is wrong and the summary of the BringIntoView routed UI command is also wrong.

I would not change the behavior of NodifyEditor.BringIntoView but instead create another command for resetting the viewport location. Setting the ViewportLocation to any location moves the top-left corner of the viewport to that location.

jpk6789 commented 6 months ago

Ok, then I change my PR accordingly and create a new command for that. Yes, I saw that the top-left corner is set by the ViewportLocation :) But if I add this new function, would it be ok to also reset the zoom factor to 1 in it? I expected such a function to fully reset the location / scale in the first place.

miroiu commented 6 months ago

It's ok to reset the zooming. But in this case, I would give it a generic name like ResetViewport.