OSDN Git Service

Committed again the same changes to with the Nates fixes.
authorIndiumIndeed <jarmo.kukkola@gmail.com>
Sat, 26 Jan 2013 16:55:22 +0000 (18:55 +0200)
committerIndiumIndeed <jarmo.kukkola@gmail.com>
Sat, 26 Jan 2013 16:55:22 +0000 (18:55 +0200)
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Slider.java

index ad844df..9530009 100644 (file)
@@ -139,6 +139,7 @@ public class Slider extends Widget {
                                sliderPos = Math.max(0, sliderPos);\r
                                sliderPos = Math.min(sliderPosHeight - knobHeight, sliderPos) + bg.getBottomHeight();\r
                        }\r
+\r
                        float knobHeightHalf = knobHeight * 0.5f;\r
                        if (knobBefore != null) {\r
                                knobBefore.draw(batch, x + (int)((width - knobBefore.getMinWidth()) * 0.5f), y, knobBefore.getMinWidth(),\r
@@ -158,6 +159,7 @@ public class Slider extends Widget {
                                sliderPos = Math.max(0, sliderPos);\r
                                sliderPos = Math.min(sliderPosWidth - knobWidth, sliderPos) + bg.getLeftWidth();\r
                        }\r
+\r
                        float knobHeightHalf = knobHeight * 0.5f;\r
                        if (knobBefore != null) {\r
                                knobBefore.draw(batch, x, y + (int)((height - knobBefore.getMinHeight()) * 0.5f), (int)(sliderPos + knobHeightHalf),\r
@@ -211,7 +213,7 @@ public class Slider extends Widget {
 \r
        /** If {@link #setAnimateDuration(float) animating} the slider value, this returns the value current displayed. */\r
        public float getVisualValue () {\r
-               if (animateTime > 0) return animateInterpolation.apply(animateFromValue, value, animateTime / animateDuration);\r
+               if (animateTime > 0) return animateInterpolation.apply(animateFromValue, value, 1 - animateTime / animateDuration);\r
                return value;\r
        }\r
 \r
@@ -221,13 +223,14 @@ public class Slider extends Widget {
                value = MathUtils.clamp(Math.round(value / stepSize) * stepSize, min, max);\r
                float oldValue = this.value;\r
                if (value == oldValue) return;\r
+               float oldVisualValue = getVisualValue();\r
                this.value = value;\r
                ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class);\r
                if (fire(changeEvent))\r
                        this.value = oldValue;\r
                else if (animateDuration > 0) {\r
+                       animateFromValue = oldVisualValue;\r
                        animateTime = animateDuration;\r
-                       animateFromValue = getVisualValue();\r
                }\r
                Pools.free(changeEvent);\r
        }\r
@@ -308,4 +311,4 @@ public class Slider extends Widget {
                        this.knob = style.knob;\r
                }\r
        }\r
-}\r
+}
\ No newline at end of file