Repository navigation
feat: added NoMove and NoResize flags to ImPlotDragToolFlags - #720
Conversation
Both new flags carried the comment of ImPlotDragToolFlags_NoInputs ("lock the tool from user inputs"), which describes neither of them. NoMove keeps the tool clickable and hoverable but stops dragging it (a DragRect can still be resized), and NoResize only affects DragRect.
With ImPlotDragToolFlags_NoMove a point or line still showed the hand or resize cursor on hover, suggesting it could be dragged when it can't. The cursor is now only set when the tool can move, as DragRect already does for its locked handles, which it neither registers nor draws.
DragRect only assigned out_clicked, out_hovered and out_held in the middle-handle block; the corner, edge and body checks OR into whatever the caller passed. With ImPlotDragToolFlags_NoMove that block is skipped, so a caller that keeps its bools across frames saw them stuck at true once set, and an uninitialized bool was read. The outputs are now reset to false before the handles run, which also covers the existing case of a zero-size rect.
… the plot With NoMove or NoResize the PR removed the matching DragRect handles, so a drag on the center or a corner fell through and panned the plot, while a locked DragPoint or DragLine keeps the click and stays put. The handles now keep their hit areas and report hovered, clicked and held, but don't move or resize the rect and show no drag cursor, which is the same rule as points and lines. They are drawn as before, like a locked point or line. Since the center handle always runs again, its outputs are assigned every frame and the reset added in the previous commit is no longer needed; the corner and edge loop also goes back to master's indentation.
|
Thanks @PysKa-Ratzinger, this is a really nice addition! I merged master into the branch (now that #719 is in) and pushed a few small commits on top. I noticed that a DragPoint or DragLine with NoMove still showed the hand or resize cursor on hover, so it looked draggable. Now the cursor only changes when the tool can really move.
On a DragRect, a locked handle used to disappear and stop catching the mouse. Pressing on the center dot with NoMove, or on a corner with NoResize, panned the plot instead, and the rect moved along with it. Now the locked handles stay where they are and catch the click like a locked DragPoint or DragLine: nothing moves, nothing pans, and the rect still reports clicked and held. The handles are drawn as before; only the cursor tells they are locked. This also means before-after.mp4 |
|
Collaboration is a great thing. I wish I took more care on my PR regarding those copy-paste comments, but it's great to see you fixed it up and even improved upon it. Cheers! |
I totally agree, sorry about that! I was rushing today to finish the release (ImPlot was breaking in v1.0). I'll make sure to not do that again 😬 |
|
No need to apologize. I was trying to thank you for fixing it. :) But I will try to be more mindful to not make these rookie mistakes in the future. I needed these flags for something I was doing and rushed the PR as well. :P |
|
Oooh now I see, I misread your comment kkkkk no worries about the mistakes, that's what review is about :) Thanks for the contribution! |

This PR also contains both commits from #719, so that should either be merged first, or closed after merging this one.