Centered zoom in Display view

This commit is contained in:
Bruno Herbelin
2025-01-05 12:52:45 +01:00
parent e06bb0f9f3
commit 26d35504c8

View File

@@ -376,6 +376,12 @@ void DisplaysView::resize ( int scale )
z *= z; // square
z *= DISPLAYS_MAX_SCALE - DISPLAYS_MIN_SCALE;
z += DISPLAYS_MIN_SCALE;
// centered zoom : if zooming, adjust translation to ratio of scaling
if (scale != size())
scene.root()->translation_ *= z / scene.root()->scale_.x;
// apply scaling
scene.root()->scale_.x = z;
scene.root()->scale_.y = z;
}