Skip to content

DynamicView zoom-fit behavior breaks when main window is maximized #10

@Gooichand

Description

@Gooichand

Issue Summary

Zoom-fit scale not updated correctly on window resize / maximize

Description

In DynamicView.resizeEvent, there is a FIXME comment noting: "Se la finestra viene massimizzata, il valore di fit_scale non si aggiorna" (when the window is maximized, fit_scale is not updated).
The current logic calls zoom_fit() only when the existing transform scale is less than or equal to fit_scale; otherwise, it just emits notify_change().
This means that after maximizing or significantly resizing the window, the fit-to-window scaling can become out-of-sync, causing suboptimal zoom behavior.

Steps to Reproduce

  1. Open any tool that uses ImageViewer / DynamicView (e.g., Original Image).
  2. Load an image and double-click to fit it.
  3. Maximize or resize the main window to a much larger size.
  4. Observe that the fitted image may no longer optimally fill the viewport due to stale fit_scale.

Expected Result

When the window is maximized or resized, the fit-scale should be recomputed so that "Fit" always behaves consistently with the new window dimensions.

Actual Result

fit_scale can remain based on the previous size, leading to incorrect zoom levels after maximizing; the code itself flags this as a known issue via the FIXME comment.

Affected Files

  • gui/viewer.py

Suggested Fix

Recompute fit_scale on resize (e.g., always call zoom_fit() when in fit mode), or track a "fit mode" state and recalculate scale whenever the viewport changes significantly. Remove the FIXME once behavior is corrected.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions