From 5fea94f36ce7a4d62c7ab05ce3d29aa0dfecd4bf Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Mon, 23 Oct 2023 08:34:20 +0900 Subject: [PATCH] update --- canvas.cpp | 166 ++++++++++++++++++++++++++++++--------------- canvas.h | 33 +++++---- common.h | 1 - dib.cpp | 2 +- history.cpp | 2 +- icons/handdrag.cur | Bin 0 -> 326 bytes mouse.cpp | 79 +++++++++++++-------- reactos/buildno.h | 12 ++-- resource.h | 1 + rsrc.rc | 1 + toolsettings.cpp | 2 +- winproc.cpp | 55 ++++----------- 12 files changed, 203 insertions(+), 151 deletions(-) create mode 100644 icons/handdrag.cur diff --git a/canvas.cpp b/canvas.cpp index 680acd6..b423662 100644 --- a/canvas.cpp +++ b/canvas.cpp @@ -89,31 +89,88 @@ HITTEST CCanvasWindow::CanvasHitTest(POINT pt) return getSizeBoxHitTest(pt, &rcBase); } +VOID CCanvasWindow::getNewZoomRect(CRect& rcView, INT newZoom, CPoint ptTarget) +{ + CRect rcImage; + GetImageRect(rcImage); + ImageToCanvas(rcImage); + + // Calculate the zoom rectangle + INT oldZoom = toolsModel.GetZoom(); + GetClientRect(rcView); + LONG cxView = rcView.right * oldZoom / newZoom, cyView = rcView.bottom * oldZoom / newZoom; + ::SetRect(&rcView, ptTarget.x - cxView / 2, ptTarget.y - cyView / 2, + ptTarget.x + cxView / 2, ptTarget.y + cyView / 2); + + // Shift the rectangle if necessary + INT dx = 0, dy = 0; + if (rcView.left < rcImage.left) + dx = rcImage.left - rcView.left; + else if (rcImage.right < rcView.right) + dx = rcImage.right - rcView.right; + if (rcView.top < rcImage.top) + dy = rcImage.top - rcView.top; + else if (rcImage.bottom < rcView.bottom) + dy = rcImage.bottom - rcView.bottom; + rcView.OffsetRect(dx, dy); + + rcView.IntersectRect(&rcView, &rcImage); +} + +VOID CCanvasWindow::zoomTo(INT newZoom, LONG left, LONG top) +{ + POINT pt = { left, top }; + CanvasToImage(pt); + + toolsModel.SetZoom(newZoom); + ImageToCanvas(pt); + pt.x += GetScrollPos(SB_HORZ); + pt.y += GetScrollPos(SB_VERT); + + updateScrollRange(); + updateScrollPos(pt.x, pt.y); + Invalidate(TRUE); +} + VOID CCanvasWindow::DoDraw(HDC hDC, RECT& rcClient, RECT& rcPaint) { + // This is the target area we have to draw on + CRect rcCanvasDraw; + rcCanvasDraw.IntersectRect(&rcClient, &rcPaint); + // We use a memory bitmap to reduce flickering HDC hdcMem0 = ::CreateCompatibleDC(hDC); m_ahbmCached[0] = CachedBufferDIB(m_ahbmCached[0], rcClient.right, rcClient.bottom); HGDIOBJ hbm0Old = ::SelectObject(hdcMem0, m_ahbmCached[0]); // Fill the background on hdcMem0 - ::FillRect(hdcMem0, &rcPaint, (HBRUSH)(COLOR_APPWORKSPACE + 1)); + ::FillRect(hdcMem0, &rcCanvasDraw, (HBRUSH)(COLOR_APPWORKSPACE + 1)); // Draw the sizeboxes if necessary RECT rcBase = GetBaseRect(); if (!selectionModel.m_bShow && !::IsWindowVisible(textEditWindow)) - drawSizeBoxes(hdcMem0, &rcBase, FALSE, &rcPaint); + drawSizeBoxes(hdcMem0, &rcBase, FALSE, &rcCanvasDraw); // Calculate image size CRect rcImage; GetImageRect(rcImage); SIZE sizeImage = { imageModel.GetWidth(), imageModel.GetHeight() }; + // Calculate the target area on the image + CRect rcImageDraw = rcCanvasDraw; + CanvasToImage(rcImageDraw); + rcImageDraw.IntersectRect(&rcImageDraw, &rcImage); + + // Consider rounding down by zooming + rcImageDraw.right += 1; + rcImageDraw.bottom += 1; + // hdcMem1 <-- imageModel HDC hdcMem1 = ::CreateCompatibleDC(hDC); m_ahbmCached[1] = CachedBufferDIB(m_ahbmCached[1], sizeImage.cx, sizeImage.cy); HGDIOBJ hbm1Old = ::SelectObject(hdcMem1, m_ahbmCached[1]); - BitBlt(hdcMem1, 0, 0, sizeImage.cx, sizeImage.cy, imageModel.GetDC(), 0, 0, SRCCOPY); + ::BitBlt(hdcMem1, rcImageDraw.left, rcImageDraw.top, rcImageDraw.Width(), rcImageDraw.Height(), + imageModel.GetDC(), rcImageDraw.left, rcImageDraw.top, SRCCOPY); // Draw overlay #1 on hdcMem1 toolsModel.OnDrawOverlayOnImage(hdcMem1); @@ -158,17 +215,15 @@ VOID CCanvasWindow::DoDraw(HDC hDC, RECT& rcClient, RECT& rcPaint) DrawXorRect(hdcMem0, &m_rcResizing); // Transfer the bits (hDC <-- hdcMem0) - ::BitBlt(hDC, - rcPaint.left, rcPaint.top, - rcPaint.right - rcPaint.left, rcPaint.bottom - rcPaint.top, - hdcMem0, rcPaint.left, rcPaint.top, SRCCOPY); + ::BitBlt(hDC, rcCanvasDraw.left, rcCanvasDraw.top, rcCanvasDraw.Width(), rcCanvasDraw.Height(), + hdcMem0, rcCanvasDraw.left, rcCanvasDraw.top, SRCCOPY); // Clean up hdcMem0 ::SelectObject(hdcMem0, hbm0Old); ::DeleteDC(hdcMem0); } -VOID CCanvasWindow::updateScrollInfo() +VOID CCanvasWindow::updateScrollRange() { CRect rcClient; GetClientRect(&rcClient); @@ -199,16 +254,16 @@ VOID CCanvasWindow::updateScrollInfo() SetScrollInfo(SB_VERT, &si); } -VOID CCanvasWindow::resetScrollPos() +VOID CCanvasWindow::updateScrollPos(INT x, INT y) { - SetScrollPos(SB_HORZ, 0); - SetScrollPos(SB_VERT, 0); + SetScrollPos(SB_HORZ, x); + SetScrollPos(SB_VERT, y); } LRESULT CCanvasWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if (m_hWnd) - updateScrollInfo(); + updateScrollRange(); return 0; } @@ -223,7 +278,7 @@ VOID CCanvasWindow::OnHVScroll(WPARAM wParam, INT fnBar) { case SB_THUMBTRACK: case SB_THUMBPOSITION: - si.nPos = HIWORD(wParam); + si.nPos = (SHORT)HIWORD(wParam); break; case SB_LINELEFT: si.nPos -= 5; @@ -238,9 +293,9 @@ VOID CCanvasWindow::OnHVScroll(WPARAM wParam, INT fnBar) si.nPos += si.nPage; break; } + si.nPos = max(min(si.nPos, si.nMax), si.nMin); SetScrollInfo(fnBar, &si); - updateScrollInfo(); - Invalidate(FALSE); // FIXME: Flicker + Invalidate(); } LRESULT CCanvasWindow::OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) @@ -255,10 +310,21 @@ LRESULT CCanvasWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& return 0; } -LRESULT CCanvasWindow::OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +LRESULT CCanvasWindow::OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + m_nMouseDownMsg = nMsg; + BOOL bLeftButton = (nMsg == WM_LBUTTONDOWN); + + if (nMsg == WM_MBUTTONDOWN) + { + m_ptOrig = pt; + SetCapture(); + ::SetCursor(::LoadCursor(g_hinstExe, MAKEINTRESOURCE(IDC_HANDDRAG))); + return 0; + } + HITTEST hitSelection = SelectionHitTest(pt); if (hitSelection != HIT_NONE) { @@ -278,7 +344,7 @@ LRESULT CCanvasWindow::OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam } else { - canvasWindow.ClientToScreen(&pt); + ClientToScreen(&pt); mainWindow.TrackPopupMenu(pt, 0); } return 0; @@ -292,13 +358,13 @@ LRESULT CCanvasWindow::OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam case TOOL_BEZIER: case TOOL_SHAPE: toolsModel.OnCancelDraw(); - canvasWindow.Invalidate(); + Invalidate(); break; case TOOL_FREESEL: case TOOL_RECTSEL: toolsModel.OnFinishDraw(); - canvasWindow.Invalidate(); + Invalidate(); break; default: @@ -331,43 +397,35 @@ LRESULT CCanvasWindow::OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam return 0; } -LRESULT CCanvasWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - return OnLRButtonDown(TRUE, nMsg, wParam, lParam, bHandled); -} - -LRESULT CCanvasWindow::OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - return OnLRButtonDown(FALSE, nMsg, wParam, lParam, bHandled); -} - -LRESULT CCanvasWindow::OnLRButtonDblClk(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +LRESULT CCanvasWindow::OnButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; CanvasToImage(pt); m_drawing = FALSE; - ReleaseCapture(); + ::ReleaseCapture(); + m_nMouseDownMsg = 0; - toolsModel.OnButtonDown(bLeftButton, pt.x, pt.y, TRUE); + toolsModel.OnButtonDown(nMsg == WM_LBUTTONDBLCLK, pt.x, pt.y, TRUE); toolsModel.resetTool(); Invalidate(FALSE); return 0; } -LRESULT CCanvasWindow::OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - return OnLRButtonDblClk(TRUE, nMsg, wParam, lParam, bHandled); -} - -LRESULT CCanvasWindow::OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - return OnLRButtonDblClk(FALSE, nMsg, wParam, lParam, bHandled); -} - LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + + if (m_nMouseDownMsg == WM_MBUTTONDOWN) + { + INT x = GetScrollPos(SB_HORZ) - (pt.x - m_ptOrig.x); + INT y = GetScrollPos(SB_VERT) - (pt.y - m_ptOrig.y); + SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, x), 0); + SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, y), 0); + m_ptOrig = pt; + return 0; + } + CanvasToImage(pt); if (toolsModel.GetActiveTool() == TOOL_ZOOM) @@ -557,13 +615,16 @@ LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL return 0; } -LRESULT CCanvasWindow::OnLRButtonUp(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +LRESULT CCanvasWindow::OnButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; CanvasToImage(pt); ::ReleaseCapture(); + BOOL bLeftButton = (m_nMouseDownMsg == WM_LBUTTONDOWN); + m_nMouseDownMsg = 0; + if (m_drawing) { m_drawing = FALSE; @@ -620,21 +681,11 @@ LRESULT CCanvasWindow::OnLRButtonUp(BOOL bLeftButton, UINT nMsg, WPARAM wParam, m_hitCanvasSizeBox = HIT_NONE; toolsModel.resetTool(); // resets the point-buffer of the polygon and bezier functions - updateScrollInfo(); + updateScrollRange(); Invalidate(TRUE); return 0; } -LRESULT CCanvasWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - return OnLRButtonUp(TRUE, nMsg, wParam, lParam, bHandled); -} - -LRESULT CCanvasWindow::OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - return OnLRButtonUp(FALSE, nMsg, wParam, lParam, bHandled); -} - LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if (CWaitCursor::IsWaiting()) @@ -643,6 +694,12 @@ LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL return 0; } + if (m_nMouseDownMsg == WM_MBUTTONDOWN) + { + ::SetCursor(::LoadCursor(g_hinstExe, MAKEINTRESOURCE(IDC_HANDDRAG))); + return 0; + } + POINT pt; ::GetCursorPos(&pt); ScreenToClient(&pt); @@ -705,6 +762,7 @@ LRESULT CCanvasWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& { // Cancel dragging ::ReleaseCapture(); + m_nMouseDownMsg = 0; m_hitCanvasSizeBox = HIT_NONE; ::SetRectEmpty(&m_rcResizing); Invalidate(TRUE); diff --git a/canvas.h b/canvas.h index 193d760..76e7225 100644 --- a/canvas.h +++ b/canvas.h @@ -20,13 +20,15 @@ class CCanvasWindow : public CWindowImpl MESSAGE_HANDLER(WM_HSCROLL, OnHScroll) MESSAGE_HANDLER(WM_VSCROLL, OnVScroll) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd) - MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) - MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown) - MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk) - MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnRButtonDblClk) + MESSAGE_HANDLER(WM_LBUTTONDOWN, OnButtonDown) + MESSAGE_HANDLER(WM_RBUTTONDOWN, OnButtonDown) + MESSAGE_HANDLER(WM_MBUTTONDOWN, OnButtonDown) + MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnButtonDblClk) + MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnButtonDblClk) MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) - MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) - MESSAGE_HANDLER(WM_RBUTTONUP, OnRButtonUp) + MESSAGE_HANDLER(WM_LBUTTONUP, OnButtonUp) + MESSAGE_HANDLER(WM_RBUTTONUP, OnButtonUp) + MESSAGE_HANDLER(WM_MBUTTONUP, OnButtonUp) MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel) MESSAGE_HANDLER(WM_CANCELMODE, OnCancelMode) @@ -42,8 +44,8 @@ class CCanvasWindow : public CWindowImpl VOID cancelDrawing(); VOID finishDrawing(); - VOID updateScrollInfo(); - VOID resetScrollPos(); + VOID updateScrollRange(); + VOID updateScrollPos(INT x = 0, INT y = 0); VOID ImageToCanvas(POINT& pt); VOID ImageToCanvas(RECT& rc); @@ -51,6 +53,8 @@ class CCanvasWindow : public CWindowImpl VOID CanvasToImage(RECT& rc, BOOL bZoomed = FALSE); VOID GetImageRect(RECT& rc); VOID MoveSelection(INT xDelta, INT yDelta); + VOID getNewZoomRect(CRect& rcView, INT newZoom, CPoint ptTarget); + VOID zoomTo(INT newZoom, LONG left = 0, LONG top = 0); protected: HITTEST m_hitSelection; @@ -74,14 +78,8 @@ class CCanvasWindow : public CWindowImpl LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - LRESULT OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - LRESULT OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - LRESULT OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - LRESULT OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); @@ -89,7 +87,8 @@ class CCanvasWindow : public CWindowImpl LRESULT OnCtlColorEdit(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - LRESULT OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - LRESULT OnLRButtonDblClk(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - LRESULT OnLRButtonUp(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + UINT m_nMouseDownMsg = 0; + LRESULT OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); }; diff --git a/common.h b/common.h index d2e862b..3dda670 100644 --- a/common.h +++ b/common.h @@ -43,7 +43,6 @@ enum HITTEST // hit /* FUNCTIONS ********************************************************/ -BOOL zoomTo(int newZoom, int mouseX, int mouseY); BOOL nearlyEqualPoints(INT x0, INT y0, INT x1, INT y1); BOOL OpenMailer(HWND hWnd, LPCWSTR pszPathName); diff --git a/dib.cpp b/dib.cpp index 7b45813..eede332 100644 --- a/dib.cpp +++ b/dib.cpp @@ -241,7 +241,7 @@ HBITMAP InitializeImage(LPCWSTR name, LPWIN32_FIND_DATAW pFound, BOOL isFile) HBITMAP SetBitmapAndInfo(HBITMAP hBitmap, LPCWSTR name, LPWIN32_FIND_DATAW pFound, BOOL isFile) { // update image - canvasWindow.resetScrollPos(); + canvasWindow.updateScrollPos(); imageModel.PushImageForUndo(hBitmap); imageModel.ClearHistory(); diff --git a/history.cpp b/history.cpp index 05990df..2d28cb5 100644 --- a/history.cpp +++ b/history.cpp @@ -16,7 +16,7 @@ void ImageModel::NotifyImageChanged() { if (canvasWindow.IsWindow()) { - canvasWindow.updateScrollInfo(); + canvasWindow.updateScrollRange(); canvasWindow.Invalidate(); } diff --git a/icons/handdrag.cur b/icons/handdrag.cur new file mode 100644 index 0000000000000000000000000000000000000000..74e5ba6b9c2b8e84d7696ce289ed5ba5296f4efa GIT binary patch literal 326 zcmZ|Ku?@m75CzchP*9;z(c+Sl4Z MIN_ZOOM) ? (oldZoom / 2) : MAX_ZOOM; + + m_bZoomed = FALSE; + + if (oldZoom != newZoom) { - if (toolsModel.GetZoom() > MIN_ZOOM) - zoomTo(toolsModel.GetZoom() / 2, x, y); + CRect rcView; + if (getNewZoomRect(rcView, newZoom)) + { + canvasWindow.zoomTo(newZoom, rcView.left, rcView.top); + m_bZoomed = TRUE; + } } } + + BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override + { + if (m_bZoomed) + toolsModel.SetActiveTool(toolsModel.GetOldActiveTool()); + + return TRUE; + } }; +BOOL ZoomTool::getNewZoomRect(CRect& rcView, INT newZoom) +{ + CPoint pt; + ::GetCursorPos(&pt); + canvasWindow.ScreenToClient(&pt); + + canvasWindow.getNewZoomRect(rcView, newZoom, pt); + + CRect rc; + canvasWindow.GetImageRect(rc); + canvasWindow.ImageToCanvas(rc); + + return rc.PtInRect(pt); +} + // TOOL_PEN struct PenTool : SmoothDrawTool { diff --git a/reactos/buildno.h b/reactos/buildno.h index bf51cc5..e3ff5eb 100644 --- a/reactos/buildno.h +++ b/reactos/buildno.h @@ -2,17 +2,17 @@ #ifndef _INC_REACTOS_BUILDNO #define _INC_REACTOS_BUILDNO -#define KERNEL_VERSION_BUILD 20231012 -#define KERNEL_VERSION_BUILD_STR "20231012-0.4.15-dev-6743-g70d5c86" -#define KERNEL_VERSION_BUILD_RC "20231012-0.4.15-dev-6743-g70d5c86\0" +#define KERNEL_VERSION_BUILD 20231022 +#define KERNEL_VERSION_BUILD_STR "20231022-0.4.15-dev-6773-g855008d" +#define KERNEL_VERSION_BUILD_RC "20231022-0.4.15-dev-6773-g855008d\0" #define KERNEL_VERSION_RC "0.4.15-x86-dev\0" #define KERNEL_VERSION_STR "0.4.15-x86-dev" -#define KERNEL_VERSION_REVISION_RC "0.4.15-dev-6743-g70d5c86\0" -#define KERNEL_VERSION_REVISION_STR "0.4.15-dev-6743-g70d5c86" +#define KERNEL_VERSION_REVISION_RC "0.4.15-dev-6773-g855008d\0" +#define KERNEL_VERSION_REVISION_STR "0.4.15-dev-6773-g855008d" -#define KERNEL_VERSION_COMMIT_HASH "70d5c864bc14a2427ca7f0b762f20589c1206491" +#define KERNEL_VERSION_COMMIT_HASH "855008d97b2c7e1a1b72ad268b68d83c739ebc6d" #define REACTOS_DLL_VERSION_MAJOR 42 #define REACTOS_DLL_VERSION_RC "42.4.15-dev\0" diff --git a/resource.h b/resource.h index b41486c..3f87e6e 100644 --- a/resource.h +++ b/resource.h @@ -22,6 +22,7 @@ #define IDC_ZOOM 532 #define IDC_PEN 533 #define IDC_AIRBRUSH 534 +#define IDC_HANDDRAG 535 #define IDI_HORZSTRETCH 535 #define IDI_VERTSTRETCH 536 diff --git a/rsrc.rc b/rsrc.rc index 4bca40c..1f0ee5a 100644 --- a/rsrc.rc +++ b/rsrc.rc @@ -33,6 +33,7 @@ IDC_COLOR ICON "icons/color_cur.ico" IDC_ZOOM ICON "icons/zoom_cur.ico" IDC_PEN ICON "icons/pen_cur.ico" IDC_AIRBRUSH ICON "icons/airbrush_cur.ico" +IDC_HANDDRAG CURSOR "icons/handdrag.cur" IDI_HORZSTRETCH ICON "icons/horzstretch.ico" IDI_VERTSTRETCH ICON "icons/vertstretch.ico" diff --git a/toolsettings.cpp b/toolsettings.cpp index 182862e..745f2af 100644 --- a/toolsettings.cpp +++ b/toolsettings.cpp @@ -309,7 +309,7 @@ LRESULT CToolSettingsWindow::OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam, LRESULT CToolSettingsWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { INT trackPos = MAX_ZOOM_TRACK - (INT)trackbarZoom.SendMessage(TBM_GETPOS, 0, 0); - zoomTo(MIN_ZOOM << trackPos, 0, 0); + canvasWindow.zoomTo(MIN_ZOOM << trackPos); INT zoomRate = toolsModel.GetZoom(); diff --git a/winproc.cpp b/winproc.cpp index 58bf4a9..c1cbff3 100644 --- a/winproc.cpp +++ b/winproc.cpp @@ -41,37 +41,6 @@ static HWND DoHtmlHelpW(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_P return s_pHtmlHelpW(hwndCaller, pszFile, uCommand, dwData); } -BOOL -zoomTo(int newZoom, int mouseX, int mouseY) -{ - int x, y, w, h; - RECT clientRectScrollbox; - canvasWindow.GetClientRect(&clientRectScrollbox); - - RECT clientRectImageArea; - ::SetRect(&clientRectImageArea, 0, 0, imageModel.GetWidth(), imageModel.GetHeight()); - Zoomed(clientRectImageArea); - - w = clientRectImageArea.right * newZoom / toolsModel.GetZoom(); - h = clientRectImageArea.bottom * newZoom / toolsModel.GetZoom(); - if (!w || !h) - { - return FALSE; - } - w = clientRectImageArea.right * clientRectScrollbox.right / w; - h = clientRectImageArea.bottom * clientRectScrollbox.bottom / h; - x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2)) * newZoom / toolsModel.GetZoom(); - y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2)) * newZoom / toolsModel.GetZoom(); - - toolsModel.SetZoom(newZoom); - - canvasWindow.Invalidate(TRUE); - - canvasWindow.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, x), 0); - canvasWindow.SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, y), 0); - return TRUE; -} - void CMainWindow::alignChildrenToMainWindow() { RECT clientRect, rc; @@ -216,20 +185,20 @@ LRESULT CMainWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& { INT zDelta = (SHORT)HIWORD(wParam); - if (::GetAsyncKeyState(VK_CONTROL) < 0) + if (::GetKeyState(VK_CONTROL) < 0) // Ctrl+Wheel { if (zDelta < 0) { if (toolsModel.GetZoom() > MIN_ZOOM) - zoomTo(toolsModel.GetZoom() / 2, 0, 0); + canvasWindow.zoomTo(toolsModel.GetZoom() / 2); } else if (zDelta > 0) { if (toolsModel.GetZoom() < MAX_ZOOM) - zoomTo(toolsModel.GetZoom() * 2, 0, 0); + canvasWindow.zoomTo(toolsModel.GetZoom() * 2); } } - else + else // Wheel only { UINT nCount = 3; if (::GetAsyncKeyState(VK_SHIFT) < 0) @@ -921,7 +890,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH case IDM_IMAGEROTATEMIRROR: { CWaitCursor waitCursor; - canvasWindow.resetScrollPos(); + canvasWindow.updateScrollPos(); switch (mirrorRotateDialog.DoModal(mainWindow.m_hWnd)) { case 1: /* flip horizontally */ @@ -1054,25 +1023,25 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH break; case IDM_VIEWZOOM125: - zoomTo(125, 0, 0); + canvasWindow.zoomTo(125); break; case IDM_VIEWZOOM25: - zoomTo(250, 0, 0); + canvasWindow.zoomTo(250); break; case IDM_VIEWZOOM50: - zoomTo(500, 0, 0); + canvasWindow.zoomTo(500); break; case IDM_VIEWZOOM100: - zoomTo(1000, 0, 0); + canvasWindow.zoomTo(1000); break; case IDM_VIEWZOOM200: - zoomTo(2000, 0, 0); + canvasWindow.zoomTo(2000); break; case IDM_VIEWZOOM400: - zoomTo(4000, 0, 0); + canvasWindow.zoomTo(4000); break; case IDM_VIEWZOOM800: - zoomTo(8000, 0, 0); + canvasWindow.zoomTo(8000); break; case IDM_VIEWFULLSCREEN: