mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:52:57 +00:00
[MSPAINT] Improve Undo/Redo and finishing tool (#4324)
- Fix Undo/Redo mechanism. - Finish drawing when the tool is to be chanaged and when the file is to be saved. - Add ToolBase::OnFinishDraw to virtualize finishing drawing. - Extend bClearRedo parameter to ImageModel::Undo. - Add ImageModel::DrawSelectionBackground and ImageModel::DeleteSelection methods. - Fix some WM_PAINT message handling. CORE-17969
This commit is contained in:
parent
c5b029d0fc
commit
0839711566
14 changed files with 313 additions and 151 deletions
|
@ -57,7 +57,7 @@ void ImageModel::CopyPrevious()
|
|||
imageSaved = FALSE;
|
||||
}
|
||||
|
||||
void ImageModel::Undo()
|
||||
void ImageModel::Undo(BOOL bClearRedo)
|
||||
{
|
||||
ATLTRACE("%s: %d\n", __FUNCTION__, undoSteps);
|
||||
if (undoSteps > 0)
|
||||
|
@ -68,7 +68,9 @@ void ImageModel::Undo()
|
|||
currInd = (currInd + HISTORYSIZE - 1) % HISTORYSIZE;
|
||||
SelectObject(hDrawingDC, hBms[currInd]);
|
||||
undoSteps--;
|
||||
if (redoSteps < HISTORYSIZE - 1)
|
||||
if (bClearRedo)
|
||||
redoSteps = 0;
|
||||
else if (redoSteps < HISTORYSIZE - 1)
|
||||
redoSteps++;
|
||||
if (GetWidth() != oldWidth || GetHeight() != oldHeight)
|
||||
NotifyDimensionsChanged();
|
||||
|
@ -251,3 +253,29 @@ void ImageModel::RotateNTimes90Degrees(int iN)
|
|||
}
|
||||
NotifyImageChanged();
|
||||
}
|
||||
|
||||
void ImageModel::DrawSelectionBackground(COLORREF rgbBG)
|
||||
{
|
||||
if (toolsModel.GetActiveTool() == TOOL_FREESEL)
|
||||
selectionModel.DrawBackgroundPoly(hDrawingDC, rgbBG);
|
||||
else
|
||||
selectionModel.DrawBackgroundRect(hDrawingDC, rgbBG);
|
||||
}
|
||||
|
||||
void ImageModel::DeleteSelection()
|
||||
{
|
||||
if (selectionWindow.IsWindowVisible())
|
||||
ResetToPrevious();
|
||||
CopyPrevious();
|
||||
if (selectionWindow.IsWindowVisible())
|
||||
Undo(TRUE);
|
||||
DrawSelectionBackground(paletteModel.GetBgColor());
|
||||
selectionWindow.ShowWindow(SW_HIDE);
|
||||
NotifyImageChanged();
|
||||
}
|
||||
|
||||
void ImageModel::Bound(POINT& pt)
|
||||
{
|
||||
pt.x = max(0, min(pt.x, GetWidth()));
|
||||
pt.y = max(0, min(pt.y, GetHeight()));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue