mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:02:58 +00:00
[MSPAINT] Improve Undo/Redo handling of selection (#6035)
Consistent behavior of the application. - Add ShiftPtStack and BuildMaskFromPtStack helper functions. - Move some codes of selectionModel to mouse.cpp. CORE-19226
This commit is contained in:
parent
ab0119c61f
commit
b8598e095d
10 changed files with 134 additions and 205 deletions
|
@ -406,7 +406,7 @@ void CMainWindow::alignChildrenToMainWindow()
|
|||
|
||||
void CMainWindow::saveImage(BOOL overwrite)
|
||||
{
|
||||
canvasWindow.finishDrawing();
|
||||
canvasWindow.OnEndDraw(FALSE);
|
||||
|
||||
// Is the extension not supported?
|
||||
PWCHAR pchDotExt = PathFindExtensionW(g_szFileName);
|
||||
|
@ -606,7 +606,7 @@ LRESULT CMainWindow::OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
|
||||
BOOL CMainWindow::ConfirmSave()
|
||||
{
|
||||
canvasWindow.finishDrawing();
|
||||
canvasWindow.OnEndDraw(FALSE);
|
||||
|
||||
if (imageModel.IsImageSaved())
|
||||
return TRUE;
|
||||
|
@ -693,8 +693,6 @@ BOOL CMainWindow::CanUndo() const
|
|||
return (BOOL)textEditWindow.SendMessage(EM_CANUNDO);
|
||||
if (selectionModel.m_bShow && toolsModel.IsSelection())
|
||||
return TRUE;
|
||||
if (ToolBase::s_pointSP != 0)
|
||||
return TRUE;
|
||||
return imageModel.CanUndo();
|
||||
}
|
||||
|
||||
|
@ -702,8 +700,6 @@ BOOL CMainWindow::CanRedo() const
|
|||
{
|
||||
if (toolsModel.GetActiveTool() == TOOL_TEXT && ::IsWindowVisible(textEditWindow))
|
||||
return FALSE; // There is no "WM_REDO" in EDIT control
|
||||
if (ToolBase::s_pointSP != 0)
|
||||
return TRUE;
|
||||
return imageModel.CanRedo();
|
||||
}
|
||||
|
||||
|
@ -802,29 +798,11 @@ LRESULT CMainWindow::OnGetMinMaxInfo(UINT nMsg, WPARAM wParam, LPARAM lParam, BO
|
|||
|
||||
LRESULT CMainWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
HWND hwndCapture;
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_ESCAPE:
|
||||
hwndCapture = GetCapture();
|
||||
if (hwndCapture)
|
||||
{
|
||||
if (canvasWindow.m_hWnd == hwndCapture ||
|
||||
fullscreenWindow.m_hWnd == hwndCapture)
|
||||
{
|
||||
::SendMessageW(hwndCapture, nMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
else if (selectionModel.m_bShow)
|
||||
{
|
||||
selectionModel.HideSelection();
|
||||
}
|
||||
else
|
||||
{
|
||||
canvasWindow.cancelDrawing();
|
||||
}
|
||||
canvasWindow.PostMessage(nMsg, wParam, lParam);
|
||||
break;
|
||||
|
||||
case VK_LEFT:
|
||||
selectionModel.moveSelection(-1, 0);
|
||||
break;
|
||||
|
@ -932,7 +910,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
GlobalFree(pd.hDevNames);
|
||||
break;
|
||||
case IDM_FILESEND:
|
||||
canvasWindow.finishDrawing();
|
||||
canvasWindow.OnEndDraw(FALSE);
|
||||
if (!OpenMailer(m_hWnd, g_szFileName))
|
||||
{
|
||||
ShowError(IDS_CANTSENDMAIL);
|
||||
|
@ -963,7 +941,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
textEditWindow.PostMessage(WM_UNDO, 0, 0);
|
||||
break;
|
||||
}
|
||||
canvasWindow.finishDrawing();
|
||||
canvasWindow.OnEndDraw(FALSE);
|
||||
imageModel.Undo();
|
||||
break;
|
||||
case IDM_EDITREDO:
|
||||
|
@ -972,7 +950,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
// There is no "WM_REDO" in EDIT control
|
||||
break;
|
||||
}
|
||||
canvasWindow.finishDrawing();
|
||||
canvasWindow.OnEndDraw(FALSE);
|
||||
imageModel.Redo();
|
||||
break;
|
||||
case IDM_EDITCOPY:
|
||||
|
@ -1087,7 +1065,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
break;
|
||||
|
||||
case TOOL_TEXT:
|
||||
canvasWindow.cancelDrawing();
|
||||
canvasWindow.OnEndDraw(TRUE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue