Fix scene hierarchy panel resize behavior on left border - #3453
Fix scene hierarchy panel resize behavior on left border#3453AnikethTS wants to merge 3 commits into
Conversation
SetNextWindowPos was being called every frame with ImGuiCond_Always, forcibly pinning the panel's position back to a fixed X. This fought ImGui's own native left-border drag-resize, which also adjusts position to track the mouse, causing the width to compound every frame instead of changing once per drag. Only reposition when the position actually needs to change (e.g. the cheat sheet's visibility toggles), using the existing SetupNextWindow helper. Also add ImGuiWindowFlags_NoMove: without the constant position reset, the panel could otherwise be dragged by its body and float away from its anchored spot.
test2.mp4Fix is working the panel now resizes smoothly from the left border while staying anchored, with no more runaway growth/shrink. I also found and fixed a related issue during testing: without ImGuiWindowFlags_NoMove, the panel could be dragged by its body and move away from its anchored position. It wasn’t obvious from the original bug report, but I caught it while reviewing the test recording frame by frame. |
|
\ci fast |
|
That's not ok, we should either prevent resizing from the left side, or if we allow it the scene hierarchy panel should be snap back to the left on mouse release. |
|
As per ocornut/imgui#2439 the "official" prescribed solution would to use Imgui's Docking feature. However that's a different Imgui branch, I'm not sure how far off |
|
Indeed, that's something to consider in the future but the author doesn't seem happy with the |
Meakk
left a comment
There was a problem hiding this comment.
Please fix the issue reported above.
Good catch, thanks you're right that dragging the left border lets the panel drift away from the anchor without snapping back. I'll look into fixing it properly: resetting the position back to the anchor once the resize ends, but keeping whatever width you dragged to. Will update this thread once it's sorted. |
Left-border resize kept the panel's Pos.x wherever the drag ended, leaving a gap between the panel and the true left margin that never corrected itself. Snap position back to the anchor once the mouse button is released instead of tracking a separate posX-changed flag. Also cap the resize width constraint to the visible viewport width instead of leaving it unbounded, so the right-border resize handle can't be dragged off-screen and become unreachable.
Fixed, with two changes: The panel now snaps back flush to the left margin as soon as you release the mouse, instead of staying wherever the drag left it. Video below shows both: resizing from either side, snapping back on release, and no more getting stuck when you drag it wide. test4.mp4 |
Describe your changes
SetNextWindowPoswas being called every frame withImGuiCond_Always, which kept forcing the panel back to a fixed X position. That fought against ImGui's own left-border drag-resize logic (which also repositions the window as you drag), so the two kept overriding each other and the width would compound every frame instead of just changing once per mouse move — that's what caused the runaway growth/shrink from the bug report.Fix: only call
SetNextWindowPoswhen the panel's position actually needs to change (e.g. the cheat sheet toggling visibility), and otherwise leave it alone so ImGui can manage resizing itself. Reused the existingSetupNextWindowhelper rather than adding a new pattern.I also added
ImGuiWindowFlags_NoMove— once the position wasn't being force-reset every frame, the panel could be dragged by its body and float away from its anchored spot. Ran into this while testing; it wasn't in the original bug report.I looked at the stalled #3062 first but didn't build on it, since it just works around the symptom (disables resizing near the left edge entirely) rather than fixing what's actually causing it.
Tested locally: built and ran interactively, repeatedly resized the panel from the left border. Resizing is smooth and proportional now, and the panel stays anchored instead of floating.
Issue ticket number and link if any
Closes #3016
Checklist for finalizing the PR
.github/workflows/versions.json, I have updateddocker_timestampAI Disclosure
Used Claude (Anthropic, Claude Sonnet 5, via Claude Code) to help diagnose the root cause and write the fix in
vtkext/private/module/vtkF3DImguiActor.cxx....
Continuous integration
Please write a comment to run CI, e.g.
\ci fast.See here for more info.