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

Horizontal scroll wheel support

This commit is contained in:
Brian Fiete 2020-10-15 10:00:36 -07:00
parent a944aa6d24
commit 72242aa31c
11 changed files with 51 additions and 28 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, float delta); delegate void NativeMouseWheelDelegate(void* window, int32 x, int32 y, float deltaX, float deltaY);
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, float delta) { GetBFWindow(window).MouseWheel(mouseX, mouseY, delta); } static void Static_NativeMouseWheelDelegate(void* window, int32 mouseX, int32 mouseY, float deltaX, float deltaY) { GetBFWindow(window).MouseWheel(mouseX, mouseY, deltaX, deltaY); }
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, float delta) public virtual void MouseWheel(int32 x, int32 y, float deltaX, float deltaY)
{ {
} }

View file

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

View file

@ -238,8 +238,9 @@ namespace Beefy.widgets
mDownTick = 0; mDownTick = 0;
} }
public override void MouseWheel(float x, float y, float delta) public override void MouseWheel(float x, float y, float deltaX, float deltaY)
{ {
float delta = deltaY;
FixedScroll(-delta); FixedScroll(-delta);
} }
} }

View file

@ -250,13 +250,21 @@ namespace Beefy.widgets
} }
} }
public override void MouseWheel(float x, float y, float delta) public override void MouseWheel(float x, float y, float deltaX, float deltaY)
{ {
base.MouseWheel(x, y, delta); base.MouseWheel(x, y, deltaX, deltaY);
if (mVertScrollbar != null) if (deltaY != 0)
mVertScrollbar.MouseWheel(x, y, delta); {
else if (mHorzScrollbar != null) if (mVertScrollbar != null)
mHorzScrollbar.MouseWheel(x, y, delta); mVertScrollbar.MouseWheel(x, y, 0, deltaY);
else if (mHorzScrollbar != null)
mHorzScrollbar.MouseWheel(x, y, deltaY, 0);
}
if (deltaX != 0)
{
if (mHorzScrollbar != null)
mHorzScrollbar.MouseWheel(x, y, deltaX, 0);
}
} }
public override void RehupScale(float oldScale, float newScale) public override void RehupScale(float oldScale, float newScale)

View file

@ -224,8 +224,9 @@ namespace Beefy.widgets
mDownTick = 0; mDownTick = 0;
} }
public override void MouseWheel(float x, float y, float delta) public override void MouseWheel(float x, float y, float deltaX, float deltaY)
{ {
float delta = (mOrientation == .Horz) ? deltaX : deltaY;
Scroll(GetScrollIncrement() * -delta); Scroll(GetScrollIncrement() * -delta);
} }
} }

View file

@ -712,7 +712,7 @@ namespace Beefy.widgets
} }
} }
public virtual void MouseWheel(float x, float y, float delta) public virtual void MouseWheel(float x, float y, float deltaX, float deltaY)
{ {
MarkDirty(); MarkDirty();
@ -722,7 +722,7 @@ namespace Beefy.widgets
float aX; float aX;
float aY; float aY;
SelfToParentTranslate(x, y, out aX, out aY); SelfToParentTranslate(x, y, out aX, out aY);
mParent.MouseWheel(aX, aY, delta); mParent.MouseWheel(aX, aY, deltaX, deltaY);
} }
} }

View file

@ -740,7 +740,7 @@ namespace Beefy.widgets
mCaptureWidget = null; mCaptureWidget = null;
} }
public override void MouseWheel(int32 inX, int32 inY, float delta) public override void MouseWheel(int32 inX, int32 inY, float deltaX, float deltaY)
{ {
float x; float x;
float y; float y;
@ -753,7 +753,8 @@ namespace Beefy.widgets
MouseEvent anEvent = scope MouseEvent(); MouseEvent anEvent = scope MouseEvent();
anEvent.mX = x; anEvent.mX = x;
anEvent.mY = y; anEvent.mY = y;
anEvent.mWheelDelta = delta; anEvent.mWheelDeltaX = deltaX;
anEvent.mWheelDeltaY = deltaY;
anEvent.mSender = this; anEvent.mSender = this;
sOnMouseWheel(anEvent); sOnMouseWheel(anEvent);
@ -766,7 +767,8 @@ namespace Beefy.widgets
MouseEvent anEvent = scope MouseEvent(); MouseEvent anEvent = scope MouseEvent();
anEvent.mX = x; anEvent.mX = x;
anEvent.mY = y; anEvent.mY = y;
anEvent.mWheelDelta = delta; anEvent.mWheelDeltaX = deltaX;
anEvent.mWheelDeltaY = deltaY;
anEvent.mSender = this; anEvent.mSender = this;
mOnMouseWheel(anEvent); mOnMouseWheel(anEvent);
@ -780,7 +782,7 @@ namespace Beefy.widgets
float childX; float childX;
float childY; float childY;
aWidget.RootToSelfTranslate(mMouseX, mMouseY, out childX, out childY); aWidget.RootToSelfTranslate(mMouseX, mMouseY, out childX, out childY);
aWidget.MouseWheel(childX, childY, delta); aWidget.MouseWheel(childX, childY, deltaX, deltaY);
} }
} }

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, float delta); typedef void (*BFWindow_MouseWheel)(BFWindow* window, int x, int y, float deltaX, float deltaY);
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

@ -539,6 +539,7 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
case WM_MBUTTONUP: case WM_MBUTTONUP:
case WM_XBUTTONUP: case WM_XBUTTONUP:
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
{ {
int x = (short)LOWORD(lParam); int x = (short)LOWORD(lParam);
@ -547,7 +548,7 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
bool releaseCapture = false; bool releaseCapture = false;
POINT point = {x, y}; POINT point = {x, y};
if (uMsg != WM_MOUSEWHEEL) if ((uMsg != WM_MOUSEWHEEL) && (uMsg != WM_MOUSEHWHEEL))
::ClientToScreen(hWnd, &point); ::ClientToScreen(hWnd, &point);
if ((uMsg == WM_MOUSEMOVE) && (point.x == gLastScreenMouseCoords.x) && (point.y == gLastScreenMouseCoords.y)) if ((uMsg == WM_MOUSEMOVE) && (point.x == gLastScreenMouseCoords.x) && (point.y == gLastScreenMouseCoords.y))
@ -627,6 +628,7 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
_BtnUp((int)(wParam >> 16) + 2); _BtnUp((int)(wParam >> 16) + 2);
break; break;
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
{ {
WinBFWindow* cursorWindow = this; WinBFWindow* cursorWindow = this;
@ -667,8 +669,16 @@ 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);
float delta = ((int16)HIWORD(wParam)) / 120.0f * (float)ucNumLines; if (uMsg == WM_MOUSEWHEEL)
mMouseWheelFunc(cursorWindow, pt.x, pt.y, delta); {
float delta = ((int16)HIWORD(wParam)) / 120.0f * (float)ucNumLines;
mMouseWheelFunc(cursorWindow, pt.x, pt.y, 0, delta);
}
else
{
float delta = ((int16)HIWORD(wParam)) / 120.0f;
mMouseWheelFunc(cursorWindow, pt.x, pt.y, delta, 0);
}
} }
break; break;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:

View file

@ -273,7 +273,7 @@ namespace IDE.ui
let windowRect = Rect(mWidgetWindow.mX, mWidgetWindow.mY, mWidgetWindow.mWindowWidth, mWidgetWindow.mWindowHeight); let windowRect = Rect(mWidgetWindow.mX, mWidgetWindow.mY, mWidgetWindow.mWindowWidth, mWidgetWindow.mWindowHeight);
if (windowRect.Contains(mouseScreenX, mouseScreenY)) if (windowRect.Contains(mouseScreenX, mouseScreenY))
{ {
MouseWheel(evt.mX - mWidgetWindow.mX, evt.mY - mWidgetWindow.mY, evt.mWheelDelta); MouseWheel(evt.mX - mWidgetWindow.mX, evt.mY - mWidgetWindow.mY, evt.mWheelDeltaX, evt.mWheelDeltaY);
evt.mHandled = true; evt.mHandled = true;
} }
else else

View file

@ -2135,11 +2135,11 @@ namespace IDE.ui
} }
*/ */
public override void MouseWheel(float x, float y, float delta) public override void MouseWheel(float x, float y, float deltaX, float deltaY)
{ {
base.MouseWheel(x, y, delta); base.MouseWheel(x, y, deltaX, deltaY);
if (mInfiniteScrollbar != null) if (mInfiniteScrollbar != null)
mInfiniteScrollbar.MouseWheel(x, y, delta); mInfiniteScrollbar.MouseWheel(x, y, deltaX, deltaY);
} }
public void ResetPosition(int position) public void ResetPosition(int position)