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

Constrains should scroll rather than zoom if possible. #537

Open
Nahor opened this issue Nov 23, 2023 · 3 comments
Open

Constrains should scroll rather than zoom if possible. #537

Nahor opened this issue Nov 23, 2023 · 3 comments

Comments

@Nahor
Copy link

Nahor commented Nov 23, 2023

When scrolling an axis, if the new axis range gets outside the constraints, Implot will fix the limit that is outside and leave the other unchanged (if applicable). It will then compute what the zoom level must be. A user is probably not expecting the zoom to be changed.

For instance, the "Axis constraints" example:

  • zoom out the X-axis to be slightly narrower than the constraints (say [-10..+8]).
  • quickly scroll the axis back-and-forth between the two extreme multiple times.
  • scroll left up to -10.
    => Take note of the right limit: it is no longer +8 but much less (in my video, it's now -2.5 or so).
Constraint.mp4

Expected:
When correcting one side of an axis, the other side should be changed by the same amount, and if both sides cannot fit within the constraints (i.e. the user must be zooming out, or the constraints changed), then and only then should the zoom factor be changed.

@Nahor
Copy link
Author

Nahor commented Nov 24, 2023

Someone already pushed a PR for this (PR #386), however I do not think this will fix it (or at least not anymore)

@Nahor
Copy link
Author

Nahor commented Nov 24, 2023

There is a similar issue with zooming out. When one side of the axis is against the limit constraint, and the mouse is near the other side, zooming-out is extremely slow. Because of the left/mouse vs right/mouse ratio, most of the change is on the opposite side of the mouse, which is against the limit constraint and thus gets "undone", while the side of the mouse gets little change.

See the video, where zooming out is "quick" at first, until the limit constraint is reached, after which is very slow.

Zoom.mp4

@Nahor
Copy link
Author

Nahor commented Nov 24, 2023

Third weird behavior:

  • when box-selecting a range smaller than the zoom constraint, the low side of the box will remain intact, while the high side will be moved to fit the constraint.

In the video below, I select the range [-0.5, 0], which is too small. The result is [-0.5, 0.5], while one would more expect [-0.75, 0.25] (i.e. grow the box, but keep it centered on the selection instead of "left aligned")

Selection.mp4

Nahor added a commit to Nahor/implot that referenced this issue Nov 24, 2023
…#537)

- Make scrolling not affect the zoom level when near the axis limit
  constraint
- Keep the zoom-out speed constant when one side of the axis is against
  the limit constraint while the mouse is on the other side
- When doing box-selection with a size smaller that the minimum zoom, keep the
  final box centered on the selection instead of "left aligning" it.
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

No branches or pull requests

1 participant