OSDN Git Service

Changed page scroll to mouse wheel.
authorNathanSweet <nathan.sweet@gmail.com>
Tue, 1 Oct 2013 06:48:52 +0000 (08:48 +0200)
committerNathanSweet <nathan.sweet@gmail.com>
Tue, 1 Oct 2013 06:48:52 +0000 (08:48 +0200)
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.java

index 8e621f2..d732fc8 100644 (file)
@@ -123,7 +123,7 @@ public class ScrollPane extends WidgetGroup {
                                                draggingPointer = pointer;\r
                                                return true;\r
                                        }\r
-                                       setScrollX(amountX + getPageScrollX() * (x < hKnobBounds.x ? -1 : 1));\r
+                                       setScrollX(amountX + areaWidth * (x < hKnobBounds.x ? -1 : 1));\r
                                        return true;\r
                                }\r
                                if (scrollY && vScrollBounds.contains(x, y)) {\r
@@ -136,7 +136,7 @@ public class ScrollPane extends WidgetGroup {
                                                draggingPointer = pointer;\r
                                                return true;\r
                                        }\r
-                                       setScrollY(amountY + getPageScrollY() * (y < vKnobBounds.y ? 1 : -1));\r
+                                       setScrollY(amountY + areaHeight * (y < vKnobBounds.y ? 1 : -1));\r
                                        return true;\r
                                }\r
                                return false;\r
@@ -212,9 +212,9 @@ public class ScrollPane extends WidgetGroup {
                        public boolean scrolled (InputEvent event, float x, float y, int amount) {\r
                                resetFade();\r
                                if (scrollY)\r
-                                       setScrollY(amountY + Math.max(areaHeight * 0.9f, maxY * 0.1f) / 4 * amount);\r
+                                       setScrollY(amountY + getMouseWheelY() * amount);\r
                                else if (scrollX) //\r
-                                       setScrollX(amountX + Math.max(areaWidth * 0.9f, maxX * 0.1f) / 4 * amount);\r
+                                       setScrollX(amountX + getMouseWheelX() * amount);\r
                                return true;\r
                        }\r
                });\r
@@ -647,14 +647,14 @@ public class ScrollPane extends WidgetGroup {
                this.visualAmountY = pixelsY;\r
        }\r
 \r
-       /** Returns the amount to scroll horizontally when the scrollbar is clicked. */\r
-       protected float getPageScrollX () {\r
-               return areaWidth;\r
+       /** Returns the amount to scroll horizontally when the mouse wheel is scrolled. */\r
+       protected float getMouseWheelX () {\r
+               return Math.max(areaWidth * 0.9f, maxX * 0.1f) / 4;\r
        }\r
 \r
-       /** Returns the amount to scroll vertically when the scrollbar is clicked. */\r
-       protected float getPageScrollY () {\r
-               return areaHeight;\r
+       /** Returns the amount to scroll vertically when the mouse wheel is scrolled. */\r
+       protected float getMouseWheelY () {\r
+               return Math.max(areaHeight * 0.9f, maxY * 0.1f) / 4;\r
        }\r
 \r
        public void setScrollX (float pixels) {\r