From: Xiangyin Ma Date: Wed, 4 Feb 2015 18:37:06 +0000 (+0000) Subject: Remove Constraints from Cluster,ToolBar,View & ImageView X-Git-Tag: dali_1.0.29~4^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=4c9e3c8180e813f24d7514b275abd0d79c155405 Remove Constraints from Cluster,ToolBar,View & ImageView Change-Id: I1225da0795796717dc750a5ff5a91f96225e3a72 --- diff --git a/optional/dali-toolkit/internal/controls/cluster/cluster-impl.cpp b/optional/dali-toolkit/internal/controls/cluster/cluster-impl.cpp index fa9ee42..d94a94b 100644 --- a/optional/dali-toolkit/internal/controls/cluster/cluster-impl.cpp +++ b/optional/dali-toolkit/internal/controls/cluster/cluster-impl.cpp @@ -26,6 +26,7 @@ // INTERNAL INCLUDES #include +#include using namespace Dali; @@ -92,6 +93,27 @@ void Cluster::OnInitialize() { } +void Cluster::OnControlSizeSet( const Vector3& targetSize ) +{ + mClusterSize = targetSize; + GetImpl(mClusterStyle).SetClusterSize(targetSize); + + for(ChildInfoIter iter = mChildren.begin(); iter != mChildren.end(); ++iter) + { + + if((*iter).mActor) + { + mClusterStyle.ApplyStyle( (*iter).mActor, + (*iter).mPositionIndex, + AlphaFunctions::EaseOut, + 0.f ); + } + } + + UpdateBackground(0.f); + UpdateTitle(0.f); +} + Cluster::~Cluster() { } @@ -389,6 +411,7 @@ void Cluster::SetStyle(Toolkit::ClusterStyle style) { unsigned int previousChildrenNum = mChildren.size(); mClusterStyle = style; + GetImpl(mClusterStyle).SetClusterSize(mClusterSize); unsigned int newChildrenNum = mClusterStyle.GetMaximumNumberOfChildren(); // New style supports less children (remove those that no longer belong) @@ -406,14 +429,12 @@ void Cluster::SetStyle(Toolkit::ClusterStyle style) mChildren.erase( removeStart, mChildren.end() ); } - // Remove constraints from previous style, and apply new style's constraints. for(ChildInfoIter iter = mChildren.begin(); iter != mChildren.end(); ++iter) { if((*iter).mActor) { - (*iter).mActor.RemoveConstraints(); - style.ApplyStyle( (*iter).mActor, + mClusterStyle.ApplyStyle( (*iter).mActor, (*iter).mPositionIndex, AlphaFunctions::EaseOut, CLUSTER_STYLE_CONSTRAINT_DURATION ); @@ -443,7 +464,6 @@ void Cluster::UpdateBackground(float duration) { if (mBackgroundImage) { - mBackgroundImage.RemoveConstraints(); mClusterStyle.ApplyStyleToBackground(mBackgroundImage, AlphaFunctions::EaseOut, duration); } } @@ -452,7 +472,6 @@ void Cluster::UpdateTitle(float duration) { if (mTitle) { - mTitle.RemoveConstraints(); mClusterStyle.ApplyStyleToTitle(mTitle, AlphaFunctions::EaseOut, duration); } } diff --git a/optional/dali-toolkit/internal/controls/cluster/cluster-impl.h b/optional/dali-toolkit/internal/controls/cluster/cluster-impl.h index 398b6a2..a7a30e0 100644 --- a/optional/dali-toolkit/internal/controls/cluster/cluster-impl.h +++ b/optional/dali-toolkit/internal/controls/cluster/cluster-impl.h @@ -256,6 +256,12 @@ private: // From Control */ virtual void OnInitialize(); + /** + * + * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize ) + */ + virtual void OnControlSizeSet( const Vector3& targetSize ); + protected: /** @@ -281,6 +287,7 @@ private: Toolkit::ClusterStyle mClusterStyle; ChildInfoContainer mChildren; + Vector3 mClusterSize; Actor mBackgroundImage; ///< Stores the background image. Actor mTitle; ///< Stores the text title. diff --git a/optional/dali-toolkit/internal/controls/cluster/cluster-style-impl.cpp b/optional/dali-toolkit/internal/controls/cluster/cluster-style-impl.cpp index 3440be7..e53b378 100644 --- a/optional/dali-toolkit/internal/controls/cluster/cluster-style-impl.cpp +++ b/optional/dali-toolkit/internal/controls/cluster/cluster-style-impl.cpp @@ -19,7 +19,7 @@ #include // EXTERNAL INCLUDES - +#include // INTERNAL INCLUDES #include @@ -175,110 +175,10 @@ const unsigned int CLUSTER_RANDOM_SEED(0x17eac9f3); ///< Random seed for const int STYLE_RANDOM_CHILDREN_NUMBER = 16; -// Constraints - -/** - * First order equation of the form y = Mx + C - * current' = current * relative + offset - */ -struct FirstOrderEquationConstraint -{ - /** - * @param relative The relative multiplier of the source property - * @param offset The offset to add onto the result. - */ - FirstOrderEquationConstraint(Vector3 relative, Vector3 offset = Vector3::ZERO) - : mRelative(relative), - mOffset(offset) - { - } - - Vector3 operator()(const Vector3& current, - const PropertyInput& sourceProperty) - { - const Vector3 source = sourceProperty.GetVector3(); - - return source * mRelative + mOffset; - } - -public: - - Vector3 mRelative; - Vector3 mOffset; -}; - -/** - * Depth Constraint. - * current' = current.xy | + Vector3::ONE.z - */ -struct DepthConstraint +Vector3 FirstOrderEquation( const Vector3& source, const Vector3& relative, const Vector3& offset = Vector3::ZERO ) { - /** - * constructor - */ - DepthConstraint() - { - } - - Vector3 operator()(const Vector3& current, - const PropertyInput& depthProperty) - { - Vector3 position(current); - position.z = depthProperty.GetFloat(); - return position; - } -}; - - -/** - * Position Constraint. - * current' = current * relative + offset - */ -struct PositionConstraint -{ - /** - * @param relative The relative multiplier of the source property - * @param offset The offset to add onto the result. - */ - PositionConstraint(Vector3 relative, Vector3 offset = Vector3::ZERO) - : mRelative(relative), - mOffset(offset) - { - } - - Vector3 operator()(const Vector3& current, - const PropertyInput& sourceProperty, - const PropertyInput& depthProperty) - { - const Vector3 source = sourceProperty.GetVector3(); - - Vector3 position(source * mRelative + mOffset); - position.z += depthProperty.GetFloat(); - return position; - } - -public: - - Vector3 mRelative; - Vector3 mOffset; -}; - -template -struct SetConstraint -{ - SetConstraint(T value) - : mValue(value) - { - - } - - T operator()(const T& current) - { - return mValue; - } - - T mValue; -}; + return source * relative + offset; +} // random data generator ////////////////////////////////////////////////////// @@ -318,7 +218,8 @@ ClusterStyle::ClusterStyle() mTitleSize(Vector3::ONE), mBackgroundPositionRelative(Vector3::ONE), mBackgroundPositionOffset(Vector3::ZERO), - mBackgroundSize(Vector3::ONE) + mBackgroundSize(Vector3::ONE), + mClusterSize( Vector3::ZERO ) { } @@ -337,6 +238,24 @@ unsigned int ClusterStyle::GetMaximumNumberOfChildren() const return mMaxChildren; } +void ClusterStyle::ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds) +{ + Apply( background, + FirstOrderEquation( GetClusterSize(), mBackgroundPositionRelative, mBackgroundPositionOffset ), + FirstOrderEquation( GetClusterSize(), mBackgroundSize ), + alpha, + durationSeconds); +} + +void ClusterStyle::ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds) +{ + Apply( title, + FirstOrderEquation( GetClusterSize(), mTitlePositionRelative, mTitlePositionOffset ), + FirstOrderEquation( GetClusterSize(), mTitleSize ), + alpha, + durationSeconds); +} + void ClusterStyle::SetTitleProperties(const Vector3& relativePosition, const Vector3& offsetPosition, const Vector3& size) @@ -355,6 +274,64 @@ void ClusterStyle::SetBackgroundProperties(const Vector3& relativePosition, mBackgroundSize = size; } +void ClusterStyle::SetClusterSize( const Vector3& clusterSize ) +{ + mClusterSize = clusterSize; +} + +Vector3 ClusterStyle::GetClusterSize() const +{ + return mClusterSize; +} + +void ClusterStyle::Apply( Actor actor, + const Vector3& position, + const Vector3& size, + AlphaFunction alpha, + const TimePeriod& durationSeconds) +{ + float animationDuration = durationSeconds.delaySeconds + durationSeconds.durationSeconds; + if( animationDuration > 0.f ) + { + Animation animation = Animation::New(animationDuration); + animation.MoveTo( actor, position, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds ); + animation.Resize( actor, size, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds ); + animation.Play(); + } + else + { + actor.SetPosition( position ); + actor.SetSize( size ); + } +} + +void ClusterStyle::Apply( Actor actor, + const Vector3& position, + const Vector3& size, + const Quaternion& rotation, + const Vector3& scale, + AlphaFunction alpha, + const TimePeriod& durationSeconds) +{ + float animationDuration = durationSeconds.delaySeconds + durationSeconds.durationSeconds; + if( animationDuration > 0.f ) + { + Animation animation = Animation::New(animationDuration); + animation.MoveTo( actor, position, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds ); + animation.Resize( actor, size, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds ); + animation.RotateTo( actor, rotation, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds ); + animation.ScaleTo( actor, scale, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds ); + animation.Play(); + } + else + { + actor.SetPosition( position ); + actor.SetSize( size ); + actor.SetRotation( rotation ); + actor.SetScale( scale ); + } +} + // ClusterStyleStandard /////////////////////////////////////////////////////// ClusterStylePtr ClusterStyleStandard::New(StyleType style) @@ -449,78 +426,16 @@ void ClusterStyleStandard::ApplyStyle(Actor child, unsigned int index, AlphaFunc // counter top-left parent origin and top-left anchor point. const Vector3 position = mPositions[index] - Vector3(0.5f, 0.5f, 0.0f) + Vector3(size, size, 0.0f) * 0.5f; - Constraint constraint = Constraint::New( Actor::POSITION, - ParentSource( Actor::SIZE ), - FirstOrderEquationConstraint(Vector3(position.x, position.y, 0.0f), - Vector3(0.0f, 0.0f, position.z)) ); - - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - child.ApplyConstraint(constraint); - - constraint = Constraint::New( Actor::SIZE, - ParentSource( Actor::SIZE ), - FirstOrderEquationConstraint(Vector3::ONE * size) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - child.ApplyConstraint(constraint); - - constraint = Constraint::New( Actor::ROTATION, - SetConstraint(Quaternion()) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - child.ApplyConstraint(constraint); - - constraint = Constraint::New( Actor::SCALE, - SetConstraint(Vector3::ONE) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - child.ApplyConstraint(constraint); + Apply( child, + FirstOrderEquation( GetClusterSize(), Vector3(position.x, position.y, 0.0f), Vector3(0.0f, 0.0f, position.z) ), + FirstOrderEquation( GetClusterSize(), Vector3::ONE * size ), + Quaternion(), + Vector3::ONE, + alpha, + durationSeconds); } } -void ClusterStyleStandard::ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds) -{ - Constraint constraint = Constraint::New( Actor::POSITION, - ParentSource( Actor::SIZE ), - FirstOrderEquationConstraint(mBackgroundPositionRelative, mBackgroundPositionOffset) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - background.ApplyConstraint(constraint); - - constraint = Constraint::New( Actor::SIZE, - ParentSource( Actor::SIZE ), - FirstOrderEquationConstraint(mBackgroundSize) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - background.ApplyConstraint(constraint); -} - -void ClusterStyleStandard::ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds) -{ - Constraint constraint = Constraint::New( Actor::POSITION, - ParentSource( Actor::SIZE ), - FirstOrderEquationConstraint(mTitlePositionRelative, mTitlePositionOffset) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - title.ApplyConstraint(constraint); - - constraint = Constraint::New( Actor::SIZE, - ParentSource( Actor::SIZE ), - FirstOrderEquationConstraint(mTitleSize) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - title.ApplyConstraint(constraint); -} - // ClusterStyleRandom ///////////////////////////////////////////////////////// ClusterStylePtr ClusterStyleRandom::New() @@ -552,85 +467,16 @@ void ClusterStyleRandom::ApplyStyle(Actor child, unsigned int index, AlphaFuncti 0.0f); Property::Index depthProperty = child.GetPropertyIndex(Toolkit::Cluster::CLUSTER_ACTOR_DEPTH); + float depthPropertyValue = child.GetProperty( depthProperty ); - Constraint constraint = Constraint::New( Actor::POSITION, - ParentSource( Actor::SIZE ), - FirstOrderEquationConstraint( Vector3(position.x, position.y, 0.0f), - Vector3(0.0f, 0.0f, position.z) ) ); - - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - child.ApplyConstraint(constraint); - - // this constraint overrides the Z position. setting it to cluster-actor-depth - constraint = Constraint::New( Actor::POSITION, - LocalSource( depthProperty ), - DepthConstraint() ); - - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - child.ApplyConstraint(constraint); - - constraint = Constraint::New( Actor::SIZE, - ParentSource( Actor::SIZE ), - FirstOrderEquationConstraint(Vector3::ONE * size) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - child.ApplyConstraint(constraint); - - constraint = Constraint::New( Actor::ROTATION, - SetConstraint(Quaternion(rotation, Vector3::ZAXIS)) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - child.ApplyConstraint(constraint); - - constraint = Constraint::New( Actor::SCALE, - SetConstraint(Vector3::ONE) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - child.ApplyConstraint(constraint); -} -void ClusterStyleRandom::ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds) -{ - Constraint constraint = Constraint::New( Actor::POSITION, - ParentSource( Actor::SIZE ), - FirstOrderEquationConstraint(mBackgroundPositionRelative, mBackgroundPositionOffset) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - background.ApplyConstraint(constraint); - - constraint = Constraint::New( Actor::SIZE, - ParentSource( Actor::SIZE ), - FirstOrderEquationConstraint(mBackgroundSize) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - background.ApplyConstraint(constraint); -} - -void ClusterStyleRandom::ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds) -{ - Constraint constraint = Constraint::New( Actor::POSITION, - ParentSource( Actor::SIZE ), - FirstOrderEquationConstraint(mTitlePositionRelative, mTitlePositionOffset) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - title.ApplyConstraint(constraint); - - constraint = Constraint::New( Actor::SIZE, - ParentSource( Actor::SIZE ), - FirstOrderEquationConstraint(mTitleSize) ); - constraint.SetApplyTime(durationSeconds); - constraint.SetAlphaFunction(alpha); - constraint.SetRemoveAction(Constraint::Bake); - title.ApplyConstraint(constraint); + Apply( child, + FirstOrderEquation( GetClusterSize(), Vector3(position.x, position.y, 0.0f), Vector3(0.0f, 0.0f, depthPropertyValue) ), + FirstOrderEquation( GetClusterSize(), Vector3::ONE * size), + Quaternion(rotation, Vector3::ZAXIS), + Vector3::ONE, + alpha, + durationSeconds); } } // namespace Internal diff --git a/optional/dali-toolkit/internal/controls/cluster/cluster-style-impl.h b/optional/dali-toolkit/internal/controls/cluster/cluster-style-impl.h index df08a47..a7f3468 100644 --- a/optional/dali-toolkit/internal/controls/cluster/cluster-style-impl.h +++ b/optional/dali-toolkit/internal/controls/cluster/cluster-style-impl.h @@ -55,12 +55,17 @@ public: /** * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground */ - virtual void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0; + virtual void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds); /** * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle */ - virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0; + virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds); + + /** + * Set the size of cluster + */ + void SetClusterSize( const Vector3& clusterSize ); protected: @@ -90,6 +95,43 @@ protected: const Vector3& offsetPosition, const Vector3& size); + /** + * Get the size of cluster. + * @return the cluster size + */ + Vector3 GetClusterSize() const; + + /** + * Apply the given position & size to the actor + * @param[in] position The target position + * @param[in] size The target size + * @param[in] size The size to resize to + * @param[in] alpha The alpha function to use. + * @param[in] durationSeconds The time period to apply this style. + */ + void Apply( Actor actor, + const Vector3& position, + const Vector3& size, + AlphaFunction alpha, + const TimePeriod& durationSeconds); + /** + * Apply the given position & size to the actor + * @param[in] actor The actor to apply the changes + * @param[in] position The target position + * @param[in] size The target size + * @param[in] rotation The target Quaternion value + * @param[in] scale The target scale + * @param[in] alpha The alpha function to use. + * @param[in] durationSeconds The time period to apply this style. + */ + void Apply( Actor actor, + const Vector3& position, + const Vector3& size, + const Quaternion& rotation, + const Vector3& scale, + AlphaFunction alpha, + const TimePeriod& durationSeconds); + protected: /** @@ -111,7 +153,7 @@ protected: Vector3 mBackgroundPositionRelative; ///< Background's position relative to size of cluster Vector3 mBackgroundPositionOffset; ///< Background's position offset Vector3 mBackgroundSize; ///< Background's size relative to size of cluster - + Vector3 mClusterSize; ///< The size of cluster }; /** @@ -139,16 +181,6 @@ public: */ void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds); - /** - * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground - */ - void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds); - - /** - * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle - */ - void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds); - private: /** @@ -197,16 +229,6 @@ public: */ void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds); - /** - * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground - */ - void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds); - - /** - * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle - */ - void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds); - protected: /** diff --git a/optional/dali-toolkit/internal/controls/image-view/image-view-impl.cpp b/optional/dali-toolkit/internal/controls/image-view/image-view-impl.cpp index 45ab799..7cb6cb4 100644 --- a/optional/dali-toolkit/internal/controls/image-view/image-view-impl.cpp +++ b/optional/dali-toolkit/internal/controls/image-view/image-view-impl.cpp @@ -109,7 +109,6 @@ void ImageView::Initialize() Image emptyImage; mImageActor = ImageActor::New( emptyImage ); self.Add( mImageActor ); - mImageActor.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); mImageActor.SetParentOrigin( ParentOrigin::CENTER ); } @@ -118,6 +117,11 @@ ImageView::~ImageView() } +void ImageView::OnControlSizeSet( const Vector3& targetSize ) +{ + mImageActor.SetSize( targetSize ); +} + void ImageView::SetImage(const std::string& filename, ImageType type, float min, float max) { switch(type) diff --git a/optional/dali-toolkit/internal/controls/image-view/image-view-impl.h b/optional/dali-toolkit/internal/controls/image-view/image-view-impl.h index 69b2f1b..e1f837f 100644 --- a/optional/dali-toolkit/internal/controls/image-view/image-view-impl.h +++ b/optional/dali-toolkit/internal/controls/image-view/image-view-impl.h @@ -138,6 +138,12 @@ protected: */ virtual ~ImageView(); + /** + * + * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize ) + */ + virtual void OnControlSizeSet( const Vector3& targetSize ); + private: /** diff --git a/optional/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp b/optional/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp index ed9d27b..fad0ade 100644 --- a/optional/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp +++ b/optional/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp @@ -534,7 +534,6 @@ void MaskedImageView::Initialize( unsigned int targetWidth, // Create actor to display result of off-screen rendering mDestinationImageActor = ImageActor::New( mDestinationImage ); self.Add( mDestinationImageActor ); - mDestinationImageActor.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); mDestinationImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); // Start the masking operation @@ -633,6 +632,11 @@ MaskedImageView::~MaskedImageView() } } +void MaskedImageView::OnControlSizeSet( const Vector3& targetSize ) +{ + mDestinationImageActor.SetSize(targetSize); +} + void MaskedImageView::OnRenderTaskFinished( Dali::RenderTask& renderTask ) { Toolkit::MaskedImageView handle( GetOwner() ); diff --git a/optional/dali-toolkit/internal/controls/image-view/masked-image-view-impl.h b/optional/dali-toolkit/internal/controls/image-view/masked-image-view-impl.h index f9af407..a1c8285 100644 --- a/optional/dali-toolkit/internal/controls/image-view/masked-image-view-impl.h +++ b/optional/dali-toolkit/internal/controls/image-view/masked-image-view-impl.h @@ -185,6 +185,12 @@ protected: */ virtual ~MaskedImageView(); + /** + * + * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize ) + */ + virtual void OnControlSizeSet( const Vector3& targetSize ); + private: // Undefined diff --git a/optional/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp b/optional/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp index ae0c35e..d49c718 100644 --- a/optional/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp +++ b/optional/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp @@ -73,7 +73,7 @@ void ToolBar::SetBackground( Actor background ) // ToolBar image background.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); background.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); - background.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); + background.SetSize( mToolBarSize ); RenderableActor renderableActor = RenderableActor::DownCast( background ); if ( renderableActor ) @@ -82,6 +82,7 @@ void ToolBar::SetBackground( Actor background ) } Self().Add( background ); + mBackground = background; } void ToolBar::AddControl( Actor control, float relativeSize, Toolkit::Alignment::Type alignment, const Toolkit::Alignment::Padding& padding ) @@ -356,6 +357,12 @@ void ToolBar::OnRelaidOut( Vector2 size, ActorSizeContainer& container ) Relayout( mLayout, size, container ); } +void ToolBar::OnControlSizeSet( const Vector3& targetSize ) +{ + mToolBarSize = targetSize; + mBackground.SetSize( mToolBarSize ); +} + } // namespace Internal } // namespace Toolkit diff --git a/optional/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.h b/optional/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.h index f12bf5a..2b2fa6d 100644 --- a/optional/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.h +++ b/optional/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.h @@ -88,6 +88,12 @@ private: // From Control */ virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container ); + /** + * + * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize ) + */ + virtual void OnControlSizeSet( const Vector3& targetSize ); + private: /** */ @@ -136,6 +142,8 @@ private: float mRightRelativeSpace; ///< Relative space between center and right groups of controls. float mAccumulatedRelativeSpace; ///< Stores the total percentage space used by controls. bool mInitializing; ///< Allows the use of Actor's API to add controls. + Vector3 mToolBarSize; ///< The size of tool bar + Actor mBackground; ///< The background of the tool bar std::map mControls; ///< Stores a relationship between controls and their alignments used to place them inside the table view. }; diff --git a/optional/dali-toolkit/internal/controls/view/view-impl.cpp b/optional/dali-toolkit/internal/controls/view/view-impl.cpp index 82b91b7..6c374c0 100644 --- a/optional/dali-toolkit/internal/controls/view/view-impl.cpp +++ b/optional/dali-toolkit/internal/controls/view/view-impl.cpp @@ -136,7 +136,7 @@ void View::SetBackground( ImageActor backgroundImage ) mBackgroundLayer = Layer::New(); mBackgroundLayer.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - mBackgroundLayer.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); + mBackgroundLayer.SetSize( mViewSize ); // Add background layer to custom actor. Self().Add( mBackgroundLayer ); @@ -156,12 +156,7 @@ void View::SetBackground( ImageActor backgroundImage ) } backgroundImage.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - Constraint constraint = Constraint::New( - Actor::SCALE, - LocalSource( Actor::SIZE ), - ParentSource( Actor::SIZE ), - ScaleToFillXYKeepAspectRatioConstraint() ); - backgroundImage.ApplyConstraint( constraint ); + backgroundImage.SetScale( FillXYKeepAspectRatio( mViewSize, backgroundImage.GetSize() ) ); mBackgroundLayer.Add( backgroundImage ); } @@ -299,6 +294,20 @@ void View::OnInitialize() } } +void View::OnControlSizeSet( const Vector3& targetSize ) +{ + mViewSize = targetSize; + if( mBackgroundLayer ) + { + mBackgroundLayer.SetSize( mViewSize ); + if( mBackgroundLayer.GetChildCount() > 0 ) + { + Actor background = mBackgroundLayer.GetChildAt(0); + background.SetScale( FillXYKeepAspectRatio( mViewSize, background.GetSize() ) ); + } + } +} + View::Orientation View::DegreeToViewOrientation( Degree degree ) { View::Orientation orientation = PORTRAIT; diff --git a/optional/dali-toolkit/internal/controls/view/view-impl.h b/optional/dali-toolkit/internal/controls/view/view-impl.h index b956eae..5352afe 100644 --- a/optional/dali-toolkit/internal/controls/view/view-impl.h +++ b/optional/dali-toolkit/internal/controls/view/view-impl.h @@ -137,6 +137,12 @@ private: // From Control */ virtual void OnInitialize(); + /** + * + * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize ) + */ + virtual void OnControlSizeSet( const Vector3& targetSize ); + private: @@ -174,6 +180,7 @@ private: Animation mRotateAnimation; ///< The animation which rotates the view (and all layers added to it) float mOrientationFunction[4]; ///< The orientation function used to transform from degrees to the internal orientation. bool mAutoRotateEnabled; ///< Whether the view rotates if the OrientationChanged method is called. + Vector3 mViewSize; ///< The Control Size Toolkit::View::OrientationAnimationStartedSignalType mOrientationAnimationStartedSignal; };