Remove constraints from Popup, TableView, Alignment & ScrollBar 81/35081/7
authorXiangyin Ma <x1.ma@samsung.com>
Fri, 6 Feb 2015 18:44:29 +0000 (18:44 +0000)
committerroot <x1.ma@samsung.com>
Tue, 10 Feb 2015 17:42:53 +0000 (17:42 +0000)
Change-Id: Icc87b6fc280a653f5fc5711c5f3bf624db5c5d18

automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp
dali-toolkit/internal/controls/alignment/alignment-impl.cpp
dali-toolkit/internal/controls/popup/popup-impl.cpp
dali-toolkit/internal/controls/popup/popup-impl.h
dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp
dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h
dali-toolkit/internal/controls/table-view/table-view-impl.cpp
dali-toolkit/internal/controls/table-view/table-view-impl.h
dali-toolkit/public-api/controls/table-view/table-view.cpp
dali-toolkit/public-api/controls/table-view/table-view.h

index 7fe943acdd36e1f61a313ab1ae1c67434aa51ee9..b32c92e830b8b0dc113cf93c786db4d779b1f119 100644 (file)
@@ -39,7 +39,6 @@ namespace
 const char* const PROPERTY_NAME_ROWS = "rows";
 const char* const PROPERTY_NAME_COLUMNS = "columns";
 const char* const PROPERTY_NAME_CELL_PADDING = "cell-padding";
-const char* const PROPERTY_NAME_LAYOUT_ANIMATION_DURATION = "layout-animation-duration";
 const char* const PROPERTY_NAME_LAYOUT_ROWS = "layout-rows";
 const char* const PROPERTY_NAME_LAYOUT_COLUMNS = "layout-columns";
 
@@ -74,8 +73,7 @@ static void SetupTableViewAndActors(TableView& tableView, Actor& actor1, Actor&
   DALI_TEST_CHECK(tableView);
 
   Stage::GetCurrent().Add( tableView );
-  tableView.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, Constraint100() ) );
-  tableView.SetLayoutAnimationDuration(0.0f);
+  tableView.SetSize( Dali::Vector3( 100.0f, 100.0f, 100.0f ) );
 
   actor1 = Actor::New();
   actor2 = Actor::New();
@@ -220,23 +218,6 @@ int UtcDaliTableViewMetricsRelative(void)
 }
 
 
-// Test animation duration setting.
-int UtcDaliTableViewAnimation(void)
-{
-  ToolkitTestApplication application;
-
-  tet_infoline("UtcDaliTableViewAnimation");
-  TableView tableView = TableView::New(10,10);
-  DALI_TEST_CHECK(tableView);
-
-  tableView.SetLayoutAnimationDuration(5.0f);
-  DALI_TEST_EQUALS(tableView.GetLayoutAnimationDuration(), 5.0f, TEST_LOCATION);
-
-  tableView.SetLayoutAnimationDuration(2.5f);
-  DALI_TEST_EQUALS(tableView.GetLayoutAnimationDuration(), 2.5f, TEST_LOCATION);
-  END_TEST;
-}
-
 // Test Adding/Removing/Finding Children.
 int UtcDaliTableViewChild(void)
 {
@@ -585,14 +566,6 @@ int UtcDaliTableViewSetGetProperty(void)
   DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(6.f, 8.f), TEST_LOCATION );
   DALI_TEST_EQUALS( tableView.GetProperty(TableView::PROPERTY_CELL_PADDING).Get<Vector2>(), Vector2(6.f,8.f), TEST_LOCATION );
 
-  // Test "layout-animation-duration" property
-  DALI_TEST_CHECK( tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ANIMATION_DURATION) == TableView::PROPERTY_LAYOUT_ANIMATION_DURATION );
-
-  tableView.SetProperty( TableView::PROPERTY_LAYOUT_ANIMATION_DURATION, 1.5f );
-
-  DALI_TEST_EQUALS( tableView.GetLayoutAnimationDuration(), 1.5f, TEST_LOCATION );
-  DALI_TEST_EQUALS( tableView.GetProperty(TableView::PROPERTY_LAYOUT_ANIMATION_DURATION).Get<float>(), 1.5f, TEST_LOCATION );
-
   //{ "policy": "fixed", "value": 30.0 },
   Property::Map item1;
   item1[ "policy" ] = "fixed";
index e887cb454391ebdc1ae6c27ae9d4e87830b817c7..97b6f64d69d1cf28d4f9566a8ffa252f0f069283 100644 (file)
@@ -301,60 +301,65 @@ struct PositionConstraint
     const Vector3& currentSize( currentSizeProperty.GetVector3() );
     const Vector3& parentSize( parentSizeProperty.GetVector3() );
 
+    return GetPosition( currentSize, parentSize );
+  }
+
+  inline Vector3 GetPosition( const Vector3& currentSize, const Vector3& parentSize )
+  {
     Vector3 position( 0.f, 0.f, 0.f );
 
     switch( mHorizontalAlignment )
     {
-      case Dali::Toolkit::Alignment::HorizontalLeft:
-      {
-        position.x += mPadding.left;
-        break;
-      }
-      case Dali::Toolkit::Alignment::HorizontalCenter:
-      {
-        if( currentSize.width + mPadding.left + mPadding.right >= parentSize.width )
-        {
-          position.x += 0.5f * ( mPadding.left - mPadding.right );
-        }
-        break;
-      }
-      case Dali::Toolkit::Alignment::HorizontalRight:
-      {
-        position.x -= mPadding.right;
-        break;
-      }
-      default:
+    case Dali::Toolkit::Alignment::HorizontalLeft:
+    {
+      position.x += mPadding.left;
+      break;
+    }
+    case Dali::Toolkit::Alignment::HorizontalCenter:
+    {
+      if( currentSize.width + mPadding.left + mPadding.right >= parentSize.width )
       {
-        DALI_ASSERT_ALWAYS( !"Wrong horizontal alignment value" );
-        break;
+        position.x += 0.5f * ( mPadding.left - mPadding.right );
       }
+      break;
+    }
+    case Dali::Toolkit::Alignment::HorizontalRight:
+    {
+      position.x -= mPadding.right;
+      break;
+    }
+    default:
+    {
+      DALI_ASSERT_ALWAYS( !"Wrong horizontal alignment value" );
+      break;
+    }
     }
 
     switch( mVerticalAlignment )
     {
-      case Dali::Toolkit::Alignment::VerticalTop:
-      {
-        position.y += mPadding.top;
-        break;
-      }
-      case Dali::Toolkit::Alignment::VerticalCenter:
-      {
-        if( currentSize.height + mPadding.top + mPadding.bottom >= parentSize.height )
-        {
-          position.y += 0.5f * ( mPadding.top - mPadding.bottom );
-        }
-        break;
-      }
-      case Dali::Toolkit::Alignment::VerticalBottom:
-      {
-        position.y -= mPadding.bottom;
-        break;
-      }
-      default:
+    case Dali::Toolkit::Alignment::VerticalTop:
+    {
+      position.y += mPadding.top;
+      break;
+    }
+    case Dali::Toolkit::Alignment::VerticalCenter:
+    {
+      if( currentSize.height + mPadding.top + mPadding.bottom >= parentSize.height )
       {
-        DALI_ASSERT_ALWAYS( !"Wrong vertical alignment value" );
-        break;
+        position.y += 0.5f * ( mPadding.top - mPadding.bottom );
       }
+      break;
+    }
+    case Dali::Toolkit::Alignment::VerticalBottom:
+    {
+      position.y -= mPadding.bottom;
+      break;
+    }
+    default:
+    {
+      DALI_ASSERT_ALWAYS( !"Wrong vertical alignment value" );
+      break;
+    }
     }
 
     return position;
@@ -364,15 +369,6 @@ struct PositionConstraint
   const Toolkit::Alignment::Type mHorizontalAlignment;
   const Toolkit::Alignment::Type mVerticalAlignment;
 };
-
-void SetPositionConstraint( Actor actor, const Toolkit::Alignment::Padding& padding, Toolkit::Alignment::Type horizontal, Toolkit::Alignment::Type vertical )
-{
-  Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
-                                                    LocalSource( Actor::SIZE ),
-                                                    ParentSource( Actor::SIZE ),
-                                                    PositionConstraint( padding, horizontal, vertical ) );
-  actor.ApplyConstraint( constraint );
-}
 } // namespace
 
 Toolkit::Alignment Alignment::New( Toolkit::Alignment::Type horizontal, Toolkit::Alignment::Type vertical )
@@ -486,61 +482,51 @@ void Alignment::OnRelayout( const Vector2& size, ActorSizeContainer& container )
     actor.SetAnchorPoint( anchorPointAndParentOrigin );
     actor.SetParentOrigin( anchorPointAndParentOrigin );
 
-    if( Toolkit::Alignment::ScaleNone != mScaling )
-    {
-      actor.RemoveConstraints();
-    }
-
-    Vector3 actorSize ( actor.GetCurrentSize() );
+    Vector3 actorSize ( actor.GetSize() );
     Toolkit::Control control( Toolkit::Control::DownCast( actor ) );
     if ( actorSize == Vector3::ZERO && control )
     {
       actorSize = control.GetNaturalSize();
     }
 
-    Vector2 childSize;
+    Vector3 childSize;
 
     switch( mScaling )
     {
       case Toolkit::Alignment::ScaleNone:
       {
         // Nothing to do but needed just to not to jump to the default.
-        childSize = size;
+        childSize = actorSize;
         break;
       }
       case Toolkit::Alignment::ScaleToFill:
       {
         ScaleToFillConstraint constraint( mPadding );
-        childSize = Vector2( constraint.GetSize( actorSize, Vector3(size) ) );
-        SetPositionConstraint( actor, mPadding, mHorizontal, mVertical );
+        childSize = constraint.GetSize( actorSize, Vector3(size) ) ;
         break;
       }
       case Toolkit::Alignment::ScaleToFitKeepAspect:
       {
         ScaleToFitKeepAspectConstraint constraint( mPadding );
-        childSize = Vector2( constraint.GetSize( actorSize, Vector3(size) ) );
-        SetPositionConstraint( actor, mPadding, mHorizontal, mVertical );
+        childSize = constraint.GetSize( actorSize, Vector3(size) ) ;
         break;
       }
       case Toolkit::Alignment::ScaleToFillKeepAspect:
       {
         ScaleToFillKeepAspectConstraint constraint( mPadding );
-        childSize = Vector2( constraint.GetSize( actorSize, Vector3(size) ) );
-        SetPositionConstraint( actor, mPadding, mHorizontal, mVertical );
+        childSize = constraint.GetSize( actorSize, Vector3(size) );
         break;
       }
       case Toolkit::Alignment::ShrinkToFit:
       {
         ShrinkToFitConstraint constraint( mPadding );
-        childSize = Vector2( constraint.GetSize( actorSize, Vector3(size) ) );
-        SetPositionConstraint( actor, mPadding, mHorizontal, mVertical );
+        childSize = constraint.GetSize( actorSize, Vector3(size) );
         break;
       }
       case Toolkit::Alignment::ShrinkToFitKeepAspect:
       {
         ShrinkToFitKeepAspectConstraint constraint( mPadding );
-        childSize = Vector2( constraint.GetSize( actorSize, Vector3(size) ) );
-        SetPositionConstraint( actor, mPadding, mHorizontal, mVertical );
+        childSize = constraint.GetSize( actorSize, Vector3(size) );
         break;
       }
       default:
@@ -550,7 +536,15 @@ void Alignment::OnRelayout( const Vector2& size, ActorSizeContainer& container )
       }
     }
 
-    Relayout( actor, childSize, container );
+    PositionConstraint positionConstraint(mPadding, mHorizontal, mVertical);
+    actor.SetPosition( positionConstraint.GetPosition(childSize, actorSize) );
+
+    if( !control )
+    {
+      actor.SetScale(childSize / actorSize);
+    }
+
+    Relayout( actor, Vector2(childSize), container );
   }
 }
 
index 1134b6e665cc30882bcdc88a03d9d12723e6ab7c..83ea7eb015458d8c08a3520dbb8cb9468296e2a8 100755 (executable)
@@ -55,78 +55,39 @@ const Vector3 DEFAULT_BOTTOM_SIZE = Vector3(1.0f, 0.2f, 0.0f);
 const char* const PROPERTY_TITLE = "title";
 const char* const PROPERTY_STATE = "state";
 
-// Constraints ///////////////////////////////////////////////////////////////////////////
-
 /**
- * BackgroundSizeConstraint
- *
  * The background size should be at least as big as the Dialog.
  * In some cases a background may have graphics which are visible
  * outside of the Dialog, e.g. A Shadow. For this we need to alter
  * the size of Background.
+ *
+ * @param[in] outerBorder The border to extend beyond parent's Size.
+ * @param[in] parentSize  The parent's size
  */
-struct BackgroundSizeConstraint
+Vector3 BackgroundSize(const Vector4& outerBoarder, const Vector3& parentSize)
 {
-  /**
-   * Constraint that sets size to parent's size plus a border.
-   *
-   * @param[in] outerBorder The border to extend beyond parent's Size.
-   */
-  BackgroundSizeConstraint( Vector4 outerBorder )
-  : mOuterBorder( outerBorder )
-  {
-  }
-
-  /**
-   * (render thread code)
-   * @param[in] current The current size.
-   * @param[in] parentSizeProperty The parent's size
-   */
-  Vector3 operator()( const Vector3& current,
-                      const PropertyInput& parentSizeProperty )
-  {
-    Vector3 size = parentSizeProperty.GetVector3();
-
-    size.width += mOuterBorder.x + mOuterBorder.y;
-    size.height += mOuterBorder.z + mOuterBorder.w;
-
-    return size;
-  }
+  Vector3 size( parentSize );
+  size.width += outerBoarder.x + outerBoarder.y;
+  size.height += outerBoarder.z + outerBoarder.w;
 
-  const Vector4 mOuterBorder;  ///< The size of the outer-border (Set to 0.0, 0.0f, 0.0f, 0.0f if doesn't exist).
-};
+  return size;
+}
 
-struct ButtonAreaSizeConstraint
-{
   /**
-   * Constraint that sets size to parent's size plus a border.
+   * sets button area size to parent's size plus a border.
    *
    * @param[in] outerBorder The border to extend beyond parent's Size.
+   * @param[in] parentSize  The parent's size
    */
-  ButtonAreaSizeConstraint( Vector4 outerBorder )
-  : mOuterBorder( outerBorder )
-  {
-  }
-
-  /**
-   * (render thread code)
-   * @param[in] current The current size.
-   * @param[in] parentSizeProperty The parent's size
-   */
-  Vector3 operator()( const Vector3& current,
-                      const PropertyInput& parentSizeProperty )
-  {
-    Vector3 size = parentSizeProperty.GetVector3();
-
-    size.width += mOuterBorder.x + mOuterBorder.y;
-    size.width -= (POPUP_OUT_MARGIN_WIDTH + POPUP_OUT_MARGIN_WIDTH);
-    size.height = POPUP_BUTTON_BG_HEIGHT;
-
-    return size;
-  }
+Vector3 ButtonAreaSize( const Vector4& outBoarder, const Vector3& parentSize )
+{
+  Vector3 size( parentSize );
+  size.width += outBoarder.x + outBoarder.y;
+  size.width -= (POPUP_OUT_MARGIN_WIDTH + POPUP_OUT_MARGIN_WIDTH);
+  size.height = POPUP_BUTTON_BG_HEIGHT;
 
-  const Vector4 mOuterBorder;  ///< The size of the outer-border (Set to 0.0, 0.0f, 0.0f, 0.0f if doesn't exist).
-};
+  return size;
+}
 
 } // unnamed namespace
 
@@ -199,13 +160,11 @@ void Popup::OnInitialize()
   mLayer.SetParentOrigin(ParentOrigin::CENTER);
   mLayer.SetAnchorPoint(AnchorPoint::CENTER);
   mLayer.RaiseToTop();
-  mLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
   self.Add(mLayer);
 
   mPopupBg = Actor::New();
   mPopupBg.SetParentOrigin(ParentOrigin::CENTER);
   mPopupBg.SetAnchorPoint(AnchorPoint::CENTER);
-  mPopupBg.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
   mLayer.Add(mPopupBg);
 
   // Any content after this point which is added to Self() will be reparented to
@@ -666,6 +625,23 @@ void Popup::OnControlChildAdd( Actor& child )
   }
 }
 
+void Popup::OnControlSizeSet( const Vector3& targetSize )
+{
+  mLayer.SetSize( targetSize );
+  mPopupBg.SetSize( targetSize );
+
+  const Vector4 outerBorder = mPopupStyle->backgroundOuterBorder;
+  if( mBackgroundImage )
+  {
+    mBackgroundImage.SetSize( BackgroundSize( outerBorder,targetSize ) );
+  }
+  if( mButtonAreaImage )
+  {
+    mButtonAreaImage.SetSize( ButtonAreaSize( outerBorder, targetSize ) );
+  }
+
+}
+
 void Popup::OnRelayout( const Vector2& size, ActorSizeContainer& container )
 {
   // Set the popup size
@@ -683,13 +659,7 @@ void Popup::OnRelayout( const Vector2& size, ActorSizeContainer& container )
 
   if( mBackgroundImage )
   {
-    Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
-                                                      ParentSource( Actor::SIZE ),
-                                                      BackgroundSizeConstraint(outerBorder) );
-
-    mBackgroundImage.RemoveConstraints();
-    mBackgroundImage.ApplyConstraint( constraint );
-
+    mBackgroundImage.SetSize(BackgroundSize(outerBorder, Vector3(size)));
     mBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
     mBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
     mBackgroundImage.SetPosition( -outerBorder.x, -outerBorder.y, 0.0f );
@@ -704,13 +674,7 @@ void Popup::OnRelayout( const Vector2& size, ActorSizeContainer& container )
     }
     else
     {
-      Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
-                                                      ParentSource( Actor::SIZE ),
-                                                      ButtonAreaSizeConstraint(outerBorder) );
-
-      mButtonAreaImage.RemoveConstraints();
-      mButtonAreaImage.ApplyConstraint( constraint );
-
+      mButtonAreaImage.SetSize( ButtonAreaSize(outerBorder, Vector3(size)) );
       mButtonAreaImage.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
       mButtonAreaImage.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
       mButtonAreaImage.SetY( -outerBorder.z - POPUP_OUT_MARGIN_HEIGHT );
@@ -865,6 +829,11 @@ Vector3 Popup::GetNaturalSize()
     Vector3 contentSize = RelayoutHelper::GetNaturalSize( mContent );
     // Choose the biggest width
     naturalSize.width = std::max( naturalSize.width, contentSize.width );
+    if( naturalSize.width > maxWidth )
+    {
+      naturalSize.width = maxWidth;
+      contentSize.height = RelayoutHelper::GetHeightForWidth( mContent, maxWidth );
+    }
     naturalSize.height += contentSize.height + mPopupStyle->margin;
   }
 
index b716c0996a61af31bc7d48c0989a3a51ff1781f4..b6ee02beaa11adf181e8d77d0827e85bc5ac3635 100755 (executable)
@@ -251,7 +251,12 @@ private:
   virtual void OnControlChildAdd( Actor& child );
 
   /**
-   * @copydoc Control::OnRelayout()
+   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& size )
+   */
+  virtual void OnControlSizeSet( const Vector3& size );
+
+  /**
+   * @copydoc Control::OnRelayOut()
    */
   virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
 
index 1191db6460c5f8956f928e63e1c0210ace350317..02267f57af84c1e0fee524489e54c035ae33bc1d 100755 (executable)
@@ -40,35 +40,15 @@ const float DEFAULT_PAN_GESTURE_PROCESS_TIME(16.7f); // 16.7 milliseconds, i.e.
 const float DEFAULT_INDICATOR_FIXED_HEIGHT(80.0f);
 
 /**
- * Indicator size constraint
  * Indicator size depends on both indicator's parent size and the scroll content size
  */
-struct IndicatorSizeConstraint
+Vector3 IndicatorSize( const Vector3& parentSize, float contentSize)
 {
-  /**
-   * @param[in] contentSize The size of scrollable content
-   */
-  IndicatorSizeConstraint(float contentSize)
-  : mContentSize(contentSize)
-  {
-  }
-
-  /**
-   * Constraint operator
-   * @param[in] current The current indicator size
-   * @param[in] parentSizeProperty The parent size of scroll indicator.
-   * @return The new scroll indicator size.
-   */
-  Vector3 operator()(const Vector3& current,
-                     const PropertyInput& parentSizeProperty)
-  {
-    const Vector3& parentSize = parentSizeProperty.GetVector3();
-    float height = mContentSize > parentSize.height ? parentSize.height * ( parentSize.height / mContentSize ) : parentSize.height * ( (parentSize.height - mContentSize * 0.5f) / parentSize.height);
-    return Vector3( parentSize.width, std::max(MINIMUM_INDICATOR_HEIGHT, height), parentSize.depth );
-  }
-
-  float mContentSize;  ///< The size of scrollable content
-};
+  float height = contentSize > parentSize.height ?
+                 parentSize.height * ( parentSize.height / contentSize ) :
+                 parentSize.height * ( (parentSize.height - contentSize * 0.5f) / parentSize.height);
+  return Vector3( parentSize.width, std::max(MINIMUM_INDICATOR_HEIGHT, height), parentSize.depth );
+}
 
 /**
  * Indicator position constraint
@@ -228,10 +208,7 @@ void ScrollBar::ApplyConstraints()
     }
     else
     {
-      constraint = Constraint::New<Vector3>( Actor::SIZE,
-                                             ParentSource( Actor::SIZE ),
-                                             IndicatorSizeConstraint( mScrollConnector.GetContentLength() ) );
-      mIndicatorSizeConstraint = mIndicator.ApplyConstraint( constraint );
+      mIndicator.SetSize( IndicatorSize( Self().GetCurrentSize(), mScrollConnector.GetContentLength() ) );
     }
 
     if(mIndicatorPositionConstraint)
@@ -245,16 +222,6 @@ void ScrollBar::ApplyConstraints()
                                            Source( mScrollPositionObject, Toolkit::ScrollConnector::SCROLL_POSITION ),
                                            IndicatorPositionConstraint( mScrollConnector.GetMinLimit(), mScrollConnector.GetMaxLimit() ) );
     mIndicatorPositionConstraint = mIndicator.ApplyConstraint( constraint );
-
-    if( mBackground )
-    {
-      mBackground.RemoveConstraints();
-
-      constraint = Constraint::New<Vector3>(Actor::SIZE,
-                                            ParentSource(Actor::SIZE),
-                                            EqualToConstraint());
-      mBackground.ApplyConstraint(constraint);
-    }
   }
 }
 
@@ -397,6 +364,14 @@ void ScrollBar::OnPan( PanGesture gesture )
   }
 }
 
+void ScrollBar::OnControlSizeSet( const Vector3& size )
+{
+  if(mIndicatorHeightPolicy != Toolkit::ScrollBar::Fixed && mScrollConnector)
+  {
+    mIndicator.SetSize( IndicatorSize( size, mScrollConnector.GetContentLength() ) );
+  }
+}
+
 void ScrollBar::OnScrollDomainChanged(float minPosition, float maxPosition, float contentSize)
 {
   // Reapply constraints when the scroll domain is changed
index 5cfca6a8c900d442568b132fdd1f36829c600cd3..989ffa4f8116c07f397e69f7d32abb52ca73c64c 100755 (executable)
@@ -186,6 +186,11 @@ private: // from Control
    */
   virtual void OnPan( PanGesture gesture );
 
+  /**
+   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& size )
+   */
+  virtual void OnControlSizeSet( const Vector3& size );
+
 private:
 
   /**
@@ -225,7 +230,6 @@ private:
 
   Constrainable mScrollPositionObject;                               ///< From mScrollConnector
 
-  ImageActor mBackground;                                            ///< Background image of scroll bar.
   ImageActor mIndicator;                                             ///< Image of scroll indicator.
   Animation mAnimation;                                              ///< Scroll indicator Show/Hide Animation.
 
index 0db4cbf15e8a0e0accf566818c5a98ad25897392..76eab51e2257451d35eee91f92fdf8fca796e331 100644 (file)
@@ -20,8 +20,6 @@
 
 // EXTERNAL INCLUDES
 #include <sstream>
-#include <dali/public-api/animation/constraint.h>
-#include <dali/public-api/animation/time-period.h>
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/scripting/scripting.h>
@@ -34,39 +32,17 @@ namespace
 const float DEFAULT_CONSTRAINT_DURATION = 0.0f;
 
 /**
- * Constraint that sets a child property relative to parents Width or Height
+ * sets a child property relative to parents size and applies a unit based padding before the relative calculation.
+ * @param[in] scale of parent minus padding between 0 and 1
+ * @param[in] padding in world coordinate units
+ * @param[in] fixed part in world coordinate units
+ * @param[in] size of the parent
+ * @return The relative size with padding.
  */
-struct RelativeToWidthOrHeight
+Vector2 RelativeToSize( const Vector2& scale, const Vector2& padding, const Vector2& fixed, const Vector2& parentSize)
 {
-  /**
-   * Constraint that is relative (%) to parent width/height and applies a
-   * unit based padding before the relative calculation.
-   * @param scale of parent minus padding between 0 and 1
-   * @param padding in world coordinate units
-   * @param fixed part in world coordinate units
-   */
-  RelativeToWidthOrHeight( float scale, float padding, float fixed )
-  : mScaleFactor( scale ),
-    mPadding( padding ),
-    mFixed( fixed )
-  {
-  }
-
-  inline float operator()( const float& parentWidthOrHeight )
-  {
-    return mFixed  + ( parentWidthOrHeight - mPadding  ) * mScaleFactor;
-  }
-
-  float operator()( const float& current,
-                    const PropertyInput& parentWidthOrHeight )
-  {
-    return operator()( parentWidthOrHeight.GetFloat() );
-  }
-
-  float mScaleFactor;
-  float mPadding;
-  float mFixed;
-};
+  return fixed + ( parentSize - padding ) * scale;
+}
 
 #if defined(DEBUG_ENABLED)
 // debugging support, very useful when new features are added or bugs are hunted down
@@ -137,9 +113,8 @@ namespace Toolkit
 const Property::Index TableView::PROPERTY_ROWS( Internal::TableView::TABLEVIEW_PROPERTY_START_INDEX );
 const Property::Index TableView::PROPERTY_COLUMNS( Internal::TableView::TABLEVIEW_PROPERTY_START_INDEX + 1 );
 const Property::Index TableView::PROPERTY_CELL_PADDING( Internal::TableView::TABLEVIEW_PROPERTY_START_INDEX + 2 );
-const Property::Index TableView::PROPERTY_LAYOUT_ANIMATION_DURATION( Internal::TableView::TABLEVIEW_PROPERTY_START_INDEX + 3 );
-const Property::Index TableView::PROPERTY_LAYOUT_ROWS( Internal::TableView::TABLEVIEW_PROPERTY_START_INDEX + 4 );
-const Property::Index TableView::PROPERTY_LAYOUT_COLUMNS( Internal::TableView::TABLEVIEW_PROPERTY_START_INDEX + 5 );
+const Property::Index TableView::PROPERTY_LAYOUT_ROWS( Internal::TableView::TABLEVIEW_PROPERTY_START_INDEX + 3 );
+const Property::Index TableView::PROPERTY_LAYOUT_COLUMNS( Internal::TableView::TABLEVIEW_PROPERTY_START_INDEX + 4 );
 
 namespace Internal
 {
@@ -166,9 +141,8 @@ TypeRegistration mType( typeid(Toolkit::TableView), typeid(Toolkit::Control), Cr
 PropertyRegistration property1( mType, "rows", Toolkit::TableView::PROPERTY_ROWS, Property::UNSIGNED_INTEGER, &TableView::SetProperty, &TableView::GetProperty );
 PropertyRegistration property2( mType, "columns", Toolkit::TableView::PROPERTY_COLUMNS, Property::UNSIGNED_INTEGER, &TableView::SetProperty, &TableView::GetProperty );
 PropertyRegistration property3( mType, "cell-padding", Toolkit::TableView::PROPERTY_CELL_PADDING, Property::VECTOR2, &TableView::SetProperty, &TableView::GetProperty );
-PropertyRegistration property4( mType, "layout-animation-duration", Toolkit::TableView::PROPERTY_LAYOUT_ANIMATION_DURATION, Property::FLOAT, &TableView::SetProperty, &TableView::GetProperty );
-PropertyRegistration property5( mType, "layout-rows", Toolkit::TableView::PROPERTY_LAYOUT_ROWS, Property::MAP, &TableView::SetProperty, &TableView::GetProperty );
-PropertyRegistration property6( mType, "layout-columns", Toolkit::TableView::PROPERTY_LAYOUT_COLUMNS, Property::MAP, &TableView::SetProperty, &TableView::GetProperty );
+PropertyRegistration property4( mType, "layout-rows", Toolkit::TableView::PROPERTY_LAYOUT_ROWS, Property::MAP, &TableView::SetProperty, &TableView::GetProperty );
+PropertyRegistration property5( mType, "layout-columns", Toolkit::TableView::PROPERTY_LAYOUT_COLUMNS, Property::MAP, &TableView::SetProperty, &TableView::GetProperty );
 
 } // namespace
 
@@ -615,16 +589,6 @@ float TableView::GetRelativeWidth( unsigned int columnIndex ) const
   return mRelativeWidths[ columnIndex ];
 }
 
-void TableView::SetLayoutAnimationDuration( float duration )
-{
-  mConstraintDuration = duration;
-}
-
-float TableView::GetLayoutAnimationDuration()
-{
-  return mConstraintDuration;
-}
-
 void TableView::OnRelayout( const Vector2& size, ActorSizeContainer& container )
 {
   float fixedHeightsTotal = 0.0f;
@@ -679,23 +643,8 @@ void TableView::OnRelayout( const Vector2& size, ActorSizeContainer& container )
         Vector2 fixedPosition( ( colPos + 1.0f ) * mPadding.width + cumulatedFixedWidth,
                                  ( rowPos + 1.0f ) * mPadding.height + cumulatedFixedHeight );
 
-        Constraint widthConstraint = Constraint::New<float>( Actor::POSITION_X,
-                                                             ParentSource( Actor::SIZE_WIDTH ),
-                                                             RelativeToWidthOrHeight( relativePosition.x, positionPadding.x, fixedPosition.x ) );
-
-        Constraint heightConstraint = Constraint::New<float>( Actor::POSITION_Y,
-                                                              ParentSource( Actor::SIZE_HEIGHT ),
-                                                              RelativeToWidthOrHeight( relativePosition.y, positionPadding.y, fixedPosition.y ) );
-
-        widthConstraint.SetApplyTime( mConstraintDuration );
-        heightConstraint.SetApplyTime( mConstraintDuration );
-
-        // bake constrained position value if constraint is removed
-        widthConstraint.SetRemoveAction( Constraint::Bake );
-        heightConstraint.SetRemoveAction( Constraint::Bake );
-
-        actor.ApplyConstraint( widthConstraint );
-        actor.ApplyConstraint( heightConstraint );
+        Vector3 actorPosition( RelativeToSize( relativePosition, positionPadding, fixedPosition, size ) );
+        actor.SetPosition( actorPosition );
 
         // 2. set size
         // constrain the actor size to be relative to the size of table
@@ -731,29 +680,11 @@ void TableView::OnRelayout( const Vector2& size, ActorSizeContainer& container )
         fixedSize.width += ( position.columnSpan - 1.0f ) * mPadding.width;
         fixedSize.height += ( position.rowSpan - 1.0f ) * mPadding.height;
 
-        RelativeToWidthOrHeight relativeWidthFunctor( relativeSize.x, sizePadding.x, fixedSize.x );
-        RelativeToWidthOrHeight relativeHeightFunctor( relativeSize.y, sizePadding.y, fixedSize.y );
-
-        widthConstraint = Constraint::New<float>( Actor::SIZE_WIDTH,
-                                                  ParentSource( Actor::SIZE_WIDTH ),
-                                                  relativeWidthFunctor );
-
-        heightConstraint = Constraint::New<float>( Actor::SIZE_HEIGHT,
-                                                   ParentSource( Actor::SIZE_HEIGHT ),
-                                                   relativeHeightFunctor );
-
-        widthConstraint.SetApplyTime( mConstraintDuration );
-        heightConstraint.SetApplyTime( mConstraintDuration );
-
-        // bake constrained size value if constraint is removed
-        widthConstraint.SetRemoveAction( Constraint::Bake );
-        heightConstraint.SetRemoveAction( Constraint::Bake );
-
-        actor.ApplyConstraint( widthConstraint );
-        actor.ApplyConstraint( heightConstraint );
+        Vector2 actorSize( RelativeToSize( relativeSize, sizePadding, fixedSize, size ) );
+        actor.SetSize(actorSize.x, actorSize.y);
 
         // Relayout Children
-        Relayout ( actor, Vector2( relativeWidthFunctor( size.width ), relativeHeightFunctor( size.height ) ), container );
+        Relayout ( actor, actorSize, container );
       }
       // for position we need to keep track of current fixed width and relative width
       // increase for next column
@@ -807,11 +738,6 @@ void TableView::SetProperty( BaseObject* object, Property::Index index, const Pr
         tableViewImpl.SetCellPadding( value.Get<Vector2>() );
         break;
       }
-      case Toolkit::TableView::PROPERTY_LAYOUT_ANIMATION_DURATION:
-      {
-        tableViewImpl.SetLayoutAnimationDuration( value.Get<float>() );
-        break;
-      }
       case Toolkit::TableView::PROPERTY_LAYOUT_ROWS:
       {
         SetHeightOrWidthProperty( tableViewImpl, &TableView::SetFixedHeight, &TableView::SetRelativeHeight, value );
@@ -852,11 +778,6 @@ Property::Value TableView::GetProperty( BaseObject* object, Property::Index inde
         value = tableViewImpl.GetCellPadding();
         break;
       }
-      case Toolkit::TableView::PROPERTY_LAYOUT_ANIMATION_DURATION:
-      {
-        value = tableViewImpl.GetLayoutAnimationDuration();
-        break;
-      }
       case Toolkit::TableView::PROPERTY_LAYOUT_ROWS:
       {
         value = tableViewImpl.GetRowHeightsPropertyValue();
@@ -953,8 +874,7 @@ void TableView::OnControlChildRemove( Actor& child )
 TableView::TableView( unsigned int initialRows, unsigned int initialColumns )
 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mCellData( initialRows, initialColumns ),
-  mLayoutingChild( false ),
-  mConstraintDuration( DEFAULT_CONSTRAINT_DURATION )
+  mLayoutingChild( false )
 {
   SetKeyboardNavigationSupport( true );
   ResizeContainers( initialRows, initialColumns );
index 82110a3659e2dd09bd93e3a4da595477fa15cb3d..9939a051200813b304cdcd7a4eb0171fd4ffeadd 100644 (file)
@@ -173,17 +173,6 @@ public:
    */
   float GetRelativeWidth( unsigned int columnIndex ) const;
 
-  /**
-   * @copydoc Toolkit::TableView::SetLayoutAnimationDuration
-   */
-  void SetLayoutAnimationDuration( float duration );
-
-  /**
-   * @copydoc Toolkit::TableView::GetLayoutAnimationDuration
-   */
-  float GetLayoutAnimationDuration();
-
-
   /**
    * @copydoc Toolkit::TableView::GetRows
    */
@@ -376,7 +365,6 @@ private: // Data
   std::vector<float> mRelativeWidths;
   Size mPadding;
   bool mLayoutingChild;
-  float mConstraintDuration;
 
 };
 
index 06c18a99d18d131f7d98c80f9695663e20573659..7c77387e99f722ce8985d7f086f2c470b63b8bfa 100644 (file)
@@ -175,16 +175,6 @@ float TableView::GetRelativeWidth( unsigned int columnIndex ) const
   return GetImpl(*this).GetRelativeWidth( columnIndex );
 }
 
-void TableView::SetLayoutAnimationDuration( float duration )
-{
-  GetImpl(*this).SetLayoutAnimationDuration( duration );
-}
-
-float TableView::GetLayoutAnimationDuration()
-{
-  return GetImpl(*this).GetLayoutAnimationDuration();
-}
-
 unsigned int TableView::GetRows()
 {
   return GetImpl(*this).GetRows();
index 1b4a332acd1cb59d436e4ef7222ece36e37a0dd5..d7c8ed38fffa0d4582dc7dc56fe3dd6646c62c16 100644 (file)
@@ -50,7 +50,6 @@ public:
   static const Property::Index PROPERTY_ROWS;                       ///< name "rows",                      type UNSIGNED_INTEGER
   static const Property::Index PROPERTY_COLUMNS;                    ///< name "columns",                   type UNSIGNED_INTEGER
   static const Property::Index PROPERTY_CELL_PADDING;               ///< name "cell-padding",              type VECTOR2
-  static const Property::Index PROPERTY_LAYOUT_ANIMATION_DURATION;  ///< name "layout-animation-duration", type FLOAT
 
   /*
    * PROPERTY_LAYOUT_ROWS set the height of the rows
@@ -332,19 +331,6 @@ public:
    */
   float GetRelativeWidth( unsigned int columnIndex ) const;
 
-  /**
-   * Sets the layout animation duration for add, remove and relayout
-   * @param duration for the layout animations
-   * @note The default duration is 0.0f.
-   */
-  void SetLayoutAnimationDuration( float duration );
-
-  /**
-   * Gets the layout animation duration for add, remove and relayout
-   * @return duration for the layout animations
-   */
-  float GetLayoutAnimationDuration();
-
   /**
    * @return the amount of rows in the table
    */