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";
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();
}
-// 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)
{
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";
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;
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 )
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:
}
}
- 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 );
}
}
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
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
}
}
+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
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 );
}
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 );
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;
}
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 );
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
}
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)
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);
- }
}
}
}
}
+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
*/
virtual void OnPan( PanGesture gesture );
+ /**
+ * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& size )
+ */
+ virtual void OnControlSizeSet( const Vector3& size );
+
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.
// 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>
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
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
{
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
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;
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
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
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 );
value = tableViewImpl.GetCellPadding();
break;
}
- case Toolkit::TableView::PROPERTY_LAYOUT_ANIMATION_DURATION:
- {
- value = tableViewImpl.GetLayoutAnimationDuration();
- break;
- }
case Toolkit::TableView::PROPERTY_LAYOUT_ROWS:
{
value = tableViewImpl.GetRowHeightsPropertyValue();
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 );
*/
float GetRelativeWidth( unsigned int columnIndex ) const;
- /**
- * @copydoc Toolkit::TableView::SetLayoutAnimationDuration
- */
- void SetLayoutAnimationDuration( float duration );
-
- /**
- * @copydoc Toolkit::TableView::GetLayoutAnimationDuration
- */
- float GetLayoutAnimationDuration();
-
-
/**
* @copydoc Toolkit::TableView::GetRows
*/
std::vector<float> mRelativeWidths;
Size mPadding;
bool mLayoutingChild;
- float mConstraintDuration;
};
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();
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
*/
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
*/