https://git.reactos.org/?p=reactos.git;a=commitdiff;h=90c3f89bb29f021470be7…
commit 90c3f89bb29f021470be7ad4e4cb9609e39bd4d8
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Dec 27 22:20:22 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Dec 27 22:20:22 2021 +0900
[MSPAINT] Mouse Wheel support (#4195)
Improve usability by mouse wheel handling. Plain wheel, Ctrl+Wheel, and Shift+Wheel.
CORE-17937
---
base/applications/mspaint/common.h | 2 ++
base/applications/mspaint/imgarea.cpp | 9 ++++--
base/applications/mspaint/imgarea.h | 2 ++
base/applications/mspaint/scrollbox.cpp | 5 +++
base/applications/mspaint/scrollbox.h | 2 ++
base/applications/mspaint/selection.cpp | 5 +++
base/applications/mspaint/selection.h | 2 ++
base/applications/mspaint/toolsettings.cpp | 2 +-
base/applications/mspaint/winproc.cpp | 50 ++++++++++++++++++++++++++++++
base/applications/mspaint/winproc.h | 2 ++
10 files changed, 78 insertions(+), 3 deletions(-)
diff --git a/base/applications/mspaint/common.h b/base/applications/mspaint/common.h
index e6864cc21a8..7cdbb22c9bf 100644
--- a/base/applications/mspaint/common.h
+++ b/base/applications/mspaint/common.h
@@ -26,3 +26,5 @@ static inline int UnZoomed(int xy)
}
#define GRIP_SIZE 3
+#define MIN_ZOOM 125
+#define MAX_ZOOM 8000
diff --git a/base/applications/mspaint/imgarea.cpp
b/base/applications/mspaint/imgarea.cpp
index 99a6c72d177..c5169a2b1cc 100644
--- a/base/applications/mspaint/imgarea.cpp
+++ b/base/applications/mspaint/imgarea.cpp
@@ -172,7 +172,7 @@ LRESULT CImgAreaWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM
lParam, B
imageModel.Undo();
}
Invalidate(FALSE);
- if ((toolsModel.GetActiveTool() == TOOL_ZOOM) && (toolsModel.GetZoom() <
8000))
+ if ((toolsModel.GetActiveTool() == TOOL_ZOOM) && (toolsModel.GetZoom() <
MAX_ZOOM))
zoomTo(toolsModel.GetZoom() * 2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
return 0;
}
@@ -192,7 +192,7 @@ LRESULT CImgAreaWindow::OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM
lParam, B
imageModel.Undo();
}
Invalidate(FALSE);
- if ((toolsModel.GetActiveTool() == TOOL_ZOOM) && (toolsModel.GetZoom() >
125))
+ if ((toolsModel.GetActiveTool() == TOOL_ZOOM) && (toolsModel.GetZoom() >
MIN_ZOOM))
zoomTo(toolsModel.GetZoom() / 2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
return 0;
}
@@ -419,3 +419,8 @@ LRESULT CImgAreaWindow::OnImageModelImageChanged(UINT nMsg, WPARAM
wParam, LPARA
Invalidate(FALSE);
return 0;
}
+
+LRESULT CImgAreaWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
+{
+ return ::SendMessage(GetParent(), nMsg, wParam, lParam);
+}
diff --git a/base/applications/mspaint/imgarea.h b/base/applications/mspaint/imgarea.h
index 2fd0074b255..184076c965a 100644
--- a/base/applications/mspaint/imgarea.h
+++ b/base/applications/mspaint/imgarea.h
@@ -24,6 +24,7 @@ public:
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
MESSAGE_HANDLER(WM_RBUTTONUP, OnRButtonUp)
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
+ MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave)
MESSAGE_HANDLER(WM_IMAGEMODELDIMENSIONSCHANGED, OnImageModelDimensionsChanged)
MESSAGE_HANDLER(WM_IMAGEMODELIMAGECHANGED, OnImageModelImageChanged)
@@ -42,6 +43,7 @@ private:
LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseLeave(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnImageModelDimensionsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled);
LRESULT OnImageModelImageChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
diff --git a/base/applications/mspaint/scrollbox.cpp
b/base/applications/mspaint/scrollbox.cpp
index c2354c0cc10..32f48e6d490 100644
--- a/base/applications/mspaint/scrollbox.cpp
+++ b/base/applications/mspaint/scrollbox.cpp
@@ -179,3 +179,8 @@ LRESULT CScrollboxWindow::OnLButtonDown(UINT nMsg, WPARAM wParam,
LPARAM lParam,
pointSP = 0; // resets the point-buffer of the polygon and bezier functions
return 0;
}
+
+LRESULT CScrollboxWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
+{
+ return ::SendMessage(GetParent(), nMsg, wParam, lParam);
+}
diff --git a/base/applications/mspaint/scrollbox.h
b/base/applications/mspaint/scrollbox.h
index 54c42b3d8a2..e2fa3461847 100644
--- a/base/applications/mspaint/scrollbox.h
+++ b/base/applications/mspaint/scrollbox.h
@@ -18,12 +18,14 @@ public:
MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
+ MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
END_MSG_MAP()
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};
void UpdateScrollbox();
diff --git a/base/applications/mspaint/selection.cpp
b/base/applications/mspaint/selection.cpp
index c9155be1cf0..8edd85ba173 100644
--- a/base/applications/mspaint/selection.cpp
+++ b/base/applications/mspaint/selection.cpp
@@ -280,3 +280,8 @@ LRESULT CSelectionWindow::OnSelectionModelRefreshNeeded(UINT nMsg,
WPARAM wParam
ForceRefreshSelectionContents();
return 0;
}
+
+LRESULT CSelectionWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
+{
+ return ::SendMessage(GetParent(), nMsg, wParam, lParam);
+}
diff --git a/base/applications/mspaint/selection.h
b/base/applications/mspaint/selection.h
index 536d4aa9a77..44c9bac0ade 100644
--- a/base/applications/mspaint/selection.h
+++ b/base/applications/mspaint/selection.h
@@ -22,6 +22,7 @@ public:
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
+ MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
MESSAGE_HANDLER(WM_PALETTEMODELCOLORCHANGED, OnPaletteModelColorChanged)
MESSAGE_HANDLER(WM_TOOLSMODELSETTINGSCHANGED, OnToolsModelSettingsChanged)
@@ -37,6 +38,7 @@ public:
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
LRESULT OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled);
diff --git a/base/applications/mspaint/toolsettings.cpp
b/base/applications/mspaint/toolsettings.cpp
index 11cce8386d0..acda95196e5 100644
--- a/base/applications/mspaint/toolsettings.cpp
+++ b/base/applications/mspaint/toolsettings.cpp
@@ -255,7 +255,7 @@ LRESULT CToolSettingsWindow::OnToolsModelZoomChanged(UINT nMsg, WPARAM
wParam, L
int tbPos = 0;
int tempZoom = toolsModel.GetZoom();
- while (tempZoom > 125)
+ while (tempZoom > MIN_ZOOM)
{
tbPos++;
tempZoom = tempZoom >> 1;
diff --git a/base/applications/mspaint/winproc.cpp
b/base/applications/mspaint/winproc.cpp
index be060047ac3..dea5e46cdda 100644
--- a/base/applications/mspaint/winproc.cpp
+++ b/base/applications/mspaint/winproc.cpp
@@ -157,6 +157,56 @@ void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND
window)
ForceRefreshSelectionContents();
}
+LRESULT CMainWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
+{
+ INT zDelta = (SHORT)HIWORD(wParam);
+
+ if (::GetAsyncKeyState(VK_CONTROL) < 0)
+ {
+ if (zDelta < 0)
+ {
+ if (toolsModel.GetZoom() > MIN_ZOOM)
+ zoomTo(toolsModel.GetZoom() / 2, 0, 0);
+ }
+ else if (zDelta > 0)
+ {
+ if (toolsModel.GetZoom() < MAX_ZOOM)
+ zoomTo(toolsModel.GetZoom() * 2, 0, 0);
+ }
+ }
+ else
+ {
+ UINT nCount = 3;
+ if (::GetAsyncKeyState(VK_SHIFT) < 0)
+ {
+#ifndef SPI_GETWHEELSCROLLCHARS
+ #define SPI_GETWHEELSCROLLCHARS 0x006C // Needed for pre-NT6 PSDK
+#endif
+ SystemParametersInfoW(SPI_GETWHEELSCROLLCHARS, 0, &nCount, 0);
+ for (UINT i = 0; i < nCount; ++i)
+ {
+ if (zDelta < 0)
+ ::PostMessageW(scrollboxWindow, WM_HSCROLL, MAKEWPARAM(SB_LINEDOWN,
0), 0);
+ else if (zDelta > 0)
+ ::PostMessageW(scrollboxWindow, WM_HSCROLL, MAKEWPARAM(SB_LINEUP, 0),
0);
+ }
+ }
+ else
+ {
+ SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, &nCount, 0);
+ for (UINT i = 0; i < nCount; ++i)
+ {
+ if (zDelta < 0)
+ ::PostMessageW(scrollboxWindow, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN,
0), 0);
+ else if (zDelta > 0)
+ ::PostMessageW(scrollboxWindow, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0),
0);
+ }
+ }
+ }
+
+ return 0;
+}
+
LRESULT CMainWindow::OnDropFiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
TCHAR droppedfile[MAX_PATH];
diff --git a/base/applications/mspaint/winproc.h b/base/applications/mspaint/winproc.h
index 0c4a4e799c9..e88e822b420 100644
--- a/base/applications/mspaint/winproc.h
+++ b/base/applications/mspaint/winproc.h
@@ -26,6 +26,7 @@ public:
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
MESSAGE_HANDLER(WM_SYSCOLORCHANGE, OnSysColorChange)
MESSAGE_HANDLER(WM_COMMAND, OnCommand)
+ MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
END_MSG_MAP()
LRESULT OnDropFiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
@@ -39,6 +40,7 @@ public:
LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
LRESULT OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
void alignChildrenToMainWindow();
void saveImage(BOOL overwrite);