Sfoglia il codice sorgente

Smoother mouse wheel scrolling

Brian Fiete 5 anni fa
parent
commit
84aecbca81

+ 3 - 3
BeefLibs/Beefy2D/src/BFWindow.bf

@@ -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, int32 delta);
+        delegate void NativeMouseWheelDelegate(void* window, int32 x, int32 y, float delta);
         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, 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_NativeMenuItemSelectedDelegate(void* window, void* item) { GetBFWindow(window).NativeMenuItemSelected(item); }
 		#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)
         {
         }
 

+ 1 - 1
BeefLibs/Beefy2D/src/events/MouseEvent.bf

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

+ 1 - 1
BeefLibs/Beefy2D/src/theme/dark/DarkEditWidget.bf

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

+ 2 - 2
BeefLibs/Beefy2D/src/widgets/InfiniteScrollbar.bf

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

+ 1 - 1
BeefLibs/Beefy2D/src/widgets/ScrollableWidget.bf

@@ -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);
             if (mVertScrollbar != null)

+ 1 - 1
BeefLibs/Beefy2D/src/widgets/Scrollbar.bf

@@ -224,7 +224,7 @@ namespace Beefy.widgets
             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);
         }

+ 1 - 1
BeefLibs/Beefy2D/src/widgets/Widget.bf

@@ -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();
 

+ 1 - 1
BeefLibs/Beefy2D/src/widgets/WidgetWindow.bf

@@ -708,7 +708,7 @@ namespace Beefy.widgets
 			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 y;

+ 1 - 1
BeefySysLib/BFWindow.h

@@ -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, int delta);
+typedef void (*BFWindow_MouseWheel)(BFWindow* window, int x, int y, float delta);
 typedef void (*BFWindow_MouseLeave)(BFWindow* window);
 typedef void (*BFWindow_MenuItemSelectedFunc)(BFWindow* window, BFMenu* menu);
 

+ 7 - 2
BeefySysLib/platform/win/WinBFApp.cpp

@@ -634,11 +634,16 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
 										aWindow->mIsMouseInside = true;
 										cursorWindow = aWindow;
 									}									
-								}								
+								}
 								++itr;
 							}
 						}
 
+						UINT ucNumLines = 0;
+						SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &ucNumLines, 0);
+						if (ucNumLines == 0)
+							ucNumLines = 3; // Default
+
 						if ((cursorWindow != this) && (mIsMouseInside))
 						{
 							mMouseLeaveFunc(this);
@@ -648,7 +653,7 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
 						POINT pt = {x, y};
 						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);						
 					}
 					break;

+ 1 - 1
IDE/src/ui/BinaryDataWidget.bf

@@ -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);
             if (mInfiniteScrollbar != null)