fix: add margin around modules when zooming (#61) - #62
Merged
Merged
Conversation
navigate_to_anchor() framed the module (anchor + upstream nodes) with nuke.zoomToFitSelected(), which fits the selection edge-to-edge with no padding, so navigating to a module read as too tight. Nuke's zoomToFitSelected() has no margin parameter, so apply the margin as a post-fit zoom-out: after fitting, read the resulting scale/center and re-zoom by MODULE_ZOOM_MARGIN_FACTOR (0.85). This leaves ~7.5% of the viewport as margin per side (~100-200px on a typical DAG panel) and adapts to any panel size, matching the breathing room backdrops have.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes overly tight framing when navigating to a module (anchor + upstream nodes) by adding post-fit “breathing room” around the selection, matching the nicer framing users see with backdrops.
Changes:
- Add a new
MODULE_ZOOM_MARGIN_FACTORconstant to apply proportional zoom-out margin afternuke.zoomToFitSelected(). - Update
navigate_to_anchor()to re-zoom after fitting using the fitted zoom + center as a baseline. - Extend navigation tests to verify the margin zoom-out behavior and ensure zoom/fit mocks don’t leak
side_effects across tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
anchor.py |
Applies a post-zoomToFitSelected() zoom-out using fitted zoom/center to create module margin. |
constants.py |
Introduces MODULE_ZOOM_MARGIN_FACTOR = 0.85 with rationale and framing notes. |
tests/test_anchor_navigation.py |
Adds tests for margin zoom-out behavior and hardens mock reset/cleanup to prevent leakage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #61.
Problem
Navigating to a module (an anchor plus its upstream nodes) framed the nodes edge-to-edge with no breathing room. Backdrops, by contrast, look well-framed because the backdrop node is physically larger than its contents, leaving natural margin.
Root cause
navigate_to_anchor()selects the module nodes and callsnuke.zoomToFitSelected(), which fits the selection's bounding box to fill the viewport with no padding. Nuke's API exposes no margin/padding parameter for that call.Fix
Apply the margin as a post-fit zoom-out. After
zoomToFitSelected(), read the resulting scale and center and re-zoom by a factor:MODULE_ZOOM_MARGIN_FACTOR = 0.85(new constant inconstants.py) leaves ~7.5% of the viewport as margin on each side — roughly 100–200px on a typical DAG panel, matching the issue request — and adapts to any panel size rather than hard-coding a pixel count.Alternatives considered
QWidgetreliably across Nuke versions/docked panels and is much harder to unit-test. The proportional factor lands in the requested range with far less fragility.Tests
test_zooms_out_for_margin_after_fit— verifies a single re-zoom atfitted_scale * MODULE_ZOOM_MARGIN_FACTORwith the fitted center.test_margin_zoom_out_happens_after_fit— verifies ordering (fit first, margin zoom-out last).setUp/tearDownhardened to reset shared zoom mocks so the newside_effects don't leak across test classes.Full suite: 484 passed.
UAT
Pending — to be performed in Nuke by the maintainer (navigate to a module via Alt+A / leader key; confirm visible margin; confirm back-navigation and link-cycling still work).