1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Smoother mouse wheel scrolling

This commit is contained in:
Brian Fiete 2020-05-25 00:10:35 -07:00
parent 5a5287bc8b
commit 84aecbca81
11 changed files with 20 additions and 15 deletions

View file

@ -125,7 +125,7 @@ namespace Beefy
delegate void NativeMouseProxyMoveDelegate(void* window, int32 x, int32 y); delegate void NativeMouseProxyMoveDelegate(void* window, int32 x, int32 y);
delegate void NativeMouseDownDelegate(void* window, int32 x, int32 y, int32 btn, int32 btnCount); delegate void NativeMouseDownDelegate(void* window, int32 x, int32 y, int32 btn, int32 btnCount);
delegate void NativeMouseUpDelegate(void* window, int32 x, int32 y, int32 btn); delegate void NativeMouseUpDelegate(void* window, int32 x, int32 y, int32 btn);
delegate void NativeMouseWheelDelegate(void* window, int32 x, int32 y, int32 delta); delegate void NativeMouseWheelDelegate(void* window, int32 x, int32 y, float delta);
delegate void NativeMouseLeaveDelegate(void* window); delegate void NativeMouseLeaveDelegate(void* window);
delegate void NativeMenuItemSelectedDelegate(void* window, void* menu); delegate void NativeMenuItemSelectedDelegate(void* window, void* menu);
@ -296,7 +296,7 @@ namespace Beefy
static void Static_NativeMouseProxyMoveDelegate(void* window, int32 mouseX, int32 mouseY) { GetBFWindow(window).MouseProxyMove(mouseX, mouseY); } static void Static_NativeMouseProxyMoveDelegate(void* window, int32 mouseX, int32 mouseY) { GetBFWindow(window).MouseProxyMove(mouseX, mouseY); }
static void Static_NativeMouseDownDelegate(void* window, int32 mouseX, int32 mouseY, int32 btnNum, int32 btnCount) { GetBFWindow(window).MouseDown(mouseX, mouseY, btnNum, btnCount); } static void Static_NativeMouseDownDelegate(void* window, int32 mouseX, int32 mouseY, int32 btnNum, int32 btnCount) { GetBFWindow(window).MouseDown(mouseX, mouseY, btnNum, btnCount); }
static void Static_NativeMouseUpDelegate(void* window, int32 mouseX, int32 mouseY, int32 btnNum) { GetBFWindow(window).MouseUp(mouseX, mouseY, btnNum); } static void Static_NativeMouseUpDelegate(void* window, int32 mouseX, int32 mouseY, int32 btnNum) { GetBFWindow(window).MouseUp(mouseX, mouseY, btnNum); }
static void Static_NativeMouseWheelDelegate(void* window, int32 mouseX, int32 mouseY, int32 delta) { GetBFWindow(window).MouseWheel(mouseX, mouseY, delta); } static void Static_NativeMouseWheelDelegate(void* window, int32 mouseX, int32 mouseY, float delta) { GetBFWindow(window).MouseWheel(mouseX, mouseY, delta); }
static void Static_NativeMouseLeaveDelegate(void* window) { GetBFWindow(window).MouseLeave(); } static void Static_NativeMouseLeaveDelegate(void* window) { GetBFWindow(window).MouseLeave(); }
static void Static_NativeMenuItemSelectedDelegate(void* window, void* item) { GetBFWindow(window).NativeMenuItemSelected(item); } static void Static_NativeMenuItemSelectedDelegate(void* window, void* item) { GetBFWindow(window).NativeMenuItemSelected(item); }
#endif #endif
@ -640,7 +640,7 @@ namespace Beefy
{ {
} }
public virtual void MouseWheel(int32 x, int32 y, int32 delta) public virtual void MouseWheel(int32 x, int32 y, float delta)
{ {
} }

View file

@ -11,7 +11,7 @@ namespace Beefy.events
public float mY; public float mY;
public int32 mBtn; public int32 mBtn;
public int32 mBtnCount; public int32 mBtnCount;
public int32 mWheelDelta; public float mWheelDelta;
public void GetRootCoords(out float x, out float y) public void GetRootCoords(out float x, out float y)
{ {

View file

@ -889,7 +889,7 @@ namespace Beefy.theme.dark
base.InitScrollbars(wantHorz, wantVert); base.InitScrollbars(wantHorz, wantVert);
float scrollIncrement = ((DarkEditWidgetContent) mEditWidgetContent).mFont.GetLineSpacing() * GS!(3); float scrollIncrement = ((DarkEditWidgetContent) mEditWidgetContent).mFont.GetLineSpacing();
if (mHorzScrollbar != null) if (mHorzScrollbar != null)
mHorzScrollbar.mScrollIncrement = scrollIncrement; mHorzScrollbar.mScrollIncrement = scrollIncrement;
if (mVertScrollbar != null) if (mVertScrollbar != null)

View file

@ -139,7 +139,7 @@ namespace Beefy.widgets
ScrollSetLevel(accelFrac); ScrollSetLevel(accelFrac);
} }
public virtual void FixedScroll(int32 delta) public virtual void FixedScroll(float delta)
{ {
HandleScroll(delta * mFixedScrollAmt); HandleScroll(delta * mFixedScrollAmt);
} }
@ -238,7 +238,7 @@ namespace Beefy.widgets
mDownTick = 0; mDownTick = 0;
} }
public override void MouseWheel(float x, float y, int32 delta) public override void MouseWheel(float x, float y, float delta)
{ {
FixedScroll(-delta); FixedScroll(-delta);
} }

View file

@ -250,7 +250,7 @@ namespace Beefy.widgets
} }
} }
public override void MouseWheel(float x, float y, int32 delta) public override void MouseWheel(float x, float y, float delta)
{ {
base.MouseWheel(x, y, delta); base.MouseWheel(x, y, delta);
if (mVertScrollbar != null) if (mVertScrollbar != null)

View file

@ -224,7 +224,7 @@ namespace Beefy.widgets
mDownTick = 0; mDownTick = 0;
} }
public override void MouseWheel(float x, float y, int32 delta) public override void MouseWheel(float x, float y, float delta)
{ {
Scroll(GetScrollIncrement() * -delta); Scroll(GetScrollIncrement() * -delta);
} }

View file

@ -708,7 +708,7 @@ namespace Beefy.widgets
} }
} }
public virtual void MouseWheel(float x, float y, int32 delta) public virtual void MouseWheel(float x, float y, float delta)
{ {
MarkDirty(); MarkDirty();

View file

@ -708,7 +708,7 @@ namespace Beefy.widgets
mCaptureWidget = null; mCaptureWidget = null;
} }
public override void MouseWheel(int32 inX, int32 inY, int32 delta) public override void MouseWheel(int32 inX, int32 inY, float delta)
{ {
float x; float x;
float y; float y;

View file

@ -20,7 +20,7 @@ typedef void (*BFWindow_MouseMove)(BFWindow* window, int x, int y);
typedef void (*BFWindow_MouseProxyMove)(BFWindow* window, int x, int y); typedef void (*BFWindow_MouseProxyMove)(BFWindow* window, int x, int y);
typedef void (*BFWindow_MouseDown)(BFWindow* window, int x, int y, int btn, int btnCount); typedef void (*BFWindow_MouseDown)(BFWindow* window, int x, int y, int btn, int btnCount);
typedef void (*BFWindow_MouseUp)(BFWindow* window, int x, int y, int btn); typedef void (*BFWindow_MouseUp)(BFWindow* window, int x, int y, int btn);
typedef void (*BFWindow_MouseWheel)(BFWindow* window, int x, int y, int delta); typedef void (*BFWindow_MouseWheel)(BFWindow* window, int x, int y, float delta);
typedef void (*BFWindow_MouseLeave)(BFWindow* window); typedef void (*BFWindow_MouseLeave)(BFWindow* window);
typedef void (*BFWindow_MenuItemSelectedFunc)(BFWindow* window, BFMenu* menu); typedef void (*BFWindow_MenuItemSelectedFunc)(BFWindow* window, BFMenu* menu);

View file

@ -639,6 +639,11 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
} }
} }
UINT ucNumLines = 0;
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &ucNumLines, 0);
if (ucNumLines == 0)
ucNumLines = 3; // Default
if ((cursorWindow != this) && (mIsMouseInside)) if ((cursorWindow != this) && (mIsMouseInside))
{ {
mMouseLeaveFunc(this); mMouseLeaveFunc(this);
@ -648,7 +653,7 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
POINT pt = {x, y}; POINT pt = {x, y};
ScreenToClient(cursorWindow->mHWnd, &pt); ScreenToClient(cursorWindow->mHWnd, &pt);
int delta = ((int16)HIWORD(wParam)) / 120; float delta = ((int16)HIWORD(wParam)) / 120.0f * (float)ucNumLines;
mMouseWheelFunc(cursorWindow, pt.x, pt.y, delta); mMouseWheelFunc(cursorWindow, pt.x, pt.y, delta);
} }
break; break;

View file

@ -2135,7 +2135,7 @@ namespace IDE.ui
} }
*/ */
public override void MouseWheel(float x, float y, int32 delta) public override void MouseWheel(float x, float y, float delta)
{ {
base.MouseWheel(x, y, delta); base.MouseWheel(x, y, delta);
if (mInfiniteScrollbar != null) if (mInfiniteScrollbar != null)