implot icon indicating copy to clipboard operation
implot copied to clipboard

`Constrains` should scroll rather than zoom if possible.

Open Nahor opened this issue 2 years ago • 3 comments

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).

https://github.com/epezent/implot/assets/1198364/4ff1a491-02ce-49f2-9eaa-3a14ab57f4dd

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 avatar Nov 23 '23 22:11 Nahor

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

Nahor avatar Nov 24 '23 20:11 Nahor

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.

https://github.com/epezent/implot/assets/1198364/890dae2f-3aa2-4003-aefb-4337c3e8754f

Nahor avatar Nov 24 '23 21:11 Nahor

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")

https://github.com/epezent/implot/assets/1198364/20da40b1-62c4-47c4-9cef-bee2af10c8b3

Nahor avatar Nov 24 '23 21:11 Nahor