[MSPAINT] Add selectionModel.drawFrameOnCanvas and use it

Refactoring. CORE-19094
This commit is contained in:
Katayama Hirofumi MZ 2023-11-23 11:03:10 +09:00
parent c2bb5aa01d
commit 4a52a4b04c
4 changed files with 16 additions and 19 deletions

View file

@ -103,18 +103,6 @@ void ToolBase::endEvent()
m_hdc = NULL;
}
void ToolBase::OnDrawSelectionOnCanvas(HDC hdc)
{
if (!selectionModel.m_bShow)
return;
RECT rcSelection = selectionModel.m_rc;
canvasWindow.ImageToCanvas(rcSelection);
::InflateRect(&rcSelection, GRIP_SIZE, GRIP_SIZE);
drawSizeBoxes(hdc, &rcSelection, TRUE);
}
void ToolBase::pushToPtStack(LONG x, LONG y)
{
if (s_pointSP >= s_maxPointSP)
@ -157,7 +145,7 @@ struct FreeSelTool : ToolBase
void OnDrawOverlayOnCanvas(HDC hdc) override
{
OnDrawSelectionOnCanvas(hdc);
selectionModel.drawFrameOnCanvas(hdc);
}
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
@ -249,7 +237,7 @@ struct RectSelTool : ToolBase
void OnDrawOverlayOnCanvas(HDC hdc) override
{
OnDrawSelectionOnCanvas(hdc);
selectionModel.drawFrameOnCanvas(hdc);
}
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override

View file

@ -523,8 +523,7 @@ void SelectionModel::NotifyContentChanged()
void SelectionModel::SwapWidthAndHeight()
{
INT cx = m_rc.Width();
INT cy = m_rc.Height();
INT cx = m_rc.Width(), cy = m_rc.Height();
m_rc.right = m_rc.left + cy;
m_rc.bottom = m_rc.top + cx;
}
@ -540,6 +539,18 @@ HITTEST SelectionModel::hitTest(POINT ptCanvas)
return getSizeBoxHitTest(ptCanvas, &rcSelection);
}
void SelectionModel::drawFrameOnCanvas(HDC hCanvasDC)
{
if (!m_bShow)
return;
RECT rcSelection = m_rc;
canvasWindow.ImageToCanvas(rcSelection);
::InflateRect(&rcSelection, GRIP_SIZE, GRIP_SIZE);
drawSizeBoxes(hCanvasDC, &rcSelection, TRUE);
}
void SelectionModel::StretchSelection(BOOL bShrink)
{
if (!m_bShow)

View file

@ -40,6 +40,7 @@ public:
void HideSelection();
void DeleteSelection();
HITTEST hitTest(POINT ptCanvas);
void drawFrameOnCanvas(HDC hCanvasDC);
HBITMAP GetSelectionContents();
void DrawFramePoly(HDC hDCImage);

View file

@ -65,9 +65,6 @@ struct ToolBase
void pushToPtStack(LONG x, LONG y);
static ToolBase* createToolObject(TOOLTYPE type);
protected:
void OnDrawSelectionOnCanvas(HDC hdc);
};
class ToolsModel