[MSPAINT] Add selectionModel.moveSelection and use it

Refactoring. CORE-19094
This commit is contained in:
Katayama Hirofumi MZ 2023-11-23 14:44:27 +09:00
parent 58c26d3fe6
commit f935132fbe
5 changed files with 15 additions and 15 deletions

View file

@ -770,16 +770,6 @@ VOID CCanvasWindow::EndSelectionDrag(POINT ptImage)
Invalidate(FALSE);
}
VOID CCanvasWindow::MoveSelection(INT xDelta, INT yDelta)
{
if (!selectionModel.m_bShow)
return;
selectionModel.TakeOff();
::OffsetRect(&selectionModel.m_rc, xDelta, yDelta);
Invalidate(FALSE);
}
LRESULT CCanvasWindow::OnCtlColorEdit(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
SetTextColor((HDC)wParam, paletteModel.GetFgColor());

View file

@ -52,7 +52,6 @@ public:
VOID CanvasToImage(POINT& pt);
VOID CanvasToImage(RECT& rc);
VOID GetImageRect(RECT& rc);
VOID MoveSelection(INT xDelta, INT yDelta);
VOID getNewZoomRect(CRect& rcView, INT newZoom, CPoint ptTarget);
VOID zoomTo(INT newZoom, LONG left = 0, LONG top = 0);

View file

@ -551,6 +551,16 @@ void SelectionModel::drawFrameOnCanvas(HDC hCanvasDC)
drawSizeBoxes(hCanvasDC, &rcSelection, TRUE);
}
void SelectionModel::moveSelection(INT xDelta, INT yDelta)
{
if (!m_bShow)
return;
TakeOff();
::OffsetRect(&m_rc, xDelta, yDelta);
canvasWindow.Invalidate();
}
void SelectionModel::StretchSelection(BOOL bShrink)
{
if (!m_bShow)

View file

@ -41,6 +41,7 @@ public:
void DeleteSelection();
HITTEST hitTest(POINT ptCanvas);
void drawFrameOnCanvas(HDC hCanvasDC);
void moveSelection(INT xDelta, INT yDelta);
HBITMAP GetSelectionContents();
void DrawFramePoly(HDC hDCImage);

View file

@ -529,16 +529,16 @@ LRESULT CMainWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
break;
case VK_LEFT:
canvasWindow.MoveSelection(-1, 0);
selectionModel.moveSelection(-1, 0);
break;
case VK_RIGHT:
canvasWindow.MoveSelection(+1, 0);
selectionModel.moveSelection(+1, 0);
break;
case VK_UP:
canvasWindow.MoveSelection(0, -1);
selectionModel.moveSelection(0, -1);
break;
case VK_DOWN:
canvasWindow.MoveSelection(0, +1);
selectionModel.moveSelection(0, +1);
break;
default:
break;