Commit c5858c16 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

comctl32: Improve mouse wheel scrolling in treeview control.

Allow fractions of WHEEL_DELTA to scroll fractions of SPI_GETWHEELSCROLLLINES, although still only whole lines. Keep the remainder and apply it to next event if in same direction.
parent 858acfbb
...@@ -102,6 +102,7 @@ typedef struct tagTREEVIEW_INFO ...@@ -102,6 +102,7 @@ typedef struct tagTREEVIEW_INFO
BOOL insertBeforeorAfter; /* flag used by TVM_SETINSERTMARK */ BOOL insertBeforeorAfter; /* flag used by TVM_SETINSERTMARK */
HIMAGELIST dragList; /* Bitmap of dragged item */ HIMAGELIST dragList; /* Bitmap of dragged item */
LONG scrollX; LONG scrollX;
INT wheelRemainder;
COLORREF clrBk; COLORREF clrBk;
COLORREF clrText; COLORREF clrText;
COLORREF clrLine; COLORREF clrLine;
...@@ -4925,7 +4926,7 @@ scroll: ...@@ -4925,7 +4926,7 @@ scroll:
static LRESULT static LRESULT
TREEVIEW_MouseWheel(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) TREEVIEW_MouseWheel(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{ {
short gcWheelDelta; short wheelDelta;
UINT pulScrollLines = 3; UINT pulScrollLines = 3;
if (wParam & (MK_SHIFT | MK_CONTROL)) if (wParam & (MK_SHIFT | MK_CONTROL))
...@@ -4936,13 +4937,25 @@ TREEVIEW_MouseWheel(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) ...@@ -4936,13 +4937,25 @@ TREEVIEW_MouseWheel(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, &pulScrollLines, 0); SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, &pulScrollLines, 0);
gcWheelDelta = -(short)HIWORD(wParam); wheelDelta = GET_WHEEL_DELTA_WPARAM(wParam);
pulScrollLines *= (gcWheelDelta / WHEEL_DELTA); /* if scrolling changes direction, ignore left overs */
if ((wheelDelta < 0 && infoPtr->wheelRemainder < 0) ||
(wheelDelta > 0 && infoPtr->wheelRemainder > 0))
infoPtr->wheelRemainder += wheelDelta;
else
infoPtr->wheelRemainder = wheelDelta;
if (abs(gcWheelDelta) >= WHEEL_DELTA && pulScrollLines) if (infoPtr->wheelRemainder && pulScrollLines)
{ {
int newDy = infoPtr->firstVisible->visibleOrder + pulScrollLines; int newDy;
int maxDy = infoPtr->maxVisibleOrder; int maxDy;
int lineScroll;
lineScroll = pulScrollLines * (float)infoPtr->wheelRemainder / WHEEL_DELTA;
infoPtr->wheelRemainder -= WHEEL_DELTA * lineScroll / (int)pulScrollLines;
newDy = infoPtr->firstVisible->visibleOrder - lineScroll;
maxDy = infoPtr->maxVisibleOrder;
if (newDy > maxDy) if (newDy > maxDy)
newDy = maxDy; newDy = maxDy;
...@@ -5047,6 +5060,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs) ...@@ -5047,6 +5060,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
/* dragList */ /* dragList */
infoPtr->scrollX = 0; infoPtr->scrollX = 0;
infoPtr->wheelRemainder = 0;
infoPtr->clrBk = CLR_NONE; /* use system color */ infoPtr->clrBk = CLR_NONE; /* use system color */
infoPtr->clrText = CLR_NONE; /* use system color */ infoPtr->clrText = CLR_NONE; /* use system color */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment