Explorar el Código

Fixing slider math to handle negative values.
Fixing slider drawing to handle clipping.
Fixing a warning in theme.

Adam Blake hace 13 años
padre
commit
ca4c205d21
Se han modificado 4 ficheros con 8 adiciones y 15 borrados
  1. 6 6
      gameplay/src/Slider.cpp
  2. 1 1
      gameplay/src/Theme.cpp
  3. 1 1
      gameplay/src/Theme.h
  4. 0 7
      gameplay/src/VerticalLayout.cpp

+ 6 - 6
gameplay/src/Slider.cpp

@@ -113,7 +113,7 @@ bool Slider::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contac
             }
 
             float oldValue = _value;
-            _value = markerPosition * _max;
+            _value = (markerPosition * (_max - _min)) + _min;
             if (_step > 0.0f)
             {
                 float stepDistance = _step / (_max - _min);
@@ -169,21 +169,21 @@ void Slider::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
     // Draw order: track, caps, marker.
     float midY = clip.y + _bounds.y + (_bounds.height - border.bottom - padding.bottom) / 2.0f;
     Vector2 pos(clip.x + _bounds.x + border.left + padding.left, midY - trackRegion.height / 2.0f);
-    spriteBatch->draw(pos.x, pos.y, _bounds.width, trackRegion.height, track.u1, track.v1, track.u2, track.v2, trackColor);
+    spriteBatch->draw(pos.x, pos.y, _bounds.width, trackRegion.height, track.u1, track.v1, track.u2, track.v2, trackColor, _clip);
 
     pos.y = midY - minCapRegion.height * 0.5f;
     pos.x -= minCapRegion.width * 0.5f;
-    spriteBatch->draw(pos.x, pos.y, minCapRegion.width, minCapRegion.height, minCap.u1, minCap.v1, minCap.u2, minCap.v2, minCapColor);
+    spriteBatch->draw(pos.x, pos.y, minCapRegion.width, minCapRegion.height, minCap.u1, minCap.v1, minCap.u2, minCap.v2, minCapColor, _clip);
         
     pos.x = clip.x + _bounds.x + _bounds.width - border.right - padding.right - maxCapRegion.width * 0.5f;
-    spriteBatch->draw(pos.x, pos.y, maxCapRegion.width, maxCapRegion.height, maxCap.u1, maxCap.v1, maxCap.u2, maxCap.v2, maxCapColor);
+    spriteBatch->draw(pos.x, pos.y, maxCapRegion.width, maxCapRegion.height, maxCap.u1, maxCap.v1, maxCap.u2, maxCap.v2, maxCapColor, _clip);
 
     // Percent across.
-    float markerPosition = _value / (_max - _min);
+    float markerPosition = (_value + _max) / (_max - _min);
     markerPosition *= _bounds.width - border.left - padding.left - border.right - padding.right - minCapRegion.width * 0.5f - maxCapRegion.width * 0.5f - markerRegion.width;
     pos.x = clip.x + _bounds.x + border.left + padding.left + minCapRegion.width * 0.5f + markerPosition;
     pos.y = midY - markerRegion.height / 2.0f;
-    spriteBatch->draw(pos.x, pos.y, markerRegion.width, markerRegion.height, marker.u1, marker.v1, marker.u2, marker.v2, markerColor);
+    spriteBatch->draw(pos.x, pos.y, markerRegion.width, markerRegion.height, marker.u1, marker.v1, marker.u2, marker.v2, markerColor, _clip);
 }
 
 }

+ 1 - 1
gameplay/src/Theme.cpp

@@ -1061,7 +1061,7 @@ namespace gameplay
         _cursor->_color.set(color);
     }
 
-    const Theme::UVs Theme::Style::Overlay::getCursorUVs() const
+    const Theme::UVs& Theme::Style::Overlay::getCursorUVs() const
     {
         if (_cursor)
         {

+ 1 - 1
gameplay/src/Theme.h

@@ -422,7 +422,7 @@ public:
             const Vector4& getCursorColor() const;
             void setCursorColor(const Vector4& color);
 
-            const Theme::UVs getCursorUVs() const;
+            const Theme::UVs& getCursorUVs() const;
 
             /**
              * @see AnimationTarget#getAnimationPropertyComponentCount

+ 0 - 7
gameplay/src/VerticalLayout.cpp

@@ -46,13 +46,6 @@ namespace gameplay
         // Need border, padding.
         Theme::Style* style = container->getStyle();
         Theme::Border border = container->getBorder(container->getState());
-        /*
-        Theme::Skin* skin = style->getOverlay(container->getOverlayType())->getSkin();
-        if (skin)
-        {
-            border = skin->getBorder();
-        }
-        */
         Theme::Padding padding = style->getPadding();
 
         float yPosition = 0;