Skip to content

[patch] Keep comment boxes with their nodes when the view pans or fits - #607

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/478-comment-boxes-follow-pan-and-fit
Oct 9, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/478-comment-boxes-follow-pan-and-fit

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #478

What was wrong

Comment boxes are drawn at canvasOrigin + ToView(box.Position), with no panning term. Two view operations moved nodes and left the boxes behind:

  • Pan. A pan shifts every node's ImNodes editor-space position. GetNodePositionUpdates reports that back as every node moving.
  • FitToView. It computed its bounds over nodes only, and offset only the nodes.

As a result, nodes slid out of their boxes on screen, and GetNodesInCommentBox stopped finding them. Moving or deleting a box then silently missed its contents.

Change

  • NodeEditorEngine.OffsetCommentBoxes(delta) (internal): shifts every box without carrying anything. Here the nodes move on their own, so MoveCommentBox would move them twice.
  • NodeEditorRenderer.GetNodePositionUpdates: reads ImNodes.EditorContextGetPanning() and shifts the boxes by the change since its last call, divided by Zoom. The view transform is linear with slope Zoom, so this matches exactly how far the nodes are reported to move.
  • FitToView:
    • includes box extents in the bounds;
    • applies the same offset to the boxes;
    • fits a graph that has only boxes instead of returning false.
  • CLAUDE.md: the comment-box section now records both behaviours.

Tests

New CommentBoxViewTests run real frames in the headless harness, with a node at (200, 200) and CreateCommentBoxAround:

  • Panning_CarriesCommentBoxesWithTheirNodes: middle-drag across empty canvas. The node moves, its offset within the box is unchanged, and GetNodesInCommentBox still holds it.
  • FitToView_CarriesCommentBoxesWithTheirNodes: the same assertions after FitToView.
  • FitToView_CentresTheBoxesAsWellAsTheNodes: the enclosing box ends up centred on the view.

How the tests were checked:

  • With the renderer change reverted: all 3 new tests fail.
  • ImGui.NodeEditor.Tests: 273/273 pass.
  • ImGuiAppDemo.UITests CleanImNodes_* (including FitToViewFitsTheGraph): 7/7 pass. These need the LFS assets pulled.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TTeaDNAaTEviJbNWuEi5hP


Generated by Claude Code

A pan shifts every node's editor-space position, which the renderer reports
back as every node moving, and FitToView moved only the nodes. Comment boxes
are drawn from the engine's space with no panning term, so both left the
boxes behind: nodes slid out of their boxes on screen and
GetNodesInCommentBox stopped finding them.

GetNodePositionUpdates now shifts every box by the panning delta since its
last call, and FitToView includes the boxes in its bounds and offsets them
with the nodes.

Fixes #478

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TTeaDNAaTEviJbNWuEi5hP
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

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.

NodeEditor comment boxes don't follow panning or FitToView: nodes slide out of their boxes and GetNodesInCommentBox drops them

2 participants