mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 17:43:47 +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
|
@ -89,6 +89,8 @@ void CMainWindow::alignChildrenToMainWindow()
|
|||
|
||||
void CMainWindow::saveImage(BOOL overwrite)
|
||||
{
|
||||
imageArea.finishDrawing();
|
||||
|
||||
if (isAFile && overwrite)
|
||||
{
|
||||
imageModel.SaveImage(filepathname);
|
||||
|
@ -156,7 +158,7 @@ void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND window)
|
|||
|
||||
placeSelWin();
|
||||
selectionWindow.ShowWindow(SW_SHOW);
|
||||
ForceRefreshSelectionContents();
|
||||
selectionWindow.ForceRefreshSelectionContents();
|
||||
}
|
||||
|
||||
LRESULT CMainWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
|
@ -238,6 +240,8 @@ LRESULT CMainWindow::OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
|
||||
BOOL CMainWindow::ConfirmSave()
|
||||
{
|
||||
imageArea.finishDrawing();
|
||||
|
||||
if (imageModel.IsImageSaved())
|
||||
return TRUE;
|
||||
|
||||
|
@ -407,14 +411,7 @@ LRESULT CMainWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
}
|
||||
else
|
||||
{
|
||||
switch (toolsModel.GetActiveTool())
|
||||
{
|
||||
case TOOL_SHAPE: case TOOL_BEZIER:
|
||||
imageArea.SendMessage(nMsg, wParam, lParam);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
imageArea.SendMessage(nMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -430,6 +427,13 @@ LRESULT CMainWindow::OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, B
|
|||
|
||||
LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
// Disable commands while dragging mouse
|
||||
if (imageArea.drawing && ::GetCapture())
|
||||
{
|
||||
ATLTRACE("locking!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDM_HELPINFO:
|
||||
|
@ -531,12 +535,31 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
case IDM_EDITUNDO:
|
||||
if (toolsModel.GetActiveTool() == TOOL_TEXT && ::IsWindowVisible(textEditWindow))
|
||||
break;
|
||||
if (selectionWindow.IsWindowVisible())
|
||||
{
|
||||
if (toolsModel.GetActiveTool() == TOOL_RECTSEL ||
|
||||
toolsModel.GetActiveTool() == TOOL_FREESEL)
|
||||
{
|
||||
imageArea.cancelDrawing();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ToolBase::pointSP != 0) // drawing something?
|
||||
{
|
||||
imageArea.cancelDrawing();
|
||||
break;
|
||||
}
|
||||
imageModel.Undo();
|
||||
imageArea.Invalidate(FALSE);
|
||||
break;
|
||||
case IDM_EDITREDO:
|
||||
if (toolsModel.GetActiveTool() == TOOL_TEXT && ::IsWindowVisible(textEditWindow))
|
||||
break;
|
||||
if (ToolBase::pointSP != 0) // drawing something?
|
||||
{
|
||||
imageArea.finishDrawing();
|
||||
break;
|
||||
}
|
||||
imageModel.Redo();
|
||||
imageArea.Invalidate(FALSE);
|
||||
break;
|
||||
|
@ -562,8 +585,19 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
break;
|
||||
case IDM_EDITDELETESELECTION:
|
||||
{
|
||||
/* remove selection window and already painted content using undo */
|
||||
imageModel.Undo();
|
||||
switch (toolsModel.GetActiveTool())
|
||||
{
|
||||
case TOOL_FREESEL:
|
||||
case TOOL_RECTSEL:
|
||||
imageModel.DeleteSelection();
|
||||
break;
|
||||
|
||||
case TOOL_TEXT:
|
||||
imageArea.cancelDrawing();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IDM_EDITSELECTALL:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue