Encapsulation and harmonizing operators for LayoutLength
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / layouting / measure-spec.h
index f766247..378464a 100644 (file)
  * limitations under the License.
  */
 
+// EXTERNAL INCLUDES
+#include <sstream>
 #include <dali/public-api/common/dali-common.h>
-#include <dali-toolkit/devel-api/layouting/layout-length.h>
 
-#include <sstream>
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/layouting/layout-length.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
 
 namespace Dali
 {
@@ -32,10 +35,9 @@ namespace Toolkit
  * how to be measured. For instance, it may measure a child with an exact width and an unspecified
  * height in order to determine height for width.
  */
-class DALI_IMPORT_API MeasureSpec
+class DALI_TOOLKIT_API MeasureSpec
 {
 public:
-  using IntType = LayoutLength::IntType;
 
   enum class Mode
   {
@@ -47,12 +49,12 @@ public:
   };
 
   MeasureSpec( LayoutLength measureSpec, MeasureSpec::Mode mode )
-  : mSize( measureSpec.mValue ),
+  : mSize( measureSpec ),
     mMode( mode )
   {
   }
 
-  MeasureSpec( IntType measureSpec )
+  MeasureSpec( LayoutLength measureSpec )
   : mSize( measureSpec ),
     mMode( Mode::UNSPECIFIED )
   {
@@ -62,8 +64,11 @@ public:
 
   MeasureSpec& operator=( const MeasureSpec& rhs )
   {
-    this->mSize = rhs.mSize;
-    this->mMode = rhs.mMode;
+    if( this != &rhs )
+    {
+      this->mSize = rhs.mSize;
+      this->mMode = rhs.mMode;
+    }
     return *this;
   }
 
@@ -78,6 +83,16 @@ public:
   }
 
   /**
+   * @brief Set the mode of the measure spec.
+   *
+   * @param mode The mode to set
+   */
+  void SetMode( MeasureSpec::Mode mode )
+  {
+    mMode = mode;
+  }
+
+  /**
    * @brief Get the mode of the measure spec.
    *
    * @return The mode of the measure spec
@@ -88,11 +103,21 @@ public:
   }
 
   /**
+   * @brief Set the size of the measure spec
+   *
+   * @param size the size to set
+   */
+  void SetSize( LayoutLength size )
+  {
+    mSize = size;
+  }
+
+  /**
    * @brief Get the size of the measure spec
    *
    * @return the size of the measure spec
    */
-  IntType GetSize() const
+  LayoutLength GetSize() const
   {
     return mSize;
   }
@@ -117,7 +142,7 @@ public:
       return MeasureSpec( size, MeasureSpec::Mode::UNSPECIFIED );
     }
 
-    if( delta < 0 && measureSpec.mSize < static_cast<IntType>(abs(delta)) )
+    if( delta < 0 && measureSpec.mSize < abs(delta) )
     {
       size = 0;
     }
@@ -128,9 +153,11 @@ public:
     return MeasureSpec( size, mode );
   }
 
-public:
-  IntType  mSize; ///< The specified size
+private:
+
+  LayoutLength  mSize; ///< The specified size
   Mode     mMode; ///< The measure mode
+
 };
 
 inline std::ostream& operator<< (std::ostream& o, const MeasureSpec& measureSpec )