Skip to content

Fix scene hierarchy panel resize behavior on left border - #3453

Open
AnikethTS wants to merge 3 commits into
f3d-app:masterfrom
AnikethTS:scene-hierarchy-resize-fix
Open

Fix scene hierarchy panel resize behavior on left border#3453
AnikethTS wants to merge 3 commits into
f3d-app:masterfrom
AnikethTS:scene-hierarchy-resize-fix

Conversation

@AnikethTS

@AnikethTS AnikethTS commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Describe your changes

SetNextWindowPos was being called every frame with ImGuiCond_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 SetNextWindowPos when 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 existing SetupNextWindow helper 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

  • I have performed a self-review of my code
  • I have added tests for new features and bugfixes
  • I have added documentation for new features
  • If it is a modifying the libf3d API, I have updated bindings
  • If it is a modifying the .github/workflows/versions.json, I have updated docker_timestamp

AI Disclosure

  • I have not used AI to generate any of the content of this pull request
  • I have used AI to generate code in this pull request:
    • I have carefully read and understood the AI policy.
    • I have carefully reviewed and completely understood every generated line.
    • I disclose below which parts of the code were generated and with which AI model:

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.

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.
@AnikethTS

Copy link
Copy Markdown
Contributor Author
test2.mp4

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

@AnikethTS
AnikethTS marked this pull request as ready for review August 24, 2026 18:11
@AnikethTS
AnikethTS requested a review from a team as a code owner August 24, 2026 18:11
@AnikethTS

Copy link
Copy Markdown
Contributor Author

\ci fast

@Meakk

Meakk commented Aug 25, 2026

Copy link
Copy Markdown
Member

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.
https://github.com/user-attachments/assets/68ca612b-6f85-47df-93c4-3c1184a0ce60

@snoyer

snoyer commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

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 master it is, or if this docking system would allow F3D's cheat sheet and scene tree side by side, would need investigation.

@Meakk

Meakk commented Aug 25, 2026

Copy link
Copy Markdown
Member

Indeed, that's something to consider in the future but the author doesn't seem happy with the docking branch.

@Meakk Meakk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the issue reported above.

@AnikethTS

Copy link
Copy Markdown
Contributor Author

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.
@AnikethTS

Copy link
Copy Markdown
Contributor Author

Please fix the issue reported above.

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.
Also capped the max resize width to the viewport width — while testing the snap fix I noticed you could drag the handle off-screen and lose access to it, so that's covered too.

Video below shows both: resizing from either side, snapping back on release, and no more getting stuck when you drag it wide.

test4.mp4

@AnikethTS
AnikethTS requested a review from Meakk August 25, 2026 17:08
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

Successfully merging this pull request may close these issues.

Scene hierarchy widget size control on the left side behave strangely

3 participants