Parcourir la source

Adding setChecked() to CheckBox.
Handling state changes on Slider.

Adam Blake il y a 13 ans
Parent
commit
0865ad5a08

+ 9 - 0
gameplay/src/CheckBox.cpp

@@ -34,6 +34,15 @@ bool CheckBox::isChecked()
     return _checked;
 }
 
+void CheckBox::setChecked(bool checked)
+{
+    if (_checked != checked)
+    {
+        _checked = checked;
+        notifyListeners(Control::Listener::VALUE_CHANGED);
+    }
+}
+
 void CheckBox::setImageSize(float width, float height)
 {
     _imageSize.set(width, height);

+ 2 - 0
gameplay/src/CheckBox.h

@@ -37,6 +37,8 @@ public:
      */
     bool isChecked();
 
+    void setChecked(bool checked);
+
     /**
      * Set the size to draw the checkbox icon.
      *

+ 6 - 0
gameplay/src/Slider.cpp

@@ -130,6 +130,12 @@ bool Slider::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contac
 
             _dirty = true;
         }
+
+        if (evt == Touch::TOUCH_RELEASE)
+        {
+            _state = NORMAL;
+        }
+        break;
     }
 
     return Control::touchEvent(evt, x, y, contactIndex);

+ 0 - 2
gameplay/src/VerticalLayout.cpp

@@ -44,9 +44,7 @@ namespace gameplay
     void VerticalLayout::update(const Container* container)
     {
         // Need border, padding.
-        //Theme::Style* style = container->getStyle();
         Theme::Border border = container->getBorder(container->getState());
-        //Theme::Padding padding = style->getPadding();
         Theme::Padding padding = container->getPadding();
 
         float yPosition = 0;