浏览代码

Update raygui.h

Ray 6 年之前
父节点
当前提交
08d31730f6
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/raygui.h

+ 7 - 1
src/raygui.h

@@ -727,6 +727,8 @@ RAYGUIDEF void GuiPanel(Rectangle bounds)
 // NOTE: bounds define the view area, content defines size of internal data
 RAYGUIDEF Vector2 GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 viewScroll)
 {
+    #define SCROLLPANEL_SCROLL_SPEED    20
+    
     GuiControlState state = guiState;
     
     bool useScrollBar = false;
@@ -744,7 +746,11 @@ RAYGUIDEF Vector2 GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 vi
             if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = GUI_STATE_PRESSED;
             else state = GUI_STATE_FOCUSED;
 
-            viewScroll.y += GetMouseWheelMove()*10;
+            viewScroll.y += GetMouseWheelMove()*SCROLLPANEL_SCROLL_SPEED;
+            
+            if (IsKeyDown(KEY_DOWN)) viewScroll.y -= SCROLLPANEL_SCROLL_SPEED;
+            if (IsKeyDown(KEY_UP)) viewScroll.y += SCROLLPANEL_SCROLL_SPEED;
+            
             if (viewScroll.y > 0) viewScroll.y = 0;
             if (viewScroll.y < (bounds.height - content.height)) viewScroll.y = bounds.height - content.height;
         }