mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 13:16:07 +00:00
[MSPAINT] "Selection Clone" and "Selection Brush" (#5734)
- Stamp the image of the selection when the user clicks on the selection while holding down the Ctrl key. - Draw the image of the selection continuously when the user starts dragging the selection while holding down the Shift key. CORE-19094
This commit is contained in:
parent
03283371c1
commit
cbc63d876c
7 changed files with 51 additions and 6 deletions
|
@ -268,9 +268,18 @@ LRESULT CCanvasWindow::OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam
|
||||||
HITTEST hitSelection = SelectionHitTest(pt);
|
HITTEST hitSelection = SelectionHitTest(pt);
|
||||||
if (hitSelection != HIT_NONE)
|
if (hitSelection != HIT_NONE)
|
||||||
{
|
{
|
||||||
|
selectionModel.m_nSelectionBrush = 0; // Selection Brush is OFF
|
||||||
if (bLeftButton)
|
if (bLeftButton)
|
||||||
{
|
{
|
||||||
CanvasToImage(pt);
|
CanvasToImage(pt);
|
||||||
|
if (::GetKeyState(VK_CONTROL) < 0) // Ctrl+Click is Selection Clone
|
||||||
|
{
|
||||||
|
imageModel.SelectionClone();
|
||||||
|
}
|
||||||
|
else if (::GetKeyState(VK_SHIFT) < 0) // Shift+Dragging is Selection Brush
|
||||||
|
{
|
||||||
|
selectionModel.m_nSelectionBrush = 1; // Selection Brush is ON
|
||||||
|
}
|
||||||
StartSelectionDrag(hitSelection, pt);
|
StartSelectionDrag(hitSelection, pt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -790,6 +799,12 @@ VOID CCanvasWindow::StartSelectionDrag(HITTEST hit, POINT ptImage)
|
||||||
|
|
||||||
VOID CCanvasWindow::SelectionDragging(POINT ptImage)
|
VOID CCanvasWindow::SelectionDragging(POINT ptImage)
|
||||||
{
|
{
|
||||||
|
if (selectionModel.m_nSelectionBrush)
|
||||||
|
{
|
||||||
|
imageModel.SelectionClone(selectionModel.m_nSelectionBrush == 1);
|
||||||
|
selectionModel.m_nSelectionBrush = 2; // Selection Brush is ON and drawn
|
||||||
|
}
|
||||||
|
|
||||||
selectionModel.Dragging(m_hitSelection, ptImage);
|
selectionModel.Dragging(m_hitSelection, ptImage);
|
||||||
Invalidate(FALSE);
|
Invalidate(FALSE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,3 +299,16 @@ void ImageModel::UnlockBitmap(HBITMAP hbmLocked)
|
||||||
m_hBms[m_currInd] = hbmLocked;
|
m_hBms[m_currInd] = hbmLocked;
|
||||||
m_hbmOld = ::SelectObject(m_hDrawingDC, hbmLocked); // Re-select
|
m_hbmOld = ::SelectObject(m_hDrawingDC, hbmLocked); // Re-select
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageModel::SelectionClone(BOOL bUndoable)
|
||||||
|
{
|
||||||
|
if (!selectionModel.m_bShow || ::IsRectEmpty(&selectionModel.m_rc))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (bUndoable)
|
||||||
|
PushImageForUndo(CopyBitmap());
|
||||||
|
|
||||||
|
selectionModel.DrawSelection(m_hDrawingDC, paletteModel.GetBgColor(),
|
||||||
|
toolsModel.IsBackgroundTransparent());
|
||||||
|
NotifyImageChanged();
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ public:
|
||||||
void NotifyImageChanged();
|
void NotifyImageChanged();
|
||||||
BOOL IsBlackAndWhite();
|
BOOL IsBlackAndWhite();
|
||||||
void PushBlackAndWhite();
|
void PushBlackAndWhite();
|
||||||
|
void SelectionClone(BOOL bUndoable = TRUE);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HDC m_hDrawingDC; // The device context for this class
|
HDC m_hDrawingDC; // The device context for this class
|
||||||
|
|
|
@ -112,10 +112,7 @@ struct FreeSelTool : ToolBase
|
||||||
void OnDrawOverlayOnImage(HDC hdc) override
|
void OnDrawOverlayOnImage(HDC hdc) override
|
||||||
{
|
{
|
||||||
if (!selectionModel.IsLanded())
|
if (!selectionModel.IsLanded())
|
||||||
{
|
|
||||||
selectionModel.DrawBackgroundPoly(hdc, selectionModel.m_rgbBack);
|
|
||||||
selectionModel.DrawSelection(hdc, paletteModel.GetBgColor(), toolsModel.IsBackgroundTransparent());
|
selectionModel.DrawSelection(hdc, paletteModel.GetBgColor(), toolsModel.IsBackgroundTransparent());
|
||||||
}
|
|
||||||
|
|
||||||
if (canvasWindow.m_drawing)
|
if (canvasWindow.m_drawing)
|
||||||
{
|
{
|
||||||
|
@ -208,10 +205,7 @@ struct RectSelTool : ToolBase
|
||||||
void OnDrawOverlayOnImage(HDC hdc) override
|
void OnDrawOverlayOnImage(HDC hdc) override
|
||||||
{
|
{
|
||||||
if (!selectionModel.IsLanded())
|
if (!selectionModel.IsLanded())
|
||||||
{
|
|
||||||
selectionModel.DrawBackgroundRect(hdc, selectionModel.m_rgbBack);
|
|
||||||
selectionModel.DrawSelection(hdc, paletteModel.GetBgColor(), toolsModel.IsBackgroundTransparent());
|
selectionModel.DrawSelection(hdc, paletteModel.GetBgColor(), toolsModel.IsBackgroundTransparent());
|
||||||
}
|
|
||||||
|
|
||||||
if (canvasWindow.m_drawing)
|
if (canvasWindow.m_drawing)
|
||||||
{
|
{
|
||||||
|
|
|
@ -187,6 +187,17 @@ BOOL SelectionModel::TakeOff()
|
||||||
// Save the selection area
|
// Save the selection area
|
||||||
m_rcOld = m_rc;
|
m_rcOld = m_rc;
|
||||||
|
|
||||||
|
if (toolsModel.GetActiveTool() == TOOL_RECTSEL)
|
||||||
|
{
|
||||||
|
imageModel.PushImageForUndo();
|
||||||
|
selectionModel.DrawBackgroundRect(imageModel.GetDC(), selectionModel.m_rgbBack);
|
||||||
|
}
|
||||||
|
else if (toolsModel.GetActiveTool() == TOOL_FREESEL)
|
||||||
|
{
|
||||||
|
imageModel.PushImageForUndo();
|
||||||
|
selectionModel.DrawBackgroundPoly(imageModel.GetDC(), selectionModel.m_rgbBack);
|
||||||
|
}
|
||||||
|
|
||||||
imageModel.NotifyImageChanged();
|
imageModel.NotifyImageChanged();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
CRect m_rc; // in image pixel coordinates
|
CRect m_rc; // in image pixel coordinates
|
||||||
POINT m_ptHit; // in image pixel coordinates
|
POINT m_ptHit; // in image pixel coordinates
|
||||||
CRect m_rcOld; // in image pixel coordinates
|
CRect m_rcOld; // in image pixel coordinates
|
||||||
|
INT m_nSelectionBrush = 0;
|
||||||
|
|
||||||
SelectionModel();
|
SelectionModel();
|
||||||
~SelectionModel();
|
~SelectionModel();
|
||||||
|
|
|
@ -704,6 +704,16 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
||||||
if (toolsModel.IsSelection())
|
if (toolsModel.IsSelection())
|
||||||
{
|
{
|
||||||
canvasWindow.cancelDrawing();
|
canvasWindow.cancelDrawing();
|
||||||
|
if (toolsModel.GetActiveTool() == TOOL_FREESEL ||
|
||||||
|
toolsModel.GetActiveTool() == TOOL_RECTSEL)
|
||||||
|
{
|
||||||
|
imageModel.Undo();
|
||||||
|
if (selectionModel.m_nSelectionBrush == 2) // Selection Brush is drawn
|
||||||
|
{
|
||||||
|
imageModel.Undo();
|
||||||
|
selectionModel.m_nSelectionBrush = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue