mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Horizontal scroll wheel support
This commit is contained in:
parent
a944aa6d24
commit
72242aa31c
11 changed files with 51 additions and 28 deletions
|
@ -125,7 +125,7 @@ namespace Beefy
|
|||
delegate void NativeMouseProxyMoveDelegate(void* window, int32 x, int32 y);
|
||||
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 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 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_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_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_NativeMenuItemSelectedDelegate(void* window, void* item) { GetBFWindow(window).NativeMenuItemSelected(item); }
|
||||
#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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ namespace Beefy.events
|
|||
public float mY;
|
||||
public int32 mBtn;
|
||||
public int32 mBtnCount;
|
||||
public float mWheelDelta;
|
||||
public float mWheelDeltaX;
|
||||
public float mWheelDeltaY;
|
||||
|
||||
public void GetRootCoords(out float x, out float y)
|
||||
{
|
||||
|
|
|
@ -238,8 +238,9 @@ namespace Beefy.widgets
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
if (mVertScrollbar != null)
|
||||
mVertScrollbar.MouseWheel(x, y, delta);
|
||||
else if (mHorzScrollbar != null)
|
||||
mHorzScrollbar.MouseWheel(x, y, delta);
|
||||
base.MouseWheel(x, y, deltaX, deltaY);
|
||||
if (deltaY != 0)
|
||||
{
|
||||
if (mVertScrollbar != null)
|
||||
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)
|
||||
|
|
|
@ -224,8 +224,9 @@ namespace Beefy.widgets
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
@ -722,7 +722,7 @@ namespace Beefy.widgets
|
|||
float aX;
|
||||
float aY;
|
||||
SelfToParentTranslate(x, y, out aX, out aY);
|
||||
mParent.MouseWheel(aX, aY, delta);
|
||||
mParent.MouseWheel(aX, aY, deltaX, deltaY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -740,7 +740,7 @@ namespace Beefy.widgets
|
|||
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 y;
|
||||
|
@ -753,7 +753,8 @@ namespace Beefy.widgets
|
|||
MouseEvent anEvent = scope MouseEvent();
|
||||
anEvent.mX = x;
|
||||
anEvent.mY = y;
|
||||
anEvent.mWheelDelta = delta;
|
||||
anEvent.mWheelDeltaX = deltaX;
|
||||
anEvent.mWheelDeltaY = deltaY;
|
||||
anEvent.mSender = this;
|
||||
sOnMouseWheel(anEvent);
|
||||
|
||||
|
@ -766,7 +767,8 @@ namespace Beefy.widgets
|
|||
MouseEvent anEvent = scope MouseEvent();
|
||||
anEvent.mX = x;
|
||||
anEvent.mY = y;
|
||||
anEvent.mWheelDelta = delta;
|
||||
anEvent.mWheelDeltaX = deltaX;
|
||||
anEvent.mWheelDeltaY = deltaY;
|
||||
anEvent.mSender = this;
|
||||
mOnMouseWheel(anEvent);
|
||||
|
||||
|
@ -780,7 +782,7 @@ namespace Beefy.widgets
|
|||
float childX;
|
||||
float childY;
|
||||
aWidget.RootToSelfTranslate(mMouseX, mMouseY, out childX, out childY);
|
||||
aWidget.MouseWheel(childX, childY, delta);
|
||||
aWidget.MouseWheel(childX, childY, deltaX, deltaY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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_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_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_MenuItemSelectedFunc)(BFWindow* window, BFMenu* menu);
|
||||
|
||||
|
|
|
@ -539,6 +539,7 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
case WM_MBUTTONUP:
|
||||
case WM_XBUTTONUP:
|
||||
case WM_MOUSEWHEEL:
|
||||
case WM_MOUSEHWHEEL:
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
int x = (short)LOWORD(lParam);
|
||||
|
@ -547,7 +548,7 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
bool releaseCapture = false;
|
||||
|
||||
POINT point = {x, y};
|
||||
if (uMsg != WM_MOUSEWHEEL)
|
||||
if ((uMsg != WM_MOUSEWHEEL) && (uMsg != WM_MOUSEHWHEEL))
|
||||
::ClientToScreen(hWnd, &point);
|
||||
|
||||
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);
|
||||
break;
|
||||
case WM_MOUSEWHEEL:
|
||||
case WM_MOUSEHWHEEL:
|
||||
{
|
||||
WinBFWindow* cursorWindow = this;
|
||||
|
||||
|
@ -666,9 +668,17 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
|
||||
POINT pt = {x, y};
|
||||
ScreenToClient(cursorWindow->mHWnd, &pt);
|
||||
|
||||
float delta = ((int16)HIWORD(wParam)) / 120.0f * (float)ucNumLines;
|
||||
mMouseWheelFunc(cursorWindow, pt.x, pt.y, delta);
|
||||
|
||||
if (uMsg == WM_MOUSEWHEEL)
|
||||
{
|
||||
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;
|
||||
case WM_MOUSEMOVE:
|
||||
|
|
|
@ -273,7 +273,7 @@ namespace IDE.ui
|
|||
let windowRect = Rect(mWidgetWindow.mX, mWidgetWindow.mY, mWidgetWindow.mWindowWidth, mWidgetWindow.mWindowHeight);
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -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)
|
||||
mInfiniteScrollbar.MouseWheel(x, y, delta);
|
||||
mInfiniteScrollbar.MouseWheel(x, y, deltaX, deltaY);
|
||||
}
|
||||
|
||||
public void ResetPosition(int position)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue