Преглед на файлове

Fixing autoWidth setters on Control and Form.

Adam Blake преди 13 години
родител
ревизия
51af923531
променени са 4 файла, в които са добавени 53 реда и са изтрити 3 реда
  1. 10 2
      gameplay/src/Control.cpp
  2. 1 1
      gameplay/src/Control.h
  3. 28 0
      gameplay/src/Form.cpp
  4. 14 0
      gameplay/src/Form.h

+ 10 - 2
gameplay/src/Control.cpp

@@ -183,7 +183,11 @@ Control::Alignment Control::getAlignment() const
 
 
 void Control::setAutoWidth(bool autoWidth)
 void Control::setAutoWidth(bool autoWidth)
 {
 {
-    _autoWidth = autoWidth;
+    if (_autoWidth != autoWidth)
+    {
+        _autoWidth = autoWidth;
+        _dirty = true;
+    }
 }
 }
 
 
 bool Control::getAutoWidth() const
 bool Control::getAutoWidth() const
@@ -193,7 +197,11 @@ bool Control::getAutoWidth() const
 
 
 void Control::setAutoHeight(bool autoHeight)
 void Control::setAutoHeight(bool autoHeight)
 {
 {
-    _autoHeight = autoHeight;
+    if (_autoHeight != autoHeight)
+    {
+        _autoHeight = autoHeight;
+        _dirty = true;
+    }
 }
 }
 
 
 void Control::setOpacity(float opacity, unsigned char states)
 void Control::setOpacity(float opacity, unsigned char states)

+ 1 - 1
gameplay/src/Control.h

@@ -185,7 +185,7 @@ public:
      * @param x The x coordinate.
      * @param x The x coordinate.
      * @param y The y coordinate.
      * @param y The y coordinate.
      */
      */
-    virtual void setPosition(float x, float y);
+    void setPosition(float x, float y);
 
 
     /**
     /**
      * Set the desired size of this control, including its border and padding, before clipping.
      * Set the desired size of this control, including its border and padding, before clipping.

+ 28 - 0
gameplay/src/Form.cpp

@@ -186,6 +186,34 @@ void Form::setBounds(const Rectangle& bounds)
     setSize(bounds.width, bounds.height);
     setSize(bounds.width, bounds.height);
 }
 }
 
 
+void Form::setAutoWidth(bool autoWidth)
+{
+    if (_autoWidth != autoWidth)
+    {
+        _autoWidth = autoWidth;
+        _dirty = true;
+
+        if (_autoWidth)
+        {
+            setSize(_bounds.width, Game::getInstance()->getWidth());
+        }
+    }
+}
+
+void Form::setAutoHeight(bool autoHeight)
+{
+    if (_autoHeight != autoHeight)
+    {
+        _autoHeight = autoHeight;
+        _dirty = true;
+
+        if (_autoHeight)
+        {
+            setSize(_bounds.width, Game::getInstance()->getHeight());
+        }
+    }
+}
+
 void Form::setQuad(const Vector3& p1, const Vector3& p2, const Vector3& p3, const Vector3& p4)
 void Form::setQuad(const Vector3& p1, const Vector3& p2, const Vector3& p3, const Vector3& p4)
 {
 {
     Mesh* mesh = Mesh::createQuad(p1, p2, p3, p4);
     Mesh* mesh = Mesh::createQuad(p1, p2, p3, p4);

+ 14 - 0
gameplay/src/Form.h

@@ -82,6 +82,20 @@ public:
      */
      */
     virtual void setBounds(const Rectangle& bounds);
     virtual void setBounds(const Rectangle& bounds);
 
 
+    /**
+     * Set this form's width to that of the display.
+     *
+     * @param autoWidth Whether to set this form's width to that of the display.
+     */
+    virtual void setAutoWidth(bool autoWidth);
+
+    /**
+     * Set this form's height to that of the display.
+     *
+     * @param autoHeight Whether to set this form's height to that of the display.
+     */
+    virtual void setAutoHeight(bool autoHeight);
+
     /**
     /**
      * Create a 3D quad to texture with this Form.
      * Create a 3D quad to texture with this Form.
      *
      *