diff --git a/Source/UI/Items/MergeItemWnd.cpp b/Source/UI/Items/MergeItemWnd.cpp index 4cd261fb..8a76b5a9 100644 --- a/Source/UI/Items/MergeItemWnd.cpp +++ b/Source/UI/Items/MergeItemWnd.cpp @@ -284,19 +284,19 @@ void CMergeItemWnd::FitToGrid(int width, int height) { return; } - const int cell = this->m_cellSize; - const int left = this->m_gridLeft; - const int minHeight = this->m_gridTop + cell * 3; - const int maxHeight = this->m_gridTop + cell * 6; + const int minWidth = this->m_cellSize * 5; + const int maxWidth = this->m_cellSize * 10; + const int minHeight = this->m_gridTop + this->m_cellSize * 3; + const int maxHeight = this->m_gridTop + this->m_cellSize * 6; - int columns = width - this->m_marginRight - left; + int columns = width - this->m_marginRight - this->m_gridLeft; columns -= columns % this->m_cellSize; - int clamped = cell * 5; - if (cell * 5 + left <= columns + left) { + int clamped = minWidth; + if (this->m_gridLeft + minWidth <= this->m_gridLeft + columns) { clamped = columns; } - int gridWidth = cell * 10; - if (clamped + left <= cell * 10 + left) { + int gridWidth = maxWidth; + if (this->m_gridLeft + clamped <= this->m_gridLeft + maxWidth) { gridWidth = clamped; } @@ -309,8 +309,8 @@ void CMergeItemWnd::FitToGrid(int width, int height) { gridHeight = maxHeight; } - if (gridWidth + left != this->geometry.width || gridHeight != this->geometry.height) { - this->Resize(this->m_marginRight + gridWidth + left, this->m_marginBottom + gridHeight); + if (gridWidth + this->m_gridLeft != this->geometry.width || gridHeight != this->geometry.height) { + this->Resize(this->m_marginRight + gridWidth + this->m_gridLeft, this->m_marginBottom + gridHeight); const int visibleColumns = (this->geometry.width - this->m_marginRight - this->m_gridLeft) / this->m_cellSize; const int visibleRows = (this->geometry.height - this->m_marginBottom - this->m_gridTop) / this->m_cellSize; this->m_columns = visibleColumns;