Encapsulation and harmonizing operators for LayoutLength 75/189675/5
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Wed, 19 Sep 2018 14:21:16 +0000 (15:21 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 20 Sep 2018 14:36:31 +0000 (15:36 +0100)
- changing internal type to float to maintain precision when doing multiplies and divisions

Change-Id: Ifedb450f56d6994c60aceb87d7ffc530739b57c9

15 files changed:
automated-tests/src/dali-toolkit/custom-layout-impl.cpp
automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp
dali-toolkit/devel-api/layouting/layout-group-impl.cpp
dali-toolkit/devel-api/layouting/layout-item-impl.cpp
dali-toolkit/devel-api/layouting/layout-length.h
dali-toolkit/devel-api/layouting/layout-size.h
dali-toolkit/devel-api/layouting/measure-spec.h
dali-toolkit/devel-api/layouting/measured-size.h
dali-toolkit/internal/layouting/absolute-layout-impl.cpp
dali-toolkit/internal/layouting/flex-layout-impl.cpp
dali-toolkit/internal/layouting/grid-impl.cpp
dali-toolkit/internal/layouting/grid-impl.h
dali-toolkit/internal/layouting/layout-controller-impl.cpp
dali-toolkit/internal/layouting/layout-item-data-impl.cpp
dali-toolkit/internal/layouting/linear-layout-impl.cpp

index 30ebc29..37b6936 100644 (file)
@@ -119,7 +119,7 @@ void CustomLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top,
       LayoutLength childWidth = childLayoutImpl.GetMeasuredWidth();
       LayoutLength childHeight = childLayoutImpl.GetMeasuredHeight();
 
-      childTop = middle - (childHeight / 2);
+      childTop = middle - childHeight / 2;
       childLayoutImpl.Layout( currentLeft, childTop, currentLeft + childWidth, childTop + childHeight );
       currentLeft += childWidth;
     }
index 6e8cc16..f0540f4 100644 (file)
@@ -70,6 +70,246 @@ void utc_dali_toolkit_layouting_cleanup(void)
   test_return_value = TET_PASS;
 }
 
+int UtcDaliLayouting_LayoutLength_Types(void)
+{
+  tet_infoline("UtcDaliLayouting_LayoutLength Types");
+
+  // testing that operators return correct type
+  // operator+
+  {
+    auto value = LayoutLength( 10 ) + LayoutLength();
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = LayoutLength( 10 ) + 20;
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = 22 + LayoutLength( 10 );
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = LayoutLength( 10 ) + 2.1f;
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = 2.2f + LayoutLength( 10 );
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  // operator-
+  {
+    auto value = LayoutLength() - LayoutLength( 10 );
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = LayoutLength( 10 ) - 99;
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = 20 - LayoutLength( 10 );
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = LayoutLength( 10 ) - 9.9f;
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = 2.0f - LayoutLength( 10 );
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+
+  // operator*
+  {
+    auto value = LayoutLength() * LayoutLength( 10 );
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = LayoutLength( 10 ) * 2;
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = 10 * LayoutLength( 10 );
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = LayoutLength( 10 ) * 2.1f;
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = 1.0f * LayoutLength( 10 );
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  // operator/
+  {
+    auto value = LayoutLength( 10 ) / 2.0f;
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+
+  // combinations
+  {
+    auto value = ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+  {
+    auto value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
+    DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+  }
+
+  END_TEST;
+}
+
+int UtcDaliLayouting_LayoutLength_Values(void)
+{
+  tet_infoline("UtcDaliLayouting_LayoutLength Values");
+
+  // operator+
+  {
+    LayoutLength value = LayoutLength( 10 ) + LayoutLength();
+    DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    LayoutLength value = LayoutLength( 10 ) + 20;
+    DALI_TEST_EQUALS( value.AsInteger(), 30.0f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    LayoutLength value = 22 - LayoutLength( 10 );
+    DALI_TEST_EQUALS( value.AsInteger(), 12.0f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    LayoutLength value = LayoutLength( 10 ) + 2.1f;
+    DALI_TEST_EQUALS( value.AsDecimal(), 12.1f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsTruncated(), 12.0f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    LayoutLength value = 2.3f - LayoutLength( 10 );
+    DALI_TEST_EQUALS( value.AsDecimal(), -7.7f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsInteger(), -8.0f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsTruncated(), -7.0f, 0.0001f, TEST_LOCATION );
+  }
+  // operator-
+  {
+    LayoutLength value = LayoutLength() - LayoutLength( 10 );
+    DALI_TEST_EQUALS( value.AsInteger(), -10.0f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    LayoutLength value = LayoutLength( 10 ) - 99;
+    DALI_TEST_EQUALS( value.AsInteger(), -89.0f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    LayoutLength value = 20 - LayoutLength( 10 );
+    DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsTruncated(), 10.f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    LayoutLength value = LayoutLength( 10 ) - 9.9f;
+    DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsDecimal(), 0.1f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    LayoutLength value = 10.9f - LayoutLength( 10 );
+    DALI_TEST_EQUALS( value.AsInteger(), 1.0f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsDecimal(), 0.9f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION );
+  }
+  // operator*
+  {
+    LayoutLength value = LayoutLength() * LayoutLength( 10 );
+    DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    LayoutLength value = LayoutLength(1) * 10;
+    DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    LayoutLength value = 11 * LayoutLength( 10 );
+    DALI_TEST_EQUALS( value.AsInteger(), 110.0f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    LayoutLength value = LayoutLength( 10 ) * 2.12f;
+    DALI_TEST_EQUALS( value.AsDecimal(), 21.2f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsInteger(), 21.0f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    LayoutLength value = 2.189f * LayoutLength( 10 );
+    DALI_TEST_EQUALS( value.AsDecimal(), 21.89f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsInteger(), 22.0f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION );
+  }
+  // operator/
+  {
+    LayoutLength value = LayoutLength( 11 ) / 2.0f;
+    DALI_TEST_EQUALS( value.AsDecimal(), 5.5f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsInteger(), 6.0f, 0.0001f, TEST_LOCATION );
+  }
+
+  // combinations
+  {
+    LayoutLength value;
+    value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
+    DALI_TEST_EQUALS( value.AsInteger(), 33.0f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsDecimal(), 33.3333f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    uint16_t padding( 1 );
+    LayoutLength right(35), left(10), mTotalLength(2);
+    LayoutLength value;
+    value = padding + ( right - left - mTotalLength ) / 2.0f;
+    //    = 1 + ( 35 - 10 - 2 ) / 2
+    DALI_TEST_EQUALS( value.AsInteger(), 13.0f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsDecimal(), 12.5f, 0.0001f, TEST_LOCATION );
+  }
+  {
+    uint16_t padding = 1, top = 2, bottom = 3;
+    LayoutLength childSpace( 44 ), childHeight( 23 );
+    LayoutLength value;
+    value = padding + ( ( childSpace - childHeight ) / 2.0f ) + top - bottom;
+    //    = 1       + ( ( 44 - 23                  ) / 2 ) + 2 - 3
+    DALI_TEST_EQUALS( value.AsInteger(), 11.0f, 0.0001f, TEST_LOCATION );
+    DALI_TEST_EQUALS( value.AsDecimal(), 10.5f, 0.0001f, TEST_LOCATION );
+  }
+
+  END_TEST;
+}
+
+int UtcDaliLayouting_LayoutLength_Operators(void)
+{
+  tet_infoline("UtcDaliLayouting_LayoutLength operators");
+
+  {
+    LayoutLength value = 10;
+    DALI_TEST_EQUALS( (int)value.AsInteger(), 10, TEST_LOCATION );
+    value += 1;
+    DALI_TEST_EQUALS( (int)value.AsInteger(), 11, TEST_LOCATION );
+    value -= 12;
+    DALI_TEST_EQUALS( (int)value.AsInteger(), -1, TEST_LOCATION );
+    LayoutLength value2 = value;
+    DALI_TEST_EQUALS( value == value2, true, TEST_LOCATION );
+    value2 = 123;
+    DALI_TEST_EQUALS( value != value2, true, TEST_LOCATION );
+    DALI_TEST_EQUALS( value < value2, true, TEST_LOCATION );
+    DALI_TEST_EQUALS( value <= value2, true, TEST_LOCATION );
+    value = 456;
+    DALI_TEST_EQUALS( value > value2, true, TEST_LOCATION );
+    DALI_TEST_EQUALS( value >= value2, true, TEST_LOCATION );
+  }
+
+  {
+    LayoutLength value( 123 );
+    std::stringstream ss;
+    ss << value;
+    DALI_TEST_EQUALS( ss.str(), "123", TEST_LOCATION );
+  }
+  {
+    LayoutLength value( 0.123f );
+    std::stringstream ss;
+    ss << value;
+    DALI_TEST_EQUALS( ss.str(), "0.123", TEST_LOCATION );
+  }
+  END_TEST;
+}
+
 int UtcDaliLayouting_HboxLayout01(void)
 {
   ToolkitTestApplication application;
index 4354909..856ca18 100644 (file)
@@ -288,7 +288,7 @@ void LayoutGroup::DoRegisterChildProperties( const std::string& containerType )
 
 void LayoutGroup::OnSetChildProperties( Handle& handle, Property::Index index, Property::Value value )
 {
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnSetChildProperties property(%s)\n", handle.GetPropertyName(index).c_str());
+  DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::OnSetChildProperties property(" << handle.GetPropertyName(index) << ")\n" );
 
   if ( ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) &&
          ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) )
@@ -489,7 +489,7 @@ MeasureSpec LayoutGroup::GetChildMeasureSpec(
     }
   }
 
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec resultSize(%u)\n", resultSize.mValue );
+  DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec resultSize(" << resultSize << ")\n" );
 
   //noinspection ResourceType
   return MeasureSpec( resultSize, resultMode );
@@ -601,10 +601,8 @@ void LayoutGroup::ChildAddedToOwner( Actor child )
       }
       childLayout->SetAnimateLayout( IsLayoutAnimated() ); // @todo this essentially forces animation inheritance. Bad?
 
-      DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner control:" <<  control.GetName().c_str() <<
-                       " desiredWidth: " <<  control.GetNaturalSize().width <<
-                       " desiredHeight:"  << control.GetNaturalSize().height
-                       );
+      DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner control:" <<  control.GetName() <<
+                       " desiredWidth: " <<  control.GetNaturalSize().width << " desiredHeight:"  << control.GetNaturalSize().height );
 
       childControlDataImpl.SetLayout( *childLayout.Get() );
 
@@ -757,14 +755,14 @@ void LayoutGroup::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMea
 
         // Get size of child
         MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
-        auto childWidth = childLayout->GetMeasuredWidth();
-        auto childHeight = childLayout->GetMeasuredHeight();
-        auto childMargin = childLayout->GetMargin();
-        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure child width[%d] height(%d)\n", childWidth.mValue, childHeight.mValue );
+        LayoutLength childWidth = childLayout->GetMeasuredWidth();
+        LayoutLength childHeight = childLayout->GetMeasuredHeight();
+        Extents childMargin = childLayout->GetMargin();
+        DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure child width[" << childWidth << "] height[" << childHeight << "]\n" );
 
         layoutWidth = std::max( layoutWidth, childWidth + childMargin.start + childMargin.end );
         layoutHeight = std::max( layoutHeight, childHeight + childMargin.top + childMargin.bottom );
-        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure calculated child width[%d] calculated height(%d)\n", layoutWidth.mValue, layoutHeight.mValue );
+        DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure calculated child width[" << layoutWidth << "] height[" << layoutHeight << "]\n" );
       }
       else
       {
@@ -817,7 +815,7 @@ void LayoutGroup::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMea
     layoutHeight = heightSpecSize;
   }
 
-  DALI_LOG_INFO( gLogFilter, Debug::General, "LayoutGroup::OnMeasure Measured size(%d,%d) for : %s \n", layoutWidth.mValue, layoutHeight.mValue, Actor::DownCast(GetOwner()).GetName().c_str() );
+  DALI_LOG_STREAM( gLogFilter, Debug::General, "LayoutGroup::OnMeasure Measured size(" << layoutWidth << "," << layoutHeight << ") for : " << Actor::DownCast(GetOwner()).GetName() << " \n" );
   SetMeasuredDimensions( MeasuredSize( layoutWidth ), MeasuredSize( layoutHeight ) );
 }
 
@@ -834,20 +832,17 @@ void LayoutGroup::OnLayout( bool changed, LayoutLength left, LayoutLength top, L
     {
 
       auto childOwner = childLayout->GetOwner();
-      auto childWidth = childLayout->GetMeasuredWidth();
-      auto childHeight = childLayout->GetMeasuredHeight();
-      auto childMargin = childLayout->GetMargin();
+      LayoutLength childWidth = childLayout->GetMeasuredWidth();
+      LayoutLength childHeight = childLayout->GetMeasuredHeight();
+      Extents childMargin = childLayout->GetMargin();
       auto control = Toolkit::Control::DownCast( childOwner );
       Extents padding = GetPadding();
 
       auto childPosition = control.GetProperty< Vector3 >( Actor::Property::POSITION );
       auto anchorPoint = control.GetProperty< Vector3 >( Actor::Property::ANCHOR_POINT );
 
-      DALI_LOG_INFO( gLogFilter, Debug::General, "LayoutGroup::OnLayout child[%s] position(%f,%f) child width[%d] height(%d)\n",
-                      control.GetName().c_str(),
-                      childPosition.x, childPosition.y,
-                      childWidth.mValue, childHeight.mValue
-                      );
+      DALI_LOG_STREAM( gLogFilter, Debug::General, "LayoutGroup::OnLayout child[" << control.GetName() <<
+                       "] position(" << childPosition << ") child width[" << childWidth << "] height[" << childHeight << "]\n" );
 
       // Margin and Padding only supported when child anchor point is TOP_LEFT.
       int paddingAndMarginOffsetX = ( AnchorPoint::TOP_LEFT == anchorPoint ) ? ( padding.top + childMargin.top ) : 0;
index 35b9997..78cd532 100644 (file)
@@ -346,8 +346,7 @@ void LayoutItem::SetLayoutRequested()
 
 void LayoutItem::SetMeasuredDimensions( MeasuredSize measuredWidth, MeasuredSize measuredHeight )
 {
-  DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetMeasuredDimensions width(%d) height(%d) \n",
-                                                 measuredWidth.GetSize().mValue, measuredHeight.GetSize().mValue );
+  DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetMeasuredDimensions width(" << measuredWidth.GetSize() << ") height(" << measuredHeight.GetSize() << ") \n" );
 
   mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET );
   mImpl->mMeasuredWidth = measuredWidth;
@@ -381,7 +380,7 @@ LayoutLength LayoutItem::GetSuggestedMinimumWidth() const
   auto actor = Actor::DownCast(owner);
   auto naturalSize = actor ? actor.GetNaturalSize() : Vector3::ZERO;
 
-  return std::max( mImpl->mMinimumSize.GetWidth(), LayoutLength::IntType( naturalSize.width ) );
+  return std::max( mImpl->mMinimumSize.GetWidth(), LayoutLength( naturalSize.width ) );
 }
 
 LayoutLength LayoutItem::GetSuggestedMinimumHeight() const
@@ -390,7 +389,7 @@ LayoutLength LayoutItem::GetSuggestedMinimumHeight() const
   auto actor = Actor::DownCast(owner);
   auto naturalSize = actor ? actor.GetNaturalSize() : Vector3::ZERO;
 
-  return std::max( mImpl->mMinimumSize.GetHeight(), LayoutLength::IntType(naturalSize.height) );
+  return std::max( mImpl->mMinimumSize.GetHeight(), LayoutLength( naturalSize.height ) );
 }
 
 MeasuredSize LayoutItem::ResolveSizeAndState( LayoutLength size, MeasureSpec measureSpec, MeasuredSize::State childMeasuredState )
@@ -437,7 +436,7 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig
 {
   bool changed = false;
 
-  DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame enter(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue );
+  DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame enter(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" );
 
   if( mImpl->mLeft != left || mImpl->mRight != right || mImpl->mTop != top || mImpl->mBottom != bottom || !mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ) )
   {
@@ -462,16 +461,16 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig
     auto actor = Actor::DownCast(owner);
     if( actor )
     {
-      DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame owner(%s) (%d, %d, %d, %d)\n",  actor.GetName().c_str(),
-                                    left.mValue, top.mValue, right.mValue, bottom.mValue );
+      DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame owner(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" );
+
       if( mImpl->mAnimated )
       {
         auto animation = Animation::New( 0.5f );
-        animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), left.AsFloat() );
-        animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), top.AsFloat() );
+        animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), left.AsInteger() );
+        animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), top.AsInteger() );
 
-        animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), newWidth.AsFloat() );
-        animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), newHeight.AsFloat() );
+        animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), newWidth.AsInteger() );
+        animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), newHeight.AsInteger() );
 
         animation.FinishedSignal().Connect( mSlotDelegate, &LayoutItem::OnLayoutAnimationFinished );
         animation.Play();
@@ -479,10 +478,10 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig
       else
       {
         // @todo Collate into list of Property & Property::Value pairs.
-        actor.SetX( left.AsFloat() );
-        actor.SetY( top.AsFloat() );
-        actor.SetProperty( Actor::Property::SIZE_WIDTH, newWidth.AsFloat() );
-        actor.SetProperty( Actor::Property::SIZE_HEIGHT, newHeight.AsFloat() );
+        actor.SetX( left.AsInteger() );
+        actor.SetY( top.AsInteger() );
+        actor.SetProperty( Actor::Property::SIZE_WIDTH, newWidth.AsInteger() );
+        actor.SetProperty( Actor::Property::SIZE_HEIGHT, newHeight.AsInteger() );
       }
     }
 
@@ -492,7 +491,7 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig
     }
   }
 
-  DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame  exit(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue );
+  DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame  exit(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" );
 
   return changed;
 }
@@ -503,7 +502,7 @@ void LayoutItem::OnLayoutAnimationFinished( Animation& animation )
   auto actor = Actor::DownCast(owner);
   if( actor )
   {
-    actor.SetSize( Vector3( mImpl->mRight.AsFloat() - mImpl->mLeft.AsFloat(), mImpl->mBottom.AsFloat() - mImpl->mTop.AsFloat(), 0.0f ) );
+    actor.SetSize( Vector3( mImpl->mRight.AsInteger() - mImpl->mLeft.AsInteger(), mImpl->mBottom.AsInteger() - mImpl->mTop.AsInteger(), 0.0f ) );
   }
 }
 
index 73c9b96..6004b77 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+// EXTERNAL INCLUDES
 #include <cstdint>
+#include <cmath>
 #include <iostream>
 
 namespace Dali
 {
+
 namespace Toolkit
 {
 
 /**
  * @brief A type that represents a layout length.
  *
- * Currently, this implies pixels, but could be extended to handle device dependant sizes, etc.
+ * Currently, this implies pixels, but could be extended to handle device dependent sizes, etc.
  */
 class LayoutLength
 {
 public:
-  using IntType = int;
 
+  /**
+   * @brief default constructor, initialises to 0
+   */
   LayoutLength()
   : mValue( 0 )
   {
   }
 
-  LayoutLength( IntType value )
+  /**
+   * @brief constructor
+   *
+   * @param value the value to initialise with
+   */
+  LayoutLength( int value )
   : mValue( value )
   {
   }
 
+  /**
+   * @brief constructor from float
+   *
+   * @param value the value to initialise with
+   */
+  LayoutLength( float value )
+  : mValue( value )
+  {
+  }
+
+  /**
+   * @brief constructor
+   *
+   * @param layoutLength the value to initialise with
+   */
   LayoutLength( const LayoutLength& layoutLength )
   : mValue( layoutLength.mValue )
   {
   }
 
-  LayoutLength& operator=(const LayoutLength& rhs)
+  /**
+   * @brief assignment operator
+   *
+   * @param rhs LayoutLength to assign
+   * @return reference to itself
+   */
+  LayoutLength& operator=( const LayoutLength& rhs )
   {
     if( this != &rhs )
     {
@@ -58,131 +90,219 @@ public:
     return *this;
   }
 
-  bool operator==( const LayoutLength& rhs )
+  /**
+   * @brief assignment operator from int
+   *
+   * @param value the value to assign
+   * @return reference to itself
+   */
+  LayoutLength& operator=( int value )
   {
-    return mValue == rhs.mValue;
+    mValue = value;
+    return *this;
   }
 
-  bool operator==( LayoutLength::IntType rhs )
+  /**
+   * @brief assignment operator from float
+   *
+   * @param value the value to assign
+   * @return reference to itself
+   */
+  LayoutLength& operator=( float value )
   {
-    return mValue == rhs;
+    mValue = value;
+    return *this;
   }
 
-  bool operator!=( const LayoutLength& rhs )
+  /**
+   * @brief plus equals operator
+   *
+   * @param rhs to add to this
+   * @return reference to itself
+   */
+  LayoutLength& operator+=( LayoutLength rhs )
   {
-    return !operator==(rhs);
+    mValue += rhs.mValue;
+    return *this;
   }
 
-  bool operator<( const LayoutLength& rhs )
+  /**
+   * @brief minus equals operator
+   *
+   * @param rhs to subtract from this
+   * @return reference to itself
+   */
+  LayoutLength& operator-=( LayoutLength rhs )
   {
-    return mValue < rhs.mValue;
+    mValue -= rhs.mValue;
+    return *this;
   }
 
-  bool operator<( const LayoutLength rhs ) const
+  /**
+   * @brief return value as decimal value (full raw value)
+   *
+   * @return the LayoutLength as full decimal value
+   */
+  float AsDecimal() const
   {
-    return mValue < rhs.mValue;
+    return mValue;
   }
 
-  bool operator<=( const LayoutLength& rhs )
-  {
-    return mValue <= rhs.mValue;
-  }
-  bool operator<=( LayoutLength rhs )
-  {
-    return mValue <= rhs.mValue;
-  }
-  bool operator>( const LayoutLength& rhs )
-  {
-    return mValue > rhs.mValue;
-  }
-  bool operator>( LayoutLength rhs )
-  {
-    return mValue > rhs.mValue;
-  }
-  bool operator>=( const LayoutLength& rhs )
-  {
-    return mValue >= rhs.mValue;
-  }
-  bool operator>=( LayoutLength rhs )
+  /**
+   * @brief return value as rounded integer value (whole number)
+   *
+   * @return the LayoutLength rounded to next integer value
+   */
+  float AsInteger() const
   {
-    return mValue >= rhs.mValue;
+    return round( mValue );
   }
 
-  LayoutLength operator+( const LayoutLength& rhs )
+  /**
+   * @brief return value as truncated integral value (whole number)
+   *
+   * @return the LayoutLength rounded to next integral value
+   */
+  float AsTruncated() const
   {
-    return mValue + rhs.mValue;
+    return trunc( mValue );
   }
 
-  LayoutLength operator+( LayoutLength::IntType rhs )
-  {
-    return mValue + rhs;
-  }
+private:
 
-  LayoutLength operator-( const LayoutLength& rhs )
-  {
-    return mValue - rhs.mValue;
-  }
-  LayoutLength operator-( LayoutLength::IntType rhs )
-  {
-    return mValue - rhs;
-  }
+  float mValue;
 
-  LayoutLength& operator+=( const LayoutLength& rhs )
-  {
-    mValue += rhs.mValue;
-    return *this;
-  }
-  LayoutLength& operator+=( LayoutLength::IntType rhs )
-  {
-    mValue += rhs;
-    return *this;
-  }
+};
 
-  LayoutLength& operator-=( const LayoutLength& rhs )
-  {
-    mValue -= rhs.mValue;
-    return *this;
-  }
+/**
+ * @brief equal to operator
+ *
+ * @param lhs value to compare
+ * @param rhs value to compare against
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return true if identical, false otherwise
+ */
+inline bool operator==( LayoutLength lhs, LayoutLength rhs )
+{
+  return lhs.AsDecimal() == rhs.AsDecimal();
+}
 
-  LayoutLength& operator-=( LayoutLength::IntType rhs )
-  {
-    mValue -= rhs;
-    return *this;
-  }
+/**
+ * @brief not equal to operator
+ *
+ * @param lhs value to compare
+ * @param rhs value to compare against
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return true if value is not identical, false otherwise
+ */
+inline bool operator!=( LayoutLength lhs, LayoutLength rhs )
+{
+  return !operator==( lhs, rhs );
+}
 
-  LayoutLength operator/( const LayoutLength& rhs )
-  {
-    return mValue / rhs.mValue;
-  }
-  LayoutLength operator/(  LayoutLength::IntType rhs )
-  {
-    return mValue / rhs;
-  }
+/**
+ * @brief less than operator
+ *
+ * @param lhs value to compare
+ * @param rhs value to compare against
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return true if lhs value is less, false otherwise
+ */
+inline bool operator<( LayoutLength lhs, LayoutLength rhs )
+{
+  return lhs.AsDecimal() < rhs.AsDecimal();
+}
 
-  LayoutLength operator*( const LayoutLength& rhs )
-  {
-    return mValue * rhs.mValue;
-  }
-  LayoutLength operator*( LayoutLength::IntType rhs )
-  {
-    return mValue * rhs;
-  }
-  LayoutLength operator*( float rhs )
-  {
-    return LayoutLength(LayoutLength::IntType(AsFloat() * rhs));
-  }
+/**
+ * @brief greater than operator
+ *
+ * @param lhs value to compare
+ * @param rhs value to compare against
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return true if lhs value is greater, false otherwise
+ */
+inline bool operator>( LayoutLength lhs, LayoutLength rhs )
+{
+  return rhs < lhs;
+}
 
-  /**
-   * @brief explicit method to return the value as float
-   * @return the LayoutLength as float
-   */
-  float AsFloat() const
-  {
-    return static_cast<float>( mValue );
-  }
+/**
+ * @brief less than or equal to operator
+ *
+ * @param lhs value to compare
+ * @param rhs value to compare against
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return true if lhs value is less than or equal to, false otherwise
+ */
+inline bool operator<=( LayoutLength lhs, LayoutLength rhs )
+{
+  return !(lhs > rhs);
+}
 
-  IntType mValue;
-};
+/**
+ * @brief greater than or equal to operator
+ *
+ * @param lhs value to compare
+ * @param rhs value to compare against
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return true if lhs value is greater than or equal to, false otherwise
+ */
+inline bool operator>=( LayoutLength lhs, LayoutLength rhs )
+{
+  return !(lhs < rhs);
+}
+
+/**
+ * @brief add two LayoutLengths
+ *
+ * @param lhs The LayoutLength to add
+ * @param rhs The LayoutLength to add
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return the resulting LayoutLength
+ */
+inline LayoutLength operator+( LayoutLength lhs, LayoutLength rhs )
+{
+  return lhs.AsDecimal() + rhs.AsDecimal();
+}
+
+/**
+ * @brief subtract two LayoutLengths
+ *
+ * @param lhs The LayoutLength to subtract from
+ * @param rhs The LayoutLength to subtract
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return the resulting LayoutLength
+ */
+inline LayoutLength operator-( LayoutLength lhs, LayoutLength rhs )
+{
+  return lhs.AsDecimal() - rhs.AsDecimal();
+}
+
+/**
+ * @brief multiply two LayoutLengths
+ *
+ * @param lhs The LayoutLength to multiply
+ * @param rhs The LayoutLength to multiply
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return the resulting LayoutLength
+ */
+inline LayoutLength operator*( LayoutLength lhs, LayoutLength rhs )
+{
+  return lhs.AsDecimal() * rhs.AsDecimal();
+}
+
+/**
+ * @brief divide LayoutLength by a LayoutLength
+ *
+ * @param lhs The LayoutLength to divide
+ * @param rhs The LayoutLength to divide by
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return the resulting value as float
+ */
+inline LayoutLength operator/( LayoutLength lhs, LayoutLength rhs )
+{
+  return lhs.AsDecimal() / rhs.AsDecimal();
+}
 
 /**
  * @brief Prints a LayoutLength
@@ -193,7 +313,7 @@ public:
  */
 inline std::ostream& operator<<( std::ostream& o, const LayoutLength& layoutLength )
 {
-  return o<<layoutLength.mValue;
+  return o << layoutLength.AsDecimal();
 }
 
 } // namespace Toolkit
index b4802b3..d025ea7 100644 (file)
@@ -31,23 +31,17 @@ class LayoutSize
 {
 public:
   LayoutSize()
-  : x(0u),
-    y(0u)
+  : x( 0 ),
+    y( 0 )
   {
   }
 
-  LayoutSize( LayoutLength::IntType anX, LayoutLength::IntType aY )
+  LayoutSize( LayoutLength anX, LayoutLength aY )
   : x( anX ),
     y( aY )
   {
   }
 
-  LayoutSize( LayoutLength anX, LayoutLength aY )
-  : x( anX.mValue ),
-    y( aY.mValue )
-  {
-  }
-
   LayoutSize( const LayoutSize& layoutSize )
   : x( layoutSize.x ),
     y( layoutSize.y )
@@ -61,31 +55,24 @@ public:
     return *this;
   }
 
-  LayoutLength::IntType GetWidth()
+  void SetWidth( LayoutLength value )
   {
-    return width;
+    width = value;
   }
 
-  LayoutLength::IntType GetHeight()
+  LayoutLength GetWidth()
   {
-    return height;
+    return width;
   }
 
-  void SetWidth(LayoutLength::IntType value)
-  {
-    width=value;
-  }
-  void SetHeight(LayoutLength::IntType value)
+  void SetHeight( LayoutLength value )
   {
-    height=value;
+    height = value;
   }
-  void SetWidth(LayoutLength value)
-  {
-    width=value.mValue;
-  }
-  void SetHeight(LayoutLength value)
+
+  LayoutLength GetHeight()
   {
-    height=value.mValue;
+    return height;
   }
 
   bool operator==( const LayoutSize& rhs )
@@ -100,14 +87,14 @@ public:
 
   union
   {
-    LayoutLength::IntType x;
-    LayoutLength::IntType width;
+    LayoutLength x;
+    LayoutLength width;
   };
 
   union
   {
-    LayoutLength::IntType y;
-    LayoutLength::IntType height;
+    LayoutLength y;
+    LayoutLength height;
   };
 };
 
index 2925724..378464a 100644 (file)
  * limitations under the License.
  */
 
+// EXTERNAL INCLUDES
+#include <sstream>
 #include <dali/public-api/common/dali-common.h>
+
+// INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/layouting/layout-length.h>
 #include <dali-toolkit/public-api/dali-toolkit-common.h>
 
-#include <sstream>
-
 namespace Dali
 {
 namespace Toolkit
index 4acdd70..f04be0a 100644 (file)
@@ -40,7 +40,7 @@ public:
   };
 
   MeasuredSize()
-  : mMeasuredSize( 0u ),
+  : mMeasuredSize( 0 ),
     mState ( MeasuredSize::State::MEASURED_SIZE_OK )
   {
   }
@@ -69,7 +69,7 @@ public:
     return *this;
   }
 
-  MeasuredSize& operator=( LayoutLength::IntType rhs )
+  MeasuredSize& operator=( LayoutLength rhs )
   {
     this->mMeasuredSize = rhs;
     this->mState = State::MEASURED_SIZE_OK;
@@ -86,11 +86,6 @@ public:
     return mMeasuredSize != value.mMeasuredSize;
   }
 
-  inline operator LayoutLength::IntType()
-  {
-    return mMeasuredSize.mValue;
-  }
-
   inline void SetState( MeasuredSize::State state )
   {
     mState = state;
index 4cba410..8a635af 100644 (file)
@@ -111,7 +111,7 @@ void AbsoluteLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec height
       // Store current width and height needed to contain all children.
       totalWidth = maxPositionX - minPositionX;
       totalHeight = maxPositionY - minPositionY;
-      DALI_LOG_INFO( gLogFilter, Debug::Concise, "AbsoluteLayout::OnMeasure child width(%f) height(%f) \n", totalWidth.AsFloat(), totalHeight.AsFloat() );
+      DALI_LOG_INFO( gLogFilter, Debug::Concise, "AbsoluteLayout::OnMeasure child width(%f) height(%f) \n", totalWidth.AsDecimal(), totalHeight.AsDecimal() );
 
       if( childLayout->GetMeasuredWidthAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL )
       {
@@ -162,11 +162,9 @@ void AbsoluteLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top
       LayoutLength childTop = childPosition.y;
       LayoutLength childLeft = childPosition.x;
 
-      DALI_LOG_INFO( gLogFilter, Debug::General, "AbsoluteLayout::OnLayout child[%s] position(%f,%f) child width[%d] height(%d)\n",
-                      Toolkit::Control::DownCast( childOwner ).GetName().c_str(),
-                      childPosition.x, childPosition.y,
-                      childWidth.mValue, childHeight.mValue
-                      );
+      DALI_LOG_STREAM( gLogFilter, Debug::General,
+                       "AbsoluteLayout::OnLayout child[" << Toolkit::Control::DownCast( childOwner ).GetName().c_str() <<
+                       "] position(" << childPosition << ") child width[" << childWidth << "] height[" << childHeight << "]\n" );
 
       childLayout->Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight );
     }
index 1df4f5f..65b46c1 100644 (file)
@@ -218,23 +218,23 @@ void FlexLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeas
 
   if( widthMeasureSpec.GetMode() == MeasureSpec::Mode::EXACTLY )
   {
-    width = widthMeasureSpec.GetSize().AsFloat();
+    width = widthMeasureSpec.GetSize().AsDecimal();
     YGNodeStyleSetWidth( mRoot, width );
   }
   else if( widthMeasureSpec.GetMode() == MeasureSpec::Mode::AT_MOST )
   {
-    width = widthMeasureSpec.GetSize().AsFloat();
+    width = widthMeasureSpec.GetSize().AsDecimal();
     YGNodeStyleSetMaxWidth( mRoot, width );
   }
 
   if ( heightMeasureSpec.GetMode() == MeasureSpec::Mode::EXACTLY )
   {
-    height = heightMeasureSpec.GetSize().AsFloat();
+    height = heightMeasureSpec.GetSize().AsDecimal();
     YGNodeStyleSetHeight( mRoot, height );
   }
   else if ( heightMeasureSpec.GetMode() == MeasureSpec::Mode::AT_MOST )
   {
-    height = heightMeasureSpec.GetSize().AsFloat();
+    height = heightMeasureSpec.GetSize().AsDecimal();
     YGNodeStyleSetMaxHeight( mRoot, height );
   }
 
@@ -263,7 +263,7 @@ void FlexLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, La
   DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() );
 #endif
 
-  YGNodeCalculateLayout( mRoot, width.AsFloat(), height.AsFloat(), isLayoutRtl ? YGDirectionRTL : YGDirectionLTR );
+  YGNodeCalculateLayout( mRoot, width.AsDecimal(), height.AsDecimal(), isLayoutRtl ? YGDirectionRTL : YGDirectionLTR );
 
   auto count = GetChildCount();
   for( unsigned int childIndex = 0; childIndex < count; childIndex++)
@@ -272,7 +272,7 @@ void FlexLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, La
     if( childLayout != nullptr )
     {
       YGNodeRef node = YGNodeGetChild(mRoot, childIndex);
-      LayoutLength childLeft = LayoutLength( YGNodeLayoutGetLeft( node ) ) + left;
+      LayoutLength childLeft = LayoutLength( YGNodeLayoutGetLeft( node ) )+ left;
       LayoutLength childTop = LayoutLength( YGNodeLayoutGetTop( node ) ) + top;
       LayoutLength childWidth = LayoutLength( YGNodeLayoutGetWidth( node ) );
       LayoutLength childHeight = LayoutLength( YGNodeLayoutGetHeight( node ) );
@@ -290,7 +290,7 @@ YGSize FlexLayout::OnChildMeasure( YGNodeRef node,
   auto childOwner = childLayout->GetOwner();
   auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
   auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
-  auto parentWidthMeasureSpec = MeasureSpec( 0 );
+  MeasureSpec parentWidthMeasureSpec( 0 );
   if ( innerWidth != YGUndefined )
   {
     parentWidthMeasureSpec = MeasureSpec( innerWidth, static_cast<MeasureSpec::Mode>(widthMode) );
@@ -336,8 +336,8 @@ YGSize FlexLayout::OnChildMeasure( YGNodeRef node,
   LayoutLength measuredHeight = childLayout->GetMeasuredHeight() - padding.bottom - padding.top;
 
   return YGSize{
-    .width = measuredWidth.AsFloat(),
-    .height = measuredHeight.AsFloat(),
+    .width = measuredWidth.AsDecimal(),
+    .height = measuredHeight.AsDecimal(),
   };
 }
 
index 3bb54a9..09224ee 100644 (file)
@@ -76,14 +76,14 @@ int Grid::GetNumberOfColumns() const
   return mNumColumns;
 }
 
-void Grid::DetermineNumberOfColumns( int availableSpace )
+void Grid::DetermineNumberOfColumns( LayoutLength availableSpace )
 {
   if( mRequestedNumColumns == AUTO_FIT )
   {
     if( availableSpace > 0 )
     {
       // Can only calculate number of columns if a column width has been set
-      mNumColumns = ( mRequestedColumnWidth > 0 ) ? ( availableSpace / mRequestedColumnWidth ) : 1;
+      mNumColumns = ( mRequestedColumnWidth > 0 ) ? ( availableSpace.AsInteger() / mRequestedColumnWidth ) : 1;
     }
   }
 }
@@ -132,7 +132,7 @@ void Grid::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpe
       desiredChildWidth += childMargin.start + childMargin.end;
 
       mTotalWidth = desiredChildWidth * mNumColumns;
-      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredWidth(%d) \n", mTotalWidth.mValue );
+      DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredWidth(" << mTotalWidth << ") \n" );
     } // Child is LayoutItem
   } // Child exists
 
@@ -149,12 +149,10 @@ void Grid::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpe
       mTotalWidth = std::min( mTotalWidth, widthSize );
   }
 
-  availableContentWidth = mTotalWidth.mValue - gridLayoutPadding.start - gridLayoutPadding.end;
+  availableContentWidth = mTotalWidth - gridLayoutPadding.start - gridLayoutPadding.end;
   widthSize = mTotalWidth;
 
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Grid::OnMeasure availableContentWidth(%d) mTotalWidth(%d) \n",
-                 availableContentWidth.mValue,
-                 mTotalWidth.mValue );
+  DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "Grid::OnMeasure availableContentWidth" << availableContentWidth << " mTotalWidth(" << mTotalWidth << ") \n" );
   // HEIGHT SPECIFICATIONS
 
   // heightMode EXACTLY so grid must be the given height
@@ -168,8 +166,7 @@ void Grid::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpe
       {
         mTotalHeight += desiredChildHeight;
       }
-      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredHeight(%d) \n",
-                      mTotalHeight.mValue );
+      DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredHeight(" << mTotalHeight << ") \n" );
 
       // Ensure ourHeight does not exceed specified atmost height
       mTotalHeight = std::min( mTotalHeight, heightSize );
@@ -196,10 +193,10 @@ void Grid::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpe
   }
 
   // If number of columns not defined
-  DetermineNumberOfColumns( availableContentWidth.mValue );
+  DetermineNumberOfColumns( availableContentWidth );
 
   // Locations define the start, end,top and bottom of each cell.
-  mLocations->CalculateLocations( mNumColumns, availableContentWidth.mValue, availableContentHeight.mValue, childCount, 0, 0 );
+  mLocations->CalculateLocations( mNumColumns, availableContentWidth.AsInteger(), availableContentHeight.AsInteger(), childCount, 0, 0 );
 
 
   SetMeasuredDimensions( ResolveSizeAndState( widthSize, widthMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK ),
index f21a9dd..264f11d 100644 (file)
@@ -93,7 +93,7 @@ private:
    * For the given availableSpace, calculate or retreive the number of required columns.
    * @param[in] availableSpace the space available for a child in each column.
    */
-  void DetermineNumberOfColumns( int availableSpace );
+  void DetermineNumberOfColumns( LayoutLength availableSpace );
 
 private:
 
@@ -130,4 +130,4 @@ inline const Internal::Grid& GetImplementation( const Dali::Toolkit::Grid& handl
 } // namespace Toolkit
 } // namespace Dali
 
-#endif // DALI_TOOLKIT_INTERNAL_LAYOUTINGInner
\ No newline at end of file
+#endif // DALI_TOOLKIT_INTERNAL_LAYOUTINGInner
index cfceb62..f912810 100644 (file)
@@ -84,8 +84,8 @@ void LayoutController::Process()
     auto stageWidth  = stage.GetSize().width;
     auto stageHeight = stage.GetSize().height;
 
-    auto widthSpec = MeasureSpec( stageWidth, MeasureSpec::Mode::EXACTLY );
-    auto heightSpec = MeasureSpec( stageHeight, MeasureSpec::Mode::EXACTLY );
+    MeasureSpec widthSpec( stageWidth, MeasureSpec::Mode::EXACTLY );
+    MeasureSpec heightSpec( stageHeight, MeasureSpec::Mode::EXACTLY );
 
     // Test how to perform a measure on each control.
     MeasureHierarchy( stage.GetRootLayer(), widthSpec, heightSpec );
index cd0460d..0833b3b 100644 (file)
@@ -30,11 +30,11 @@ bool LayoutItem::Impl::sUseZeroUnspecifiedMeasureSpec = false;
 LayoutItem::Impl::Impl()
 : mOwner( nullptr ),
   mLayoutParent( nullptr ),
-  mOldWidthMeasureSpec( 0u ),
-  mOldHeightMeasureSpec( 0u ),
+  mOldWidthMeasureSpec( 0 ),
+  mOldHeightMeasureSpec( 0 ),
   mMinimumSize(),
-  mMeasuredWidth(0u),
-  mMeasuredHeight(0u),
+  mMeasuredWidth(0),
+  mMeasuredHeight(0),
   mLeft( 0 ),
   mRight( 0 ),
   mTop( 0 ),
index ecde6eb..b077f54 100644 (file)
@@ -249,8 +249,8 @@ void LinearLayout::MeasureHorizontal( MeasureSpec widthMeasureSpec, MeasureSpec
           childWidth = childLayout->GetMeasuredWidth();
         }
 
-        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LinearLayout::OnMeasure childWidth(%d)\n", childWidth.mValue );
-        LayoutLength length = childWidth + LayoutLength::IntType( childMargin.start + childMargin.end );
+        DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LinearLayout::OnMeasure childWidth(" << childWidth << ")\n" );
+        LayoutLength length = childWidth + childMargin.start + childMargin.end;
         LayoutLength cellPadding = i < GetChildCount() - 1 ? mCellPadding.width : 0;
         if( isExactly )
         {
@@ -331,7 +331,7 @@ void LinearLayout::MeasureHorizontal( MeasureSpec widthMeasureSpec, MeasureSpec
       LayoutLength childWidth = 0;
       if( childWeight > 0 )
       {
-        LayoutLength share = (childWeight * remainingExcess.mValue) / remainingWeightSum;
+        LayoutLength share = ( childWeight * remainingExcess ) / remainingWeightSum;
         remainingExcess -= share;
         remainingWeightSum -= childWeight;
 
@@ -426,12 +426,12 @@ void LinearLayout::ForceUniformHeight( int count, MeasureSpec widthMeasureSpec )
       {
         // Temporarily force children to reuse their old measured width
         LayoutLength oldWidth = desiredWidth;
-        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, childLayout->GetMeasuredWidth().mValue );
+        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, childLayout->GetMeasuredWidth().AsInteger() );
 
         // Remeasure with new dimensions
         MeasureChildWithMargins( childLayout, widthMeasureSpec, 0, uniformMeasureSpec, 0 );
 
-        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, oldWidth.mValue );
+        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, oldWidth.AsInteger() );
       }
     }
   }
@@ -490,7 +490,7 @@ void LinearLayout::LayoutHorizontal( LayoutLength left, LayoutLength top, Layout
     case Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL:
     {
       // mTotalLength contains the padding already
-      childLeft = LayoutLength( padding.start ) + ( right - left - mTotalLength ) / 2;
+      childLeft = padding.start + ( right - left - mTotalLength ) / 2.0f;
       break;
     }
   }
@@ -527,10 +527,10 @@ void LinearLayout::LayoutHorizontal( LayoutLength left, LayoutLength top, Layout
           childTop = height - padding.bottom - childHeight - childMargin.bottom;
           break;
         }
-        case Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL:
+        case Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL: // FALLTHROUGH
         default:
         {
-          childTop = LayoutLength( padding.top ) + ( ( childSpace - childHeight ) / 2 ) + childMargin.top - childMargin.bottom;
+          childTop = padding.top + ( ( childSpace - childHeight ) / 2.0f ) + childMargin.top - childMargin.bottom;
           break;
         }
       }
@@ -613,9 +613,9 @@ void LinearLayout::MeasureVertical( MeasureSpec widthMeasureSpec, MeasureSpec he
           childHeight = childLayout->GetMeasuredHeight();
         }
 
-        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LinearLayout::MeasureVertical childHeight(%d)\n", childHeight.mValue );
+        DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LinearLayout::MeasureVertical childHeight(" << childHeight << ")\n" );
 
-        LayoutLength length = childHeight + LayoutLength::IntType( childMargin.top + childMargin.bottom );
+        LayoutLength length = childHeight + childMargin.top + childMargin.bottom;
         LayoutLength cellPadding = i < GetChildCount() - 1 ? mCellPadding.height : 0;
         LayoutLength totalLength = mTotalLength;
         mTotalLength = std::max( totalLength, totalLength + length + cellPadding );
@@ -693,7 +693,7 @@ void LinearLayout::MeasureVertical( MeasureSpec widthMeasureSpec, MeasureSpec he
       LayoutLength childHeight = 0;
       if( childWeight > 0 )
       {
-        LayoutLength share = (childWeight * remainingExcess.mValue) / remainingWeightSum;
+        LayoutLength share = ( childWeight * remainingExcess ) / remainingWeightSum;
         remainingExcess -= share;
         remainingWeightSum -= childWeight;
 
@@ -738,7 +738,7 @@ void LinearLayout::MeasureVertical( MeasureSpec widthMeasureSpec, MeasureSpec he
       alternativeMaxWidth = std::max( alternativeMaxWidth, matchWidthLocally ? marginWidth : childWidth );
 
       childHeight = childLayout->GetMeasuredHeight();
-      LayoutLength length = childHeight + LayoutLength::IntType( childMargin.top + childMargin.bottom );
+      LayoutLength length = childHeight + childMargin.top + childMargin.bottom;
       LayoutLength cellPadding = i < GetChildCount() - 1 ? mCellPadding.height : 0;
       LayoutLength totalLength = mTotalLength;
       mTotalLength = std::max( totalLength, totalLength + length + cellPadding );
@@ -787,12 +787,12 @@ void LinearLayout::ForceUniformWidth( int count, MeasureSpec heightMeasureSpec )
       {
         // Temporarily force children to reuse their old measured height
         LayoutLength oldHeight = desiredHeight;
-        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, childLayout->GetMeasuredHeight().mValue );
+        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, childLayout->GetMeasuredHeight().AsInteger() );
 
         // Remeasure with new dimensions
         MeasureChildWithMargins( childLayout, uniformMeasureSpec, 0, heightMeasureSpec, 0 );
 
-        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, oldHeight.mValue );
+        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, oldHeight.AsInteger() );
       }
     }
   }
@@ -830,7 +830,7 @@ void LinearLayout::LayoutVertical( LayoutLength left, LayoutLength top, LayoutLe
     default:
     {
       // mTotalLength contains the padding already
-      childTop = LayoutLength( padding.top ) + ( bottom - top - mTotalLength ) / 2;
+      childTop = padding.top + ( bottom - top - mTotalLength ) / 2.0f;
       break;
     }
   }
@@ -860,7 +860,7 @@ void LinearLayout::LayoutVertical( LayoutLength left, LayoutLength top, LayoutLe
         }
         case Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL:
         {
-          childLeft = LayoutLength( padding.start ) + ( childSpace - childWidth ) / 2 + childMargin.start - childMargin.end;
+          childLeft = padding.start + ( childSpace - childWidth ) / 2.0f + childMargin.start - childMargin.end;
           break;
         }
       }