Skip to content

fix: fit backdrops on navigation instead of forcing 100% zoom - #64

Merged
charlesangus merged 1 commit into
mainfrom
fix/backdrop-nav-zoom-to-fit
Jun 15, 2026
Merged

charlesangus merged 1 commit into
mainfrom
fix/backdrop-nav-zoom-to-fit

Conversation

@charlesangus

Copy link
Copy Markdown
Owner

Problem

Navigating to a backdrop with Alt+A zoomed in too far on large backdrops, while small ones looked fine — an inconsistent "sometimes" framing. Selecting the same backdrop and running zoomToFitSelected() in the Script Editor framed it correctly.

This is a pre-existing bug, independent of the #61 / #62 / #63 module-margin work.

Root cause

navigate_to_backdrop() called nuke.zoom(1.0, [center_x, center_y]). The first argument is an absolute zoom scale (100% — one node-grid unit per screen pixel), not a fit. So it always jumped to 100% regardless of backdrop size:

  • Large backdrop → 100% is far more zoomed-in than fit → too far in.
  • Small backdrop (~viewport-sized at 100%) → happens to look right.

The center math was correct; only the hardcoded scale was wrong.

Fix

Select the backdrop and call nuke.zoomToFitSelected(), so the scale adapts to the backdrop's size — the same thing that works from the Script Editor.

nukescripts.clear_selection_recursive()
backdrop_node['selected'].setValue(True)
nuke.zoomToFitSelected()
nukescripts.clear_selection_recursive()

The old docstring justified avoiding zoomToFitSelected() to target a Group's internal DAG panel rather than the root DAG. That reasoning is obsolete: navigation is dispatched after the picker closes via QtCore.QTimer.singleShot (_anchor_navigate_invoke), so the focused panel is already active — the exact path navigate_to_anchor() already uses with zoomToFitSelected().

Tests

  • Updated test_navigate_to_backdrop_selects_and_zooms to assert zoomToFitSelected() is called.
  • Added test_navigate_to_backdrop_does_not_force_fixed_zoom — asserts no absolute zoom scale is set.

Full suite: 486 passed.

UAT

Pending — to be performed in Nuke by the maintainer:

  • Navigate to a large backdrop with Alt+A → confirm it now fits (no longer zoomed in too far).
  • Navigate to a small backdrop → still framed sensibly.
  • Confirm backdrops inside a Group's node graph also fit correctly (the panel-targeting case the old docstring worried about).

navigate_to_backdrop() called nuke.zoom(1.0, center), which jumps to an
absolute 100% zoom scale regardless of backdrop size. Large backdrops
were therefore zoomed in too far, while small ones happened to look fine
— the inconsistent "sometimes" framing reported during UAT.

Select the backdrop and use nuke.zoomToFitSelected() instead, so the
zoom scale adapts to the backdrop's size (matching what selecting the
backdrop and running zoomToFitSelected() in the Script Editor does). The
old docstring's reason for avoiding zoomToFitSelected (root-DAG vs group
panel targeting) is obsolete: navigation is dispatched after the picker
closes via QTimer.singleShot, so the focused panel is already active —
the same path navigate_to_anchor relies on.

Tests: navigate_to_backdrop test now asserts zoomToFitSelected() is
called; added a regression test asserting no absolute zoom scale is set.
Copilot AI review requested due to automatic review settings June 15, 2026 21:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@charlesangus
charlesangus merged commit 71bfe5d into main Jun 15, 2026
2 checks passed
@charlesangus
charlesangus deleted the fix/backdrop-nav-zoom-to-fit branch June 15, 2026 22:03
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.

2 participants