From 344f2c96068149ae588c33db76ba0d6e6f103703 Mon Sep 17 00:00:00 2001 From: Gaspar Capello Date: Fri, 3 May 2024 17:31:03 -0300 Subject: [PATCH] Fix "clang-tidy" suggestions about variables that can be declared 'constants' --- src/app/ui/editor/pixels_movement.cpp | 34 +++++++++++++-------------- src/doc/util.cpp | 6 ++--- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/app/ui/editor/pixels_movement.cpp b/src/app/ui/editor/pixels_movement.cpp index 82d666173..3554a005f 100644 --- a/src/app/ui/editor/pixels_movement.cpp +++ b/src/app/ui/editor/pixels_movement.cpp @@ -822,13 +822,13 @@ void PixelsMovement::alignMasksAndTransformData( // Raw grid alignment of currentData can result in unintentional scaling. // That's why we need to know if the artist's intention was just to move // the selection and/or scaling via 'initialDeltaA' and 'initialDeltaB'. - gfx::Point currentDataAlignedOrigin = + const gfx::Point currentDataAlignedOrigin = grid.alignBounds(gfx::Rect(m_initialData.bounds().x + deltaA.w, m_initialData.bounds().y + deltaA.h, 1, 1)).origin(); int deltaH = deltaB.w - deltaA.w; int deltaV = deltaB.h - deltaA.h; - gfx::RectF currentDataBounds( + const gfx::RectF currentDataBounds( currentDataAlignedOrigin.x, currentDataAlignedOrigin.y, m_initialData.bounds().w + (deltaH == 0 ? 0 : deltaH), @@ -873,13 +873,13 @@ void PixelsMovement::stampImage(bool finalStamp) // 'reproduceAllTransformationsWithInnerCmds' function for restoring later. // All values of m_initialXX, m_currentXX will be recalculated // to align their original selection bounds with each cel's grid. - TilemapMode originalSiteTilemapMode = ( + const TilemapMode originalSiteTilemapMode = ( m_site.tilemapMode() == TilemapMode::Tiles && m_site.layer()->isTilemap()? TilemapMode::Tiles : TilemapMode::Pixels); - TilesetMode originalSiteTilesetMode = m_site.tilesetMode(); - Mask initialMask0(*m_initialMask0); - Mask initialMask(*m_initialMask); - Mask currentMask(*m_currentMask); + const TilesetMode originalSiteTilesetMode = m_site.tilesetMode(); + const Mask initialMask0(*m_initialMask0); + const Mask initialMask(*m_initialMask); + const Mask currentMask(*m_currentMask); auto initialData = m_initialData; auto currentData = m_currentData; @@ -892,18 +892,18 @@ void PixelsMovement::stampImage(bool finalStamp) // | | // | | // ---- b - gfx::Rect currentAlignedBounds( + const gfx::Rect currentAlignedBounds( m_site.grid().alignBounds(currentData.bounds())); - gfx::Rect initialAlignedBounds( + const gfx::Rect initialAlignedBounds( m_site.grid().alignBounds(initialMask.bounds())); - gfx::Size deltaA(currentAlignedBounds.origin().x - - initialAlignedBounds.origin().x, - currentAlignedBounds.origin().y - - initialAlignedBounds.origin().y); - gfx::Size deltaB(currentAlignedBounds.x2() - - initialAlignedBounds.x2(), - currentAlignedBounds.y2() - - initialAlignedBounds.y2()); + const gfx::Size deltaA(currentAlignedBounds.origin().x - + initialAlignedBounds.origin().x, + currentAlignedBounds.origin().y - + initialAlignedBounds.origin().y); + const gfx::Size deltaB(currentAlignedBounds.x2() - + initialAlignedBounds.x2(), + currentAlignedBounds.y2() - + initialAlignedBounds.y2()); for (Cel* target : cels) { // We'll re-create the transformation for the other cels diff --git a/src/doc/util.cpp b/src/doc/util.cpp index c6bab2058..6c262ac93 100644 --- a/src/doc/util.cpp +++ b/src/doc/util.cpp @@ -62,8 +62,8 @@ Mask make_aligned_mask( ASSERT(false); return maskOutput; } - gfx::Rect oldBounds = mask->bounds(); - gfx::Rect newBounds = grid->alignBounds(mask->bounds()); + const gfx::Rect oldBounds = mask->bounds(); + const gfx::Rect newBounds = grid->alignBounds(mask->bounds()); ASSERT(newBounds.w > 0 && newBounds.h > 0); ImageRef newBitmap; if (!mask->bitmap()) { @@ -84,7 +84,7 @@ Mask make_aligned_mask( for (int x=0; x < oldBounds.w; ++x, ++it) { ASSERT(it != bits.end()); if (*it) { - gfx::Rect newBoundsTile = + const gfx::Rect newBoundsTile = grid->alignBounds(gfx::Rect(oldBounds.x + x, oldBounds.y + y, 1, 1)); if (previousPoint != newBoundsTile.origin()) { // Fill a tile region in the newBitmap