X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fcluster%2Fcluster-impl.cpp;h=d43d63a42ae3197f69ed5046810f0c4a981f4156;hp=1c4a249afffd9dd27f8a5d746a915b393f38d429;hb=4b347781c8761d2909b235ded2e98d272fa9ac16;hpb=e2eda444afbe82e9591fe198eef339227f90a616;ds=sidebyside diff --git a/dali-toolkit/internal/controls/cluster/cluster-impl.cpp b/dali-toolkit/internal/controls/cluster/cluster-impl.cpp index 1c4a249..d43d63a 100644 --- a/dali-toolkit/internal/controls/cluster/cluster-impl.cpp +++ b/dali-toolkit/internal/controls/cluster/cluster-impl.cpp @@ -1,39 +1,37 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // CLASS HEADER #include // EXTERNAL INCLUDES #include +#include // for strcmp +#include +#include +#include #include // INTERNAL INCLUDES #include +#include -using namespace std; using namespace Dali; -namespace // unnamed namespace -{ - -const float CLUSTER_STYLE_CONSTRAINT_DURATION = 1.0f; - -} - namespace Dali { @@ -48,15 +46,19 @@ namespace BaseHandle Create() { - Toolkit::ClusterStyleStandard s = Toolkit::ClusterStyleStandard::New(Toolkit::ClusterStyleStandard::ClusterStyle1); + Toolkit::ClusterStyleStandard s = Toolkit::ClusterStyleStandard::New( Toolkit::ClusterStyleStandard::ClusterStyle1 ); return Toolkit::Cluster::New( s ); } -TypeRegistration mType( typeid(Toolkit::Cluster), typeid(Toolkit::Control), Create ); +DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Cluster, Toolkit::Control, Create ) -TypeAction a1(mType, Toolkit::Cluster::ACTION_EXPAND , &Cluster::DoAction); -TypeAction a2(mType, Toolkit::Cluster::ACTION_COLLAPSE , &Cluster::DoAction); -TypeAction a3(mType, Toolkit::Cluster::ACTION_TRANSFORM, &Cluster::DoAction); +DALI_ACTION_REGISTRATION( Cluster, "expand", ACTION_EXPAND ) +DALI_ACTION_REGISTRATION( Cluster, "collapse", ACTION_COLLAPSE ) +DALI_ACTION_REGISTRATION( Cluster, "transform", ACTION_TRANSFORM ) + +DALI_TYPE_REGISTRATION_END() + +const float CLUSTER_STYLE_CONSTRAINT_DURATION = 1.0f; } @@ -80,7 +82,7 @@ Dali::Toolkit::Cluster Cluster::New(Toolkit::ClusterStyle& style) } Cluster::Cluster(Toolkit::ClusterStyle& style) -: ControlImpl(true/*requires touch*/), +: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ), mClusterStyle(style), mExpandedCount(0) { @@ -90,6 +92,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() { } @@ -138,7 +161,7 @@ void Cluster::AddChildInfoAt( ChildInfo childInfo, unsigned int index ) Property::Index depthProperty = child.GetPropertyIndex(Toolkit::Cluster::CLUSTER_ACTOR_DEPTH); if(depthProperty == Property::INVALID_INDEX) { - depthProperty = child.RegisterProperty(Toolkit::Cluster::CLUSTER_ACTOR_DEPTH, depth); + child.RegisterProperty(Toolkit::Cluster::CLUSTER_ACTOR_DEPTH, depth); } // not added prior @@ -321,9 +344,9 @@ void Cluster::TransformChild( unsigned int index, const Vector3& position, const child.RemoveConstraints(); Animation animation = Animation::New(period.delaySeconds + period.durationSeconds); - animation.AnimateTo( Property(child, Actor::POSITION), position, AlphaFunctions::EaseOut, period); - animation.AnimateTo( Property(child, Actor::SCALE), scale, AlphaFunctions::EaseOut, period); - animation.AnimateTo( Property(child, Actor::ROTATION), rotation, AlphaFunctions::EaseOut, period); + animation.AnimateTo( Property(child, Actor::Property::POSITION), position, AlphaFunctions::EaseOut, period); + animation.AnimateTo( Property(child, Actor::Property::SCALE), scale, AlphaFunctions::EaseOut, period); + animation.AnimateTo( Property(child, Actor::Property::ORIENTATION), rotation, AlphaFunctions::EaseOut, period); animation.Play(); } } @@ -387,6 +410,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) @@ -404,14 +428,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 ); @@ -441,7 +463,6 @@ void Cluster::UpdateBackground(float duration) { if (mBackgroundImage) { - mBackgroundImage.RemoveConstraints(); mClusterStyle.ApplyStyleToBackground(mBackgroundImage, AlphaFunctions::EaseOut, duration); } } @@ -450,7 +471,6 @@ void Cluster::UpdateTitle(float duration) { if (mTitle) { - mTitle.RemoveConstraints(); mClusterStyle.ApplyStyleToTitle(mTitle, AlphaFunctions::EaseOut, duration); } } @@ -527,29 +547,29 @@ void Cluster::OnControlChildRemove(Actor& child) child.RemoveConstraints(); } -bool Cluster::DoAction(BaseObject* object, const std::string& actionName, const std::vector& attributes) +bool Cluster::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes) { bool ret = false; - Dali::BaseHandle handle(object); + Dali::BaseHandle handle( object ); - Toolkit::Cluster cluster = Toolkit::Cluster::DownCast(handle); + Toolkit::Cluster cluster = Toolkit::Cluster::DownCast( handle ); - DALI_ASSERT_ALWAYS(cluster); + DALI_ASSERT_ALWAYS( cluster ); - if(Toolkit::Cluster::ACTION_EXPAND == actionName) + if( 0 == strcmp( actionName.c_str(), ACTION_EXPAND ) ) { - GetImpl(cluster).DoExpandAction(attributes); + GetImpl( cluster ).DoExpandAction( attributes ); ret = true; } - else if(Toolkit::Cluster::ACTION_COLLAPSE == actionName) + else if( 0 == strcmp( actionName.c_str(), ACTION_COLLAPSE ) ) { - GetImpl(cluster).DoCollapseAction(attributes); + GetImpl( cluster ).DoCollapseAction( attributes ); ret = true; } - else if(Toolkit::Cluster::ACTION_TRANSFORM == actionName) + else if( 0 == strcmp( actionName.c_str(), ACTION_TRANSFORM ) ) { - GetImpl(cluster).DoTransformAction(attributes); + GetImpl( cluster ).DoTransformAction( attributes ); ret = true; }