From dca06a53c055661e33eefd99f3cba59c5c6d22f6 Mon Sep 17 00:00:00 2001 From: Liebranca Date: Mon, 9 Sep 2024 05:38:00 -0300 Subject: [PATCH] Cap scaling to grid size --- src/app/ui/editor/moving_cel_state.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/ui/editor/moving_cel_state.cpp b/src/app/ui/editor/moving_cel_state.cpp index 8a0d8813f..c8b17eee1 100644 --- a/src/app/ui/editor/moving_cel_state.cpp +++ b/src/app/ui/editor/moving_cel_state.cpp @@ -417,20 +417,21 @@ gfx::RectF MovingCelState::calcFullBounds() const void MovingCelState::snapBoundsToGrid(gfx::RectF& celBounds) const { + const gfx::RectF& gridBounds = m_editor->getSite().gridBounds(); if (m_scaled) { gfx::PointF gridOffset( snap_to_grid( - m_editor->getSite().gridBounds(), + gridBounds, gfx::Point(celBounds.w, celBounds.h), PreferSnapTo::ClosestGridVertex)); - celBounds.w = gridOffset.x; - celBounds.h = gridOffset.y; + celBounds.w = std::max(gridBounds.w, gridOffset.x); + celBounds.h = std::max(gridBounds.h, gridOffset.y); } else if (m_moved) { gfx::PointF gridOffset( snap_to_grid( - m_editor->getSite().gridBounds(), + gridBounds, gfx::Point(celBounds.origin()), PreferSnapTo::ClosestGridVertex));