소스 검색

Add horizontal scroll (#116)

Add horizontal scroll (Shift + Mouse wheel) for Scroll Panel control
Nomi 4 년 전
부모
커밋
b4288f969c
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 2
      src/raygui.h

+ 6 - 2
src/raygui.h

@@ -896,7 +896,11 @@ Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll)
                 if (IsKeyDown(KEY_UP)) scrollPos.y += GuiGetStyle(SCROLLBAR, SCROLL_SPEED);
             }
 
-            scrollPos.y += GetMouseWheelMove()*20;
+            int wheelMove = GetMouseWheelMove();
+
+            // Horizontal scroll (Shift + Mouse wheel)
+            if (hasHorizontalScrollBar && (IsKeyDown(KEY_LEFT_SHIFT) || IsKeyDown(KEY_RIGHT_SHIFT))) scrollPos.x += wheelMove*20;
+            else scrollPos.y += wheelMove*20; // Vertical scroll
         }
     }
 
@@ -3716,4 +3720,4 @@ static const char *CodepointToUtf8(int codepoint, int *byteLength)
 
 #if defined(__cplusplus)
 }            // Prevents name mangling of functions
-#endif
+#endif