Skip to content

feat: added NoMove and NoResize flags to ImPlotDragToolFlags - #720

Merged
brenocq merged 6 commits into
epezent:masterfrom
PysKa-Ratzinger:feat/new_drag_flags
Oct 25, 2026
Merged

brenocq merged 6 commits into
epezent:masterfrom
PysKa-Ratzinger:feat/new_drag_flags

Conversation

@PysKa-Ratzinger

Copy link
Copy Markdown
Contributor

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

@brenocq
brenocq self-requested a review October 25, 2026 10:21
@brenocq brenocq added type:feat New feature or request prio:medium Medium priority status:review The task is under review labels Oct 25, 2026
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.
@brenocq

brenocq commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

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.

image

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 out_clicked, out_hovered and out_held are set every frame again, so they no longer stay true with NoMove when the caller keeps them across frames.

before-after.mp4

@brenocq
brenocq merged commit 83e9866 into epezent:master Oct 25, 2026
19 checks passed
@brenocq brenocq added status:done Task completed successfully and removed status:review The task is under review labels Oct 25, 2026
@PysKa-Ratzinger

Copy link
Copy Markdown
Contributor Author

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!

@brenocq

brenocq commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

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 😬

@PysKa-Ratzinger

Copy link
Copy Markdown
Contributor Author

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

@brenocq

brenocq commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

Oooh now I see, I misread your comment kkkkk no worries about the mistakes, that's what review is about :)

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prio:medium Medium priority status:done Task completed successfully type:feat New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants