From: Kingsley Stephens Date: Fri, 17 Apr 2015 12:14:56 +0000 (+0100) Subject: Delete view from toolkit and move cluster into demo X-Git-Tag: dali_1.0.40~6^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=d02debcc6c1e5876da270fc648fa5d880d75120b Delete view from toolkit and move cluster into demo Change-Id: I079a8b85eaedc2a9915db163f6ab1e5f17557c49 --- diff --git a/automated-tests/src/dali-toolkit/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt index 9372e84..e522f31 100644 --- a/automated-tests/src/dali-toolkit/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit/CMakeLists.txt @@ -15,7 +15,6 @@ SET(TC_SOURCES utc-Dali-Builder.cpp utc-Dali-CarouselEffect.cpp utc-Dali-CheckBoxButton.cpp - utc-Dali-Cluster.cpp utc-Dali-CubeTransitionEffect.cpp utc-Dali-DepthLayout.cpp utc-Dali-DisplacementEffect.cpp diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Cluster.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Cluster.cpp deleted file mode 100644 index b83ff8c..0000000 --- a/automated-tests/src/dali-toolkit/utc-Dali-Cluster.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * 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. - * - */ - -#include -#include -#include -#include - - -using namespace Dali; -using namespace Dali::Toolkit; - -namespace -{ - -static bool gObjectCreatedCallBackCalled; - -static void TestCallback(BaseHandle handle) -{ - gObjectCreatedCallBackCalled = true; -} - -} // namespace - - -void cluster_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void cluster_cleanup(void) -{ - test_return_value = TET_PASS; -} - -int UtcDaliClusterNew(void) -{ - ToolkitTestApplication application; - - // Create the Cluster actor - ClusterStyle style = ClusterStyleStandard::New(ClusterStyleStandard::ClusterStyle1); - Cluster cluster = Cluster::New(style); - - DALI_TEST_CHECK(cluster); - - //Additional check to ensure object is created by checking if it's registered - ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); - DALI_TEST_CHECK( registry ); - - gObjectCreatedCallBackCalled = false; - registry.ObjectCreatedSignal().Connect(&TestCallback); - { - ClusterStyle style = ClusterStyleStandard::New(ClusterStyleStandard::ClusterStyle1); - Cluster cluster = Cluster::New(style); - } - DALI_TEST_CHECK( gObjectCreatedCallBackCalled ); - END_TEST; -} - -int UtcDaliClusterDownCast(void) -{ - ToolkitTestApplication application; - - // Create the Cluster actor - ClusterStyle style = ClusterStyleRandom::New(); - const Cluster clusterConst = Cluster::New(style); - Cluster cluster(clusterConst); - - BaseHandle handle(cluster); - - Cluster newCluster = Cluster::DownCast( handle ); - DALI_TEST_CHECK( cluster ); - DALI_TEST_CHECK( newCluster == cluster ); - END_TEST; -} - -int UtcDaliClusterAddAndRemoveChild(void) -{ - ToolkitTestApplication application; - - // Create the Cluster actor - ClusterStyle style = ClusterStyleStandard::New(ClusterStyleStandard::ClusterStyle1); - Cluster cluster = Cluster::New(style); - - Actor childActor1 = Actor::New(); - Actor childActor2 = Actor::New(); - Actor childActor3 = Actor::New(); - Actor childActor4 = Actor::New(); - - // Add the first child and check it is added to the end - cluster.AddChild(childActor1); - DALI_TEST_CHECK( cluster.GetChildAt(0) == childActor1); - DALI_TEST_CHECK( !cluster.GetChildAt(1) ); - DALI_TEST_CHECK( cluster.GetTotalCount() == 1 ); - - // Add the second child to the given position and check it is added - cluster.AddChild(childActor2, 1); - DALI_TEST_CHECK( cluster.GetChildAt(1) == childActor2); - DALI_TEST_CHECK( cluster.GetTotalCount() == 2 ); - - // Add the third child with depth index 1 and check it is added to the end - cluster.AddChildAt(childActor3, 1); - DALI_TEST_CHECK( cluster.GetChildAt(2) == childActor3); - DALI_TEST_CHECK( cluster.GetTotalCount() == 3 ); - - // Add the fourth child with depth index 2 to the given position and check it is added - cluster.AddChildAt(childActor4, 2, 3); - DALI_TEST_CHECK( cluster.GetChildAt(3) == childActor4); - DALI_TEST_CHECK( cluster.GetTotalCount() == 4 ); - - // Remove the child in the given position and check it's removed - cluster.RemoveChildAt(3); - DALI_TEST_CHECK( !cluster.GetChildAt(3) ); - DALI_TEST_CHECK( cluster.GetTotalCount() == 3 ); - END_TEST; -} - -int UtcDaliClusterExpandAndCollapseChild(void) -{ - ToolkitTestApplication application; - - // Create the Cluster actor - ClusterStyle style = ClusterStyleStandard::New(ClusterStyleStandard::ClusterStyle1); - Cluster cluster = Cluster::New(style); - - Actor childActor1 = Actor::New(); - Actor childActor2 = Actor::New(); - Actor childActor3 = Actor::New(); - Actor childActor4 = Actor::New(); - - // Add the child actors - cluster.AddChild(childActor1); - cluster.AddChild(childActor2); - cluster.AddChildAt(childActor3, 1); - cluster.AddChildAt(childActor4, 2, 3); - - // Expand child actor 3 - cluster.ExpandChild(2); - DALI_TEST_CHECK( cluster.GetExpandedCount() == 1 ); - - // Expand child actor 4 - cluster.ExpandChild(3); - DALI_TEST_CHECK( cluster.GetExpandedCount() == 2 ); - - // Collapse child actor 3 - cluster.CollapseChild(2); - DALI_TEST_CHECK( cluster.GetExpandedCount() == 1 ); - - // Expand all children - cluster.ExpandAllChildren(); - DALI_TEST_CHECK( cluster.GetExpandedCount() == 4 ); - - // Collpase all children - cluster.CollapseAllChildren(); - DALI_TEST_CHECK( cluster.GetExpandedCount() == 0 ); - - // Transform and restore the child - cluster.TransformChild(1, Vector3(10.0f, 10.0f, 1.0f), Vector3(1.0f, 1.0f, 1.0f), Quaternion( Radian(0.0f), Vector3::YAXIS), AlphaFunctions::EaseOut, 0.5f); - cluster.RestoreChild(1, AlphaFunctions::EaseOut, 0.25f, true); - END_TEST; -} - -int UtcDaliClusterSetAndGetStyle(void) -{ - ToolkitTestApplication application; - - // Create the default cluster style - ClusterStyle defaultStyle = ClusterStyleStandard::New(ClusterStyleStandard::ClusterStyle1); - DALI_TEST_CHECK( defaultStyle.GetMaximumNumberOfChildren() > 0 ); - - // Add style to background and title - Actor background = Actor::New(); - Actor title = Actor::New(); - defaultStyle.ApplyStyleToBackground(background, AlphaFunctions::EaseOut, 1.0f); - defaultStyle.ApplyStyleToTitle(title, AlphaFunctions::EaseOut, 1.0f); - - // Create the Cluster actor with the default style - Cluster cluster = Cluster::New(defaultStyle); - DALI_TEST_CHECK( cluster.GetStyle() == defaultStyle ); - cluster.SetBackgroundImage(background); - cluster.SetTitle(title); - - // Create a new style and apply it to the cluster - ClusterStyle newStyle = ClusterStyleRandom::New(); - cluster.SetStyle(newStyle); - DALI_TEST_CHECK( cluster.GetStyle() == newStyle ); - END_TEST; -} diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h index 0e705e2..f9bdac1 100644 --- a/dali-toolkit/dali-toolkit.h +++ b/dali-toolkit/dali-toolkit.h @@ -30,8 +30,6 @@ #include #include #include -#include -#include #include #include #include @@ -76,7 +74,6 @@ #include #include #include -#include #include #include diff --git a/dali-toolkit/internal/controls/alignment/alignment-impl.cpp b/dali-toolkit/internal/controls/alignment/alignment-impl.cpp index 16d0cab..b06e57b 100644 --- a/dali-toolkit/internal/controls/alignment/alignment-impl.cpp +++ b/dali-toolkit/internal/controls/alignment/alignment-impl.cpp @@ -377,7 +377,7 @@ Toolkit::Alignment Alignment::New( Toolkit::Alignment::Type horizontal, Toolkit: // Create the implementation, temporarily owned on stack IntrusivePtr< Alignment > internalAlignment = new Alignment( horizontal, vertical ); - // Pass ownership to Toolkit::View + // Pass ownership to Toolkit::Alignment Toolkit::Alignment alignment( *internalAlignment ); // Second-phase init of the implementation diff --git a/dali-toolkit/internal/controls/cluster/cluster-impl.cpp b/dali-toolkit/internal/controls/cluster/cluster-impl.cpp deleted file mode 100644 index 73d13c8..0000000 --- a/dali-toolkit/internal/controls/cluster/cluster-impl.cpp +++ /dev/null @@ -1,583 +0,0 @@ -/* - * 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 Dali; - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -namespace -{ - -BaseHandle Create() -{ - Toolkit::ClusterStyleStandard s = Toolkit::ClusterStyleStandard::New( Toolkit::ClusterStyleStandard::ClusterStyle1 ); - return Toolkit::Cluster::New( s ); -} - -DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Cluster, Toolkit::Control, Create ) - -DALI_ACTION_REGISTRATION( Toolkit, Cluster, "expand", ACTION_EXPAND ) -DALI_ACTION_REGISTRATION( Toolkit, Cluster, "collapse", ACTION_COLLAPSE ) -DALI_ACTION_REGISTRATION( Toolkit, Cluster, "transform", ACTION_TRANSFORM ) - -DALI_TYPE_REGISTRATION_END() - -const float CLUSTER_STYLE_CONSTRAINT_DURATION = 1.0f; - -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Cluster -/////////////////////////////////////////////////////////////////////////////////////////////////// - -Dali::Toolkit::Cluster Cluster::New(Toolkit::ClusterStyle& style) -{ - // Create the implementation - ClusterPtr cluster(new Cluster(style)); - - // Pass ownership to CustomActor via derived handle - Dali::Toolkit::Cluster handle(*cluster); - - // Second-phase init of the implementation - // This can only be done after the CustomActor connection has been made... - cluster->Initialize(); - - return handle; -} - -Cluster::Cluster(Toolkit::ClusterStyle& style) -: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | DISABLE_SIZE_NEGOTIATION ) ), - mClusterStyle(style), - mExpandedCount(0) -{ -} - -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() -{ -} - -void Cluster::AddChild( Actor child ) -{ - // automatically add child with a position at end. - AddChild( child, mChildren.size() ); -} - -void Cluster::AddChild( Actor child, unsigned int positionIndex ) -{ - AddChildInfo( ChildInfo(child, positionIndex) ); -} - -void Cluster::AddChildAt( Actor child, unsigned int index ) -{ - // automatically add child with a position at end. - AddChild( child, mChildren.size() ); -} - -void Cluster::AddChildAt( Actor child, unsigned int positionIndex, unsigned int index ) -{ - AddChildInfoAt( ChildInfo(child, positionIndex), index ); -} - -void Cluster::AddChildInfo( ChildInfo childInfo ) -{ - AddChildInfoAt(childInfo, mChildren.size()); -} - -void Cluster::AddChildInfoAt( ChildInfo childInfo, unsigned int index ) -{ - // check that the child is valid - DALI_ASSERT_ALWAYS( childInfo.mActor ); - - ChildInfoIter offset = index < mChildren.size() ? (mChildren.begin() + index) : mChildren.end(); - // now perform customization on this child. - - // adopt the child - if(childInfo.mActor.GetParent() != Self()) - { - Actor& child = childInfo.mActor; - const float depth = std::distance(mChildren.begin(), offset); - - Property::Index depthProperty = child.GetPropertyIndex(Toolkit::Cluster::CLUSTER_ACTOR_DEPTH); - if(depthProperty == Property::INVALID_INDEX) - { - child.RegisterProperty(Toolkit::Cluster::CLUSTER_ACTOR_DEPTH, depth); - } - - // not added prior - Self().Add( childInfo.mActor ); - mChildren.insert( offset, childInfo ); - - // Use parent position plus relative position. - child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION ); - - // remove old constraints - child.RemoveConstraints(); - - // apply new constraints to the child - mClusterStyle.ApplyStyle(child, childInfo.mPositionIndex, AlphaFunctions::EaseOut, 0.0f); - } - else - { - // already added. - ChildInfoContainer mNewChildren; - ChildInfoIter iter = mChildren.begin(); - float depth = 0.0f; - - for( ; iter != mChildren.end(); ++iter) - { - if(iter == offset) - { - SetDepth(childInfo, depth); - depth++; - // insert the new childInfo before offset. - mNewChildren.push_back(childInfo); - } - // copy all children except the one that we wish to move. - if((*iter).mActor != childInfo.mActor) - { - SetDepth(*iter, depth); - depth++; - mNewChildren.push_back(*iter); - } - } // end for. - - if(iter == offset) - { - SetDepth(childInfo, depth); - // insert the new childInfo before offset (end). - mNewChildren.push_back(childInfo); - } - - mChildren = mNewChildren; - - // Todo somehow adjust their perceived depth. - } -} - -void Cluster::SetDepth( ChildInfo& childInfo, float depth ) -{ - Property::Index depthProperty = childInfo.mActor.GetPropertyIndex(Toolkit::Cluster::CLUSTER_ACTOR_DEPTH); - childInfo.mActor.SetProperty( depthProperty, depth ); -} - -ChildInfo Cluster::GetChildInfoAt( unsigned int index ) -{ - // check if we have this position in the cluster - if( index < mChildren.size() ) - { - // return the child handle - return mChildren[ index ]; - } - - // return an empty handle - return ChildInfo(); -} - -Actor Cluster::GetChildAt( unsigned int index ) -{ - // check if we have this position in the cluster - if( index < mChildren.size() ) - { - // return the child handle - return mChildren[ index ].mActor; - } - - // return an empty handle - return Actor(); -} - -Actor Cluster::RemoveChildAt( unsigned int index ) -{ - DALI_ASSERT_ALWAYS( index < mChildren.size() ); - - ChildInfoIter iter = mChildren.begin() + index; - Actor child = (*iter).mActor; - mChildren.erase( iter ); - Self().Remove(child); - // note: constraints will automatically be removed in OnControlChildRemove - - // update depths. - float depth = 0.0f; - - for(ChildInfoIter iter = mChildren.begin(); iter != mChildren.end(); ++iter) - { - SetDepth(*iter, depth); - depth++; - } // end for. - - return child; -} - -void Cluster::ExpandChild( unsigned int index ) -{ - if( index < mChildren.size() ) - { - ChildInfo& childInfo = mChildren[ index ]; - DALI_ASSERT_ALWAYS(childInfo.mActor); - - if(!childInfo.mExpanded) - { - // expand child to a random position/angle. - const Vector3 clusterSize = Self().GetCurrentSize(); - const float length = clusterSize.Length() * 0.1f; - const float zOffset = 50.0f; - const float angle = (rand()%360) * Math::PI / 180.0f; - Vector3 position(sin(angle) * length, -cos(angle) * length, zOffset); - const float scale(1.2f); - const Radian rotate( Degree( (rand()%30) - 15 ) ); - - position += childInfo.mActor.GetCurrentPosition(); - - TransformChild(index, - position, - Vector3::ONE * scale, - Quaternion(rotate, Vector3::ZAXIS), - AlphaFunctions::EaseOut, - 0.5f); - } - } -} - -void Cluster::ExpandAllChildren() -{ - for(unsigned int index = 0;index < mChildren.size(); index++) - { - ExpandChild( index ); - } -} - -void Cluster::CollapseChild( unsigned int index, bool front ) -{ - if( index < mChildren.size() ) - { - RestoreChild(index, - AlphaFunctions::EaseOut, - 0.25f, - front); - } -} - -void Cluster::CollapseAllChildren( bool front ) -{ - for(unsigned int index = 0;index < mChildren.size(); index++) - { - RestoreChild(index, - AlphaFunctions::EaseOut, - 0.25f, - front); - } -} - -void Cluster::TransformChild( unsigned int index, const Vector3& position, const Vector3& scale, const Quaternion& rotation, AlphaFunction alpha, const TimePeriod& period ) -{ - if( index < mChildren.size() ) - { - ChildInfo& childInfo = mChildren[ index ]; - DALI_ASSERT_ALWAYS(childInfo.mActor); - - if(!childInfo.mExpanded) - { - Actor child = childInfo.mActor; - childInfo.mExpanded = true; - mExpandedCount++; - - child.RemoveConstraints(); - Animation animation = Animation::New(period.delaySeconds + period.durationSeconds); - 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(); - } - } -} - -void Cluster::RestoreChild( unsigned int index, AlphaFunction alpha, const TimePeriod& period, bool front ) -{ - if( index < mChildren.size() ) - { - ChildInfo& childInfo = mChildren[ index ]; - DALI_ASSERT_ALWAYS(childInfo.mActor); - - if(childInfo.mExpanded) - { - Actor child = childInfo.mActor; - childInfo.mExpanded = false; - mExpandedCount--; - mClusterStyle.ApplyStyle( child, childInfo.mPositionIndex, alpha, period ); - - const unsigned int hideIndex = front ? mChildren.size() : 0; - AddChildInfoAt(childInfo, hideIndex); // move child info to the back or front of the pack. - } - } -} - -void Cluster::SetBackgroundImage( Actor image ) -{ - // Replaces the background image. - if(mBackgroundImage && mBackgroundImage.GetParent()) - { - mBackgroundImage.GetParent().Remove(mBackgroundImage); - } - - mBackgroundImage = image; - Self().Add(mBackgroundImage); - - mBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT ); - - UpdateBackground(0.0f); -} - -void Cluster::SetTitle( Actor text ) -{ - // Replaces the title actor. - if(mTitle && mTitle.GetParent()) - { - mTitle.GetParent().Remove( mTitle ); - } - - mTitle = text; - Self().Add( mTitle ); - - mTitle.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mTitle.SetParentOrigin( ParentOrigin::TOP_LEFT ); - - UpdateTitle(0.0f); -} - -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) - if(newChildrenNum < previousChildrenNum) - { - ChildInfoIter removeStart = mChildren.begin() + newChildrenNum; - - for(ChildInfoIter iter = removeStart; iter != mChildren.end(); ++iter) - { - Actor child = (*iter).mActor; - child.RemoveConstraints(); - Self().Remove(child); - } - - mChildren.erase( removeStart, mChildren.end() ); - } - - for(ChildInfoIter iter = mChildren.begin(); iter != mChildren.end(); ++iter) - { - - if((*iter).mActor) - { - mClusterStyle.ApplyStyle( (*iter).mActor, - (*iter).mPositionIndex, - AlphaFunctions::EaseOut, - CLUSTER_STYLE_CONSTRAINT_DURATION ); - } - } - - UpdateBackground(CLUSTER_STYLE_CONSTRAINT_DURATION); - UpdateTitle(CLUSTER_STYLE_CONSTRAINT_DURATION); -} - -Toolkit::ClusterStyle Cluster::GetStyle() const -{ - return mClusterStyle; -} - -unsigned int Cluster::GetExpandedCount() const -{ - return mExpandedCount; -} - -unsigned int Cluster::GetTotalCount() const -{ - return mChildren.size(); -} - -void Cluster::UpdateBackground(float duration) -{ - if (mBackgroundImage) - { - mClusterStyle.ApplyStyleToBackground(mBackgroundImage, AlphaFunctions::EaseOut, duration); - } -} - -void Cluster::UpdateTitle(float duration) -{ - if (mTitle) - { - mClusterStyle.ApplyStyleToTitle(mTitle, AlphaFunctions::EaseOut, duration); - } -} - -void Cluster::DoExpandAction(const PropertyValueContainer& attributes) -{ - if(attributes.size() >= 1) - { - for(PropertyValueConstIter iter = attributes.begin(); iter != attributes.end(); ++iter) - { - const Property::Value& value = *iter; - - DALI_ASSERT_ALWAYS(value.GetType() == Property::FLOAT); - unsigned int index = value.Get(); - ExpandChild( index ); - } - } - else - { - ExpandAllChildren(); - } -} - -void Cluster::DoCollapseAction(const PropertyValueContainer& attributes) -{ - if(attributes.size() >= 1) - { - for(PropertyValueConstIter iter = attributes.begin(); iter != attributes.end(); ++iter) - { - const Property::Value& value = *iter; - - DALI_ASSERT_ALWAYS(value.GetType() == Property::FLOAT); - unsigned int index = value.Get(); - CollapseChild( index, false ); - } - } - else - { - CollapseAllChildren( false ); - } -} - -void Cluster::DoTransformAction(const PropertyValueContainer& attributes) -{ - DALI_ASSERT_ALWAYS(attributes.size() >= 2); - - DALI_ASSERT_ALWAYS(attributes[0].GetType() == Property::FLOAT); - unsigned int index = attributes[0].Get(); - Vector3 position; - Vector3 scale(Vector3::ONE); - Quaternion rotation( Dali::ANGLE_0, Vector3::ZAXIS ); - - DALI_ASSERT_ALWAYS(attributes[1].GetType() == Property::VECTOR3); - attributes[1].Get(position); - - if(attributes.size()>2) - { - attributes[2].Get(scale); - } - - if(attributes.size()>3) - { - attributes[3].Get(rotation); - } - - // wrap index around -1 => size - 1 - index%= mChildren.size(); - - TransformChild(index, position, scale, rotation, AlphaFunctions::EaseOut, 0.5f); -} - -void Cluster::OnControlChildRemove(Actor& child) -{ - child.RemoveConstraints(); -} - -bool Cluster::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes) -{ - bool ret = false; - - Dali::BaseHandle handle( object ); - - Toolkit::Cluster cluster = Toolkit::Cluster::DownCast( handle ); - - DALI_ASSERT_ALWAYS( cluster ); - - if( 0 == strcmp( actionName.c_str(), ACTION_EXPAND ) ) - { - GetImpl( cluster ).DoExpandAction( attributes ); - ret = true; - } - else if( 0 == strcmp( actionName.c_str(), ACTION_COLLAPSE ) ) - { - GetImpl( cluster ).DoCollapseAction( attributes ); - ret = true; - } - else if( 0 == strcmp( actionName.c_str(), ACTION_TRANSFORM ) ) - { - GetImpl( cluster ).DoTransformAction( attributes ); - ret = true; - } - - return ret; -} - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/internal/controls/cluster/cluster-impl.h b/dali-toolkit/internal/controls/cluster/cluster-impl.h deleted file mode 100644 index 17585fe..0000000 --- a/dali-toolkit/internal/controls/cluster/cluster-impl.h +++ /dev/null @@ -1,325 +0,0 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_CLUSTER_H__ -#define __DALI_TOOLKIT_INTERNAL_CLUSTER_H__ - -/* - * 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. - * - */ - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include -#include -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -class Cluster; - -typedef IntrusivePtr ClusterPtr; - -class ChildInfo -{ - -public: - - ChildInfo() - : mExpanded(false) - { - } - - ChildInfo(Actor actor, unsigned int positionIndex) - : mActor(actor), - mExpanded(false), - mPositionIndex(positionIndex) - { - } - - Actor mActor; - bool mExpanded; - unsigned int mPositionIndex; -}; - -typedef std::vector ChildInfoContainer; -typedef ChildInfoContainer::iterator ChildInfoIter; -typedef ChildInfoContainer::const_iterator ChildInfoConstIter; - -/** - * Cluster is a container of grouped actors positioned in different cluster styles. - * Multiple cluster styles may be provided, to determine the position, size, rotation, scale, color and visibility - * of the child actors in the cluster. - */ -class Cluster : public Control -{ -public: - - /** - * Create a new Cluster. - * @param[in] style of the cluster - * @return A public handle to the newly allocated Cluster. - */ - static Dali::Toolkit::Cluster New(Toolkit::ClusterStyle& style); - - /** - * @copydoc Toolkit::Cluster::AddChild( Actor child ) - */ - void AddChild( Actor child ); - - /** - * @copydoc Toolkit::Cluster::AddChild( Actor child, unsigned int positionIndex ) - */ - void AddChild( Actor child, unsigned int positionIndex ); - - /** - * @copydoc Toolkit::Cluster::AddChildAt( Actor child, unsigned int index ); - */ - void AddChildAt( Actor child, unsigned int index ); - - /** - * @copydoc Toolkit::Cluster::AddChildAt( Actor child, unsigned int positionIndex, unsigned int index ); - */ - void AddChildAt( Actor child, unsigned int positionIndex, unsigned int index ); - - /** - * Adds a ChildInfo struct to the end of the children list. - * @param[in] childInfo the child info to that to children list. - */ - void AddChildInfo( ChildInfo childInfo ); - - /** - * Adds a ChildInfo struct before the specified index. - * @param[in] childInfo the child info to that to children list. - * @param[in] index the index within the children list to insert - * ChildInfo - */ - void AddChildInfoAt( ChildInfo childInfo, unsigned int index ); - - /** - * @copydoc Toolkit::Cluster::GetChildAt - */ - Actor GetChildAt( unsigned int index ); - - /** - * @copydoc Toolkit::Cluster::RemoveChildAt - */ - Actor RemoveChildAt( unsigned int index ); - - /** - * @copydoc Toolkit::Cluster::ExpandChild - */ - void ExpandChild( unsigned int index ); - - /** - * @copydoc Toolkit::Cluster::ExpandAllChildren - */ - void ExpandAllChildren(); - - /** - * @copydoc Toolkit::Cluster::CollapseChild - */ - void CollapseChild( unsigned int index, bool front ); - - /** - * @copydoc Toolkit::Cluster::CollapseAllChildren - */ - void CollapseAllChildren( bool front ); - - /** - * @copydoc Toolkit::Cluster::TransformChild - */ - void TransformChild( unsigned int index, const Vector3& position, const Vector3& scale, const Quaternion& rotation, AlphaFunction alpha, const TimePeriod& period ); - - /** - * @copydoc Toolkit::Cluster::RestoreChild - */ - void RestoreChild( unsigned int index, AlphaFunction alpha, const TimePeriod& period, bool front ); - - /** - * @copydoc Toolkit::Cluster::SetBackgroundImage - */ - void SetBackgroundImage( Actor image ); - - /** - * @copydoc Toolkit::Cluster::SetTitle - */ - void SetTitle( Actor text ); - - /** - * @copydoc Toolkit::Cluster::SetStyle - */ - void SetStyle(Toolkit::ClusterStyle style); - - /** - * @copydoc Toolkit::Cluster::GetStyle - */ - Toolkit::ClusterStyle GetStyle() const; - - /** - * @copydoc Toolkit::Cluster::GetExpandedCount - */ - unsigned int GetExpandedCount() const; - - /** - * @copydoc Toolkit::Cluster::GetTotalCount - */ - unsigned int GetTotalCount() const; - -private: - - ChildInfo GetChildInfoAt( unsigned int index ); - - void SetDepth( ChildInfo& childInfo, float depth ); - - /** - * Updates the style of the Background - * (occurs when either background changes or style changes) - * @param[in] duration apply duration for style - */ - void UpdateBackground(float duration); - - /** - * Updates the style of the Title - * (occurs when either background changes or style changes) - * @param[in] duration apply duration for style - */ - void UpdateTitle(float duration); - - /** - * Action: Expand - * Expands one or more actors. - * - * @param[in] attributes list of indices of actors to expand. - * (if no attributes specifies, then all actors expand) - */ - void DoExpandAction(const PropertyValueContainer& attributes); - - /** - * Action: Collapse - * Collapses one or more actors. - * - * @param[in] attributes list of indices of actors to collapse. - * (if no attributes specifies, then all actors collapse) - */ - void DoCollapseAction(const PropertyValueContainer& attributes); - - /** - * Action: Transform - * Transforms one actor (index) to a specified position (Vector3), - * scale (Vector3), and rotation (Quaternion). - * - * @param[in] attributes index and transform values. - */ - void DoTransformAction(const PropertyValueContainer& attributes); - -private: // From Control - /** - * From Control; called shortly before a child is removed from the owning actor. - * @param[in] child The child being removed.Ptr - */ - virtual void OnControlChildRemove(Actor& child); - -public: - - /** - * Performs actions as requested using the action name. - * @param[in] object The object on which to perform the action. - * @param[in] actionName The action to perform. - * @param[in] attributes The attributes with which to perfrom this action. - * @return true if action has been accepted by this control - */ - static bool DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes); - -private: // From Control - - /** - * @copydoc Toolkit::Control::OnInitialize() - */ - virtual void OnInitialize(); - - /** - * - * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize ) - */ - virtual void OnControlSizeSet( const Vector3& targetSize ); - -protected: - - /** - * Construct a new Cluster. - * @param[in] style of the cluster - */ - Cluster(Toolkit::ClusterStyle& style); - - /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~Cluster(); - -private: - - // Undefined - Cluster(const Cluster&); - - // Undefined - Cluster& operator=(const Cluster& rhs); - -private: - - Toolkit::ClusterStyle mClusterStyle; - ChildInfoContainer mChildren; - Vector3 mClusterSize; - - Actor mBackgroundImage; ///< Stores the background image. - Actor mTitle; ///< Stores the text title. - unsigned int mExpandedCount; ///< A count of how many children have been expanded. - -}; - -} // namespace Internal - -// Helpers for public-api forwarding methods - -inline Toolkit::Internal::Cluster& GetImpl(Toolkit::Cluster& cluster) -{ - DALI_ASSERT_ALWAYS(cluster); - - Dali::RefObject& handle = cluster.GetImplementation(); - - return static_cast(handle); -} - -inline const Toolkit::Internal::Cluster& GetImpl(const Toolkit::Cluster& cluster) -{ - DALI_ASSERT_ALWAYS(cluster); - - const Dali::RefObject& handle = cluster.GetImplementation(); - - return static_cast(handle); -} - -} // namespace Toolkit - -} // namespace Dali - -#endif // __DALI_TOOLKIT_INTERNAL_CLUSTER_H__ diff --git a/dali-toolkit/internal/controls/cluster/cluster-style-impl.cpp b/dali-toolkit/internal/controls/cluster/cluster-style-impl.cpp deleted file mode 100644 index 16dd5ea..0000000 --- a/dali-toolkit/internal/controls/cluster/cluster-style-impl.cpp +++ /dev/null @@ -1,486 +0,0 @@ -/* - * 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 - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace // unnamed namespace -{ -// Cluster style one - -const unsigned int STYLE_1_CHILDREN_NUMBER = 8; - -const float STYLE_1_BACKGROUND_IMAGE_OFFSET_Z = 1.0f; - -const float STYLE_1_CHILD_OFFSET_Z = 2.0f; -const float STYLE_1_CHILD_GAP_FACTOR = 0.03f; -const float STYLE_1_CHILD_SIZE_FACTOR[] = { 0.4f, 0.15f, 0.25f, 0.15f, 0.4f, 0.15f, 0.25f, 0.15f }; -const Vector3 STYLE_1_CHILD_POSITION_FACTOR[] = { Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[0] - STYLE_1_CHILD_GAP_FACTOR * 0.5f, - 0.5f - STYLE_1_CHILD_SIZE_FACTOR[0] - STYLE_1_CHILD_GAP_FACTOR * 0.5f, - STYLE_1_CHILD_OFFSET_Z), - Vector3(0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f, - 0.5f - STYLE_1_CHILD_SIZE_FACTOR[1] - STYLE_1_CHILD_SIZE_FACTOR[2] - STYLE_1_CHILD_GAP_FACTOR * 1.5f, - STYLE_1_CHILD_OFFSET_Z + 0.5f), - Vector3(0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f, - 0.5f - STYLE_1_CHILD_SIZE_FACTOR[2] - STYLE_1_CHILD_GAP_FACTOR * 0.5f, - STYLE_1_CHILD_OFFSET_Z + 1.0f), - Vector3(0.5f + STYLE_1_CHILD_SIZE_FACTOR[2] + STYLE_1_CHILD_GAP_FACTOR * 1.5f, - 0.5f - STYLE_1_CHILD_SIZE_FACTOR[3] - STYLE_1_CHILD_GAP_FACTOR * 0.5f, - STYLE_1_CHILD_OFFSET_Z + 1.5f), - Vector3(0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f, - 0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f, - STYLE_1_CHILD_OFFSET_Z + 2.0f), - Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[5] - STYLE_1_CHILD_GAP_FACTOR * 0.5f, - 0.5f + STYLE_1_CHILD_SIZE_FACTOR[6] + STYLE_1_CHILD_GAP_FACTOR * 1.5f, - STYLE_1_CHILD_OFFSET_Z + 2.5f), - Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[6] - STYLE_1_CHILD_GAP_FACTOR * 0.5f, - 0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f, - STYLE_1_CHILD_OFFSET_Z + 3.0f), - Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[6] - STYLE_1_CHILD_SIZE_FACTOR[7] - STYLE_1_CHILD_GAP_FACTOR * 1.5f, - 0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f, - STYLE_1_CHILD_OFFSET_Z + 3.5f) }; - -const Vector3 STYLE_1_TITLE_SIZE_FACTOR = Vector3(0.3f, 0.11f, 1.0f); -const Vector3 STYLE_1_TITLE_POSITION_FACTOR = Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[0] - STYLE_1_CHILD_GAP_FACTOR * 0.5f, - 0.5f - STYLE_1_CHILD_SIZE_FACTOR[0] - STYLE_1_CHILD_GAP_FACTOR * 0.5f - STYLE_1_TITLE_SIZE_FACTOR.height + 0.02f, - 0.0f); -const Vector3 STYLE_1_TITLE_POSITION_OFFSET = Vector3(0.0f, 0.0f, 8.0f); - -// Cluster style two - -const unsigned int STYLE_2_CHILDREN_NUMBER = 6; - -const float STYLE_2_BACKGROUND_IMAGE_OFFSET_Z = 1.0f; - -const float STYLE_2_CHILD_OFFSET_Z = 2.0f; -const float STYLE_2_CHILD_GAP_FACTOR = 0.03f; -const float STYLE_2_CHILD_SIZE_FACTOR[] = { 0.4f, 0.25f, 0.15f, 0.4f, 0.25f, 0.15f }; -const Vector3 STYLE_2_CHILD_POSITION_FACTOR[] = { Vector3(0.5f - STYLE_2_CHILD_SIZE_FACTOR[0] - STYLE_2_CHILD_GAP_FACTOR * 0.5f, - 0.5f - STYLE_2_CHILD_SIZE_FACTOR[0] * 0.75f, - STYLE_2_CHILD_OFFSET_Z), - Vector3(0.5f + STYLE_2_CHILD_GAP_FACTOR * 0.5f, - 0.5f - STYLE_2_CHILD_SIZE_FACTOR[1] - STYLE_2_CHILD_SIZE_FACTOR[3] * 0.25f - STYLE_2_CHILD_GAP_FACTOR, - STYLE_2_CHILD_OFFSET_Z + 0.5f), - Vector3(0.5f + STYLE_2_CHILD_SIZE_FACTOR[1] + STYLE_2_CHILD_GAP_FACTOR * 1.5f, - 0.5f - STYLE_2_CHILD_SIZE_FACTOR[2] - STYLE_2_CHILD_SIZE_FACTOR[3] * 0.25f - STYLE_2_CHILD_GAP_FACTOR, - STYLE_2_CHILD_OFFSET_Z + 1.0f), - Vector3(0.5f + STYLE_2_CHILD_GAP_FACTOR * 0.5f, - 0.5f - STYLE_2_CHILD_SIZE_FACTOR[3] * 0.25f, - STYLE_2_CHILD_OFFSET_Z + 1.5f), - Vector3(0.5f - STYLE_2_CHILD_SIZE_FACTOR[4] - STYLE_2_CHILD_GAP_FACTOR * 0.5f, - 0.5f + STYLE_2_CHILD_SIZE_FACTOR[0] * 0.25f + STYLE_2_CHILD_GAP_FACTOR, - STYLE_2_CHILD_OFFSET_Z + 2.0f), - Vector3(0.5f - STYLE_2_CHILD_SIZE_FACTOR[4] - STYLE_2_CHILD_SIZE_FACTOR[5] - STYLE_2_CHILD_GAP_FACTOR * 1.5f, - 0.5f + STYLE_2_CHILD_SIZE_FACTOR[0] * 0.25f + STYLE_2_CHILD_GAP_FACTOR, - STYLE_2_CHILD_OFFSET_Z + 2.5f) }; - -const Vector3 STYLE_2_TITLE_SIZE_FACTOR = Vector3(0.3f, 0.11f, 1.0f); -const Vector3 STYLE_2_TITLE_POSITION_FACTOR = Vector3(0.5f - STYLE_2_CHILD_SIZE_FACTOR[0] - STYLE_2_CHILD_GAP_FACTOR * 0.5f, - 0.5f - STYLE_2_CHILD_SIZE_FACTOR[0] * 0.75f - STYLE_2_TITLE_SIZE_FACTOR.height + 0.02f, - 0.0f); -const Vector3 STYLE_2_TITLE_POSITION_OFFSET = Vector3(0.0f, 0.0f, 8.0f); - -// Cluster style three - -const unsigned int STYLE_3_CHILDREN_NUMBER = 6; - -const Vector3 STYLE_3_TITLE_SIZE_FACTOR = Vector3(0.4f, 0.15f, 1.0f); - -const float STYLE_3_BACKGROUND_IMAGE_OFFSET_Z = 1.0f; - -const float STYLE_3_CHILD_OFFSET_Z = 2.0f; -const float STYLE_3_CHILD_GAP_FACTOR = 0.03f; -const float STYLE_3_CHILD_SIZE_FACTOR[] = { 0.4f, 0.4f, 0.15f, 0.25f, 0.25f, 0.15f }; -const float STYLE_3_CHILD_POSITION_OFFSET_Y = (1.0f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_SIZE_FACTOR[3] - STYLE_3_CHILD_GAP_FACTOR - STYLE_3_TITLE_SIZE_FACTOR.height) * 0.5f; -const Vector3 STYLE_3_CHILD_POSITION_FACTOR[] = { Vector3(0.5f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_GAP_FACTOR * 0.5f, - 0.5f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y, - STYLE_3_CHILD_OFFSET_Z), - Vector3(0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f, - 0.5f - STYLE_3_CHILD_SIZE_FACTOR[1] - STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y, - STYLE_3_CHILD_OFFSET_Z + 0.5f), - Vector3(0.5f + STYLE_3_CHILD_SIZE_FACTOR[3] + STYLE_3_CHILD_GAP_FACTOR * 1.5f, - 0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y, - STYLE_3_CHILD_OFFSET_Z + 1.0f), - Vector3(0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f, - 0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y, - STYLE_3_CHILD_OFFSET_Z + 1.5f), - Vector3(0.5f - STYLE_3_CHILD_SIZE_FACTOR[4] - STYLE_3_CHILD_GAP_FACTOR * 0.5f, - 0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y, - STYLE_3_CHILD_OFFSET_Z + 2.0f), - Vector3(0.5f - STYLE_3_CHILD_SIZE_FACTOR[4] - STYLE_3_CHILD_SIZE_FACTOR[5] - STYLE_3_CHILD_GAP_FACTOR * 1.5f, - 0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y, - STYLE_3_CHILD_OFFSET_Z + 2.5f) }; - -const Vector3 STYLE_3_TITLE_POSITION_FACTOR = Vector3(0.5f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_GAP_FACTOR * 0.5f, - 0.5f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y - STYLE_3_TITLE_SIZE_FACTOR.height + 0.02f, - 0.0f); -const Vector3 STYLE_3_TITLE_POSITION_OFFSET = Vector3(0.0f, 0.0f, 8.0f); - -// Cluster style four - -const unsigned int STYLE_4_CHILDREN_NUMBER = 6; - -const float STYLE_4_BACKGROUND_IMAGE_OFFSET_Z = 1.0f; - -const float STYLE_4_CHILD_OFFSET_Z = 2.0f; -const float STYLE_4_CHILD_GAP_FACTOR = 0.03f; -const float STYLE_4_CHILD_SIZE_FACTOR[] = { 0.4f, 0.22f, 0.13f, 0.4f, 0.22f, 0.13f }; -const Vector3 STYLE_4_CHILD_POSITION_FACTOR[] = { Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[0] * 0.9f, - 0.5f - STYLE_4_CHILD_SIZE_FACTOR[0] - STYLE_4_CHILD_GAP_FACTOR * 0.5f, - STYLE_4_CHILD_OFFSET_Z), - Vector3(0.5f + STYLE_4_CHILD_SIZE_FACTOR[0] * 0.1f + STYLE_4_CHILD_GAP_FACTOR, - 0.5f - STYLE_4_CHILD_SIZE_FACTOR[1] - STYLE_4_CHILD_GAP_FACTOR * 0.5f, - STYLE_4_CHILD_OFFSET_Z + 0.5f), - Vector3(0.5f + STYLE_4_CHILD_SIZE_FACTOR[0] * 0.1f + STYLE_4_CHILD_SIZE_FACTOR[1] + STYLE_4_CHILD_GAP_FACTOR * 2.0f, - 0.5f - STYLE_4_CHILD_SIZE_FACTOR[2] - STYLE_4_CHILD_GAP_FACTOR * 0.5f, - STYLE_4_CHILD_OFFSET_Z + 1.0f), - Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[3] * 0.1f, - 0.5f + STYLE_4_CHILD_GAP_FACTOR * 0.5f, - STYLE_4_CHILD_OFFSET_Z + 1.5f), - Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[3] * 0.1f - STYLE_4_CHILD_SIZE_FACTOR[4] - STYLE_4_CHILD_GAP_FACTOR, - 0.5f + STYLE_4_CHILD_GAP_FACTOR * 0.5f, - STYLE_4_CHILD_OFFSET_Z + 2.0f), - Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[3] * 0.1f - STYLE_4_CHILD_SIZE_FACTOR[4] - STYLE_4_CHILD_SIZE_FACTOR[5] - STYLE_4_CHILD_GAP_FACTOR * 2.0f, - 0.5f + STYLE_4_CHILD_GAP_FACTOR * 0.5f, - STYLE_4_CHILD_OFFSET_Z + 2.5f) }; - -const Vector3 STYLE_4_TITLE_SIZE_FACTOR = Vector3(0.3f, 0.11f, 1.0f); -const Vector3 STYLE_4_TITLE_POSITION_FACTOR = Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[0] * 0.9f, - 0.5f - STYLE_4_CHILD_SIZE_FACTOR[0] - STYLE_4_CHILD_GAP_FACTOR * 0.5f - STYLE_4_TITLE_SIZE_FACTOR.height + 0.02f, - 0.0f); -const Vector3 STYLE_4_TITLE_POSITION_OFFSET = Vector3(0.0f, 0.0f, 8.0f); -const unsigned int CLUSTER_RANDOM_SEED(0x17eac9f3); ///< Random seed for cluster data. - -const int STYLE_RANDOM_CHILDREN_NUMBER = 16; - -Vector3 FirstOrderEquation( const Vector3& source, const Vector3& relative, const Vector3& offset = Vector3::ZERO ) -{ - return source * relative + offset; -} - -// random data generator ////////////////////////////////////////////////////// - -const unsigned int GEN_RAND_CONST = 0x15d9a373; - -unsigned int genRandom(unsigned int& seed, unsigned int offset) -{ - unsigned int shft = offset&31; - - offset++; - - seed^= (seed << (shft) | seed >> (32 - shft)) * (offset * GEN_RAND_CONST); - - return seed; -} - -float genRandomFloat(unsigned int& seed, unsigned int offset, float min, float max) -{ - const float f = static_cast(genRandom(seed, offset)) / 0xffffffff; - return f * (max - min) + min; -} - -} // unnamed namespace - -namespace Toolkit -{ - -namespace Internal -{ - -// ClusterStyle /////////////////////////////////////////////////////////////// - -ClusterStyle::ClusterStyle() -: mMaxChildren(0), - mTitlePositionRelative(Vector3::ONE), - mTitlePositionOffset(Vector3::ZERO), - mTitleSize(Vector3::ONE), - mBackgroundPositionRelative(Vector3::ONE), - mBackgroundPositionOffset(Vector3::ZERO), - mBackgroundSize(Vector3::ONE), - mClusterSize( Vector3::ZERO ) -{ -} - -ClusterStyle::~ClusterStyle() -{ - -} - -void ClusterStyle::SetMaximumNumberOfChildren(unsigned int maxChildren) -{ - mMaxChildren = maxChildren; -} - -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) -{ - mTitlePositionRelative = relativePosition; - mTitlePositionOffset = offsetPosition; - mTitleSize = size; -} - -void ClusterStyle::SetBackgroundProperties(const Vector3& relativePosition, - const Vector3& offsetPosition, - const Vector3& size) -{ - mBackgroundPositionRelative = relativePosition; - mBackgroundPositionOffset = offsetPosition; - 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.AnimateTo( Property( actor, Actor::Property::POSITION ), position, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) ); - animation.AnimateTo( Property( actor, Actor::Property::SIZE ), size, alpha, TimePeriod( 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.AnimateTo( Property( actor, Actor::Property::POSITION ), position, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) ); - animation.AnimateTo( Property( actor, Actor::Property::SIZE ), size, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) ); - animation.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), rotation, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) ); - animation.AnimateTo( Property( actor, Actor::Property::SCALE ), scale, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) ); - animation.Play(); - } - else - { - actor.SetPosition( position ); - actor.SetSize( size ); - actor.SetOrientation( rotation ); - actor.SetScale( scale ); - } -} - -// ClusterStyleStandard /////////////////////////////////////////////////////// - -ClusterStylePtr ClusterStyleStandard::New(StyleType style) -{ - ClusterStylePtr impl( new ClusterStyleStandard(style) ); - - return impl; -} - -ClusterStyleStandard::ClusterStyleStandard(StyleType style) -: ClusterStyle(), - mSizes(NULL), - mPositions(NULL) -{ - switch(style) - { - case Toolkit::ClusterStyleStandard::ClusterStyle1: - { - SetMaximumNumberOfChildren(STYLE_1_CHILDREN_NUMBER); - SetSizes(STYLE_1_CHILD_SIZE_FACTOR); - SetPositions(STYLE_1_CHILD_POSITION_FACTOR); - SetTitleProperties(STYLE_1_TITLE_POSITION_FACTOR, - STYLE_1_TITLE_POSITION_OFFSET, - STYLE_1_TITLE_SIZE_FACTOR); - SetBackgroundProperties(Vector3::ZERO, - Vector3(0.0f, 0.0f, STYLE_1_BACKGROUND_IMAGE_OFFSET_Z), - Vector3::ONE); - break; - } - case Toolkit::ClusterStyleStandard::ClusterStyle2: - { - SetMaximumNumberOfChildren(STYLE_2_CHILDREN_NUMBER); - SetSizes(STYLE_2_CHILD_SIZE_FACTOR); - SetPositions(STYLE_2_CHILD_POSITION_FACTOR); - SetTitleProperties(STYLE_2_TITLE_POSITION_FACTOR, - STYLE_2_TITLE_POSITION_OFFSET, - STYLE_2_TITLE_SIZE_FACTOR); - SetBackgroundProperties(Vector3::ZERO, - Vector3(0.0f, 0.0f, STYLE_2_BACKGROUND_IMAGE_OFFSET_Z), - Vector3::ONE); - break; - } - case Toolkit::ClusterStyleStandard::ClusterStyle3: - { - SetMaximumNumberOfChildren(STYLE_3_CHILDREN_NUMBER); - SetSizes(STYLE_3_CHILD_SIZE_FACTOR); - SetPositions(STYLE_3_CHILD_POSITION_FACTOR); - SetTitleProperties(STYLE_3_TITLE_POSITION_FACTOR, - STYLE_3_TITLE_POSITION_OFFSET, - STYLE_3_TITLE_SIZE_FACTOR); - SetBackgroundProperties(Vector3::ZERO, - Vector3(0.0f, 0.0f, STYLE_3_BACKGROUND_IMAGE_OFFSET_Z), - Vector3::ONE); - break; - } - case Toolkit::ClusterStyleStandard::ClusterStyle4: - { - SetMaximumNumberOfChildren(STYLE_4_CHILDREN_NUMBER); - SetSizes(STYLE_4_CHILD_SIZE_FACTOR); - SetPositions(STYLE_4_CHILD_POSITION_FACTOR); - SetTitleProperties(STYLE_4_TITLE_POSITION_FACTOR, - STYLE_4_TITLE_POSITION_OFFSET, - STYLE_4_TITLE_SIZE_FACTOR); - SetBackgroundProperties(Vector3::ZERO, - Vector3(0.0f, 0.0f, STYLE_4_BACKGROUND_IMAGE_OFFSET_Z), - Vector3::ONE); - break; - } - default: - { - DALI_ASSERT_ALWAYS(false && "Invalid Style"); - break; - } - } // end switch -} - -void ClusterStyleStandard::SetSizes(const float *sizes) -{ - mSizes = sizes; -} - -void ClusterStyleStandard::SetPositions(const Vector3 *positions) -{ - mPositions = positions; -} - -void ClusterStyleStandard::ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds) -{ - if(mPositions) - { - const float& size = mSizes[index]; - // 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; - - 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); - } -} - -// ClusterStyleRandom ///////////////////////////////////////////////////////// - -ClusterStylePtr ClusterStyleRandom::New() -{ - ClusterStylePtr impl( new ClusterStyleRandom() ); - - return impl; -} - -ClusterStyleRandom::ClusterStyleRandom() -: ClusterStyle() -{ - SetMaximumNumberOfChildren(STYLE_RANDOM_CHILDREN_NUMBER); - SetTitleProperties(Vector3::ZERO, - Vector3::ZERO, - Vector3::ONE); - SetBackgroundProperties(Vector3::ZERO, - Vector3(0.0f, 0.0f, 0.0f), - Vector3::ONE); -} - -void ClusterStyleRandom::ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds) -{ - unsigned int seed = CLUSTER_RANDOM_SEED; - const float size = 0.5f; - const float rotation = genRandomFloat(seed, index, -1.0f, 1.0f) * Math::PI * 0.1; // +/- 18 degrees - const Vector3 position(genRandomFloat(seed, index, -0.1f, 0.1f), - genRandomFloat(seed, index, -0.1f, 0.1f), - 0.0f); - - Property::Index depthProperty = child.GetPropertyIndex(Toolkit::Cluster::CLUSTER_ACTOR_DEPTH); - float depthPropertyValue = child.GetProperty( depthProperty ); - - Apply( child, - FirstOrderEquation( GetClusterSize(), Vector3(position.x, position.y, 0.0f), Vector3(0.0f, 0.0f, depthPropertyValue) ), - FirstOrderEquation( GetClusterSize(), Vector3::ONE * size), - Quaternion( Radian( rotation ), Vector3::ZAXIS ), - Vector3::ONE, - alpha, - durationSeconds); -} - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/internal/controls/cluster/cluster-style-impl.h b/dali-toolkit/internal/controls/cluster/cluster-style-impl.h deleted file mode 100644 index bf7b75d..0000000 --- a/dali-toolkit/internal/controls/cluster/cluster-style-impl.h +++ /dev/null @@ -1,269 +0,0 @@ -/* - * 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. - * - */ - -// EXTERNAL INCLUDES -#include -#include -#include -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -class ClusterStyle; - -typedef IntrusivePtr ClusterStylePtr; - -/** - * ClusterStyle internal implementation - */ -class ClusterStyle : public Dali::BaseObject -{ -public: - - /** - * @copydoc Toolkit::ClusterStyle::GetMaximumNumberOfChildren - */ - unsigned int GetMaximumNumberOfChildren() const; - - /** - * @copydoc Toolkit::ClusterStyle::ApplyStyle - */ - virtual void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0; - - /** - * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground - */ - virtual void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds); - - /** - * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle - */ - virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds); - - /** - * Set the size of cluster - */ - void SetClusterSize( const Vector3& clusterSize ); - -protected: - - /** - * Set the maximum number of children this Style can handle. - * @param[in] The maximum number of children. - */ - void SetMaximumNumberOfChildren(unsigned int children); - - /** - * Set the title properties - * @param[in] relativePosition Relative position of the title - * @param[in] offsetPosition Offset position of the title - * @param[in] size The size of the title - */ - void SetTitleProperties(const Vector3& relativePosition, - const Vector3& offsetPosition, - const Vector3& size); - - /** - * Set the background properties - * @param[in] relativePosition Relative position of the background - * @param[in] offsetPosition Offset position of the background - * @param[in] size The size of the title - */ - void SetBackgroundProperties(const Vector3& relativePosition, - 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: - - /** - * Protected constructor see ClusterStyle::New(). - */ - ClusterStyle(); - - /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~ClusterStyle(); - -protected: - - unsigned int mMaxChildren; ///< Maximum number of children that this style supports - Vector3 mTitlePositionRelative; ///< Title's position relative to size of cluster - Vector3 mTitlePositionOffset; ///< Title's position offset - Vector3 mTitleSize; ///< Title's size relative to size of cluster - 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 -}; - -/** - * ClusterStyleStandard internal implementation - */ -class ClusterStyleStandard : public ClusterStyle -{ -public: - - typedef Toolkit::ClusterStyleStandard::StyleType StyleType; - -public: - - /** - * Create a new cluster style. - * @param[in] style The style type to create. - * @return A smart-pointer to the newly allocated ClusterStyle. - */ - static ClusterStylePtr New(StyleType style); - -public: - - /** - * @copydoc Toolkit::ClusterStyle::ApplyStyle - */ - void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds); - -private: - - /** - * Set the relative sizes of the children - * @param[in] size The list of sizes for the children - */ - void SetSizes(const float *sizes); - - /** - * Set the relative positions of the children - * @param[in] positions The list of positions for the children - */ - void SetPositions(const Vector3 *positions); - -protected: - - /** - * Protected constructor see ClusterStyleRandom::New(). - */ - ClusterStyleStandard(StyleType style); - -private: - - const float *mSizes; ///< List of sizes - const Vector3 *mPositions; ///< List of positions - -}; - -/** - * ClusterStyleRandom internal implementation - */ -class ClusterStyleRandom : public ClusterStyle -{ -public: - - /** - * Create a new cluster style. - * @return A smart-pointer to the newly allocated ClusterStyle. - */ - static ClusterStylePtr New(); - -public: - - /** - * @copydoc Toolkit::ClusterStyle::ApplyStyle - */ - void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds); - -protected: - - /** - * Protected constructor see ClusterStyleRandom::New(). - */ - ClusterStyleRandom(); - -private: - -}; - -} // namespace Internal - -// Helpers for public-api forwarding methods - -inline Internal::ClusterStyle& GetImpl(Toolkit::ClusterStyle& pub) -{ - DALI_ASSERT_ALWAYS(pub); - - Dali::RefObject& handle = pub.GetBaseObject(); - - return static_cast(handle); -} - -inline const Internal::ClusterStyle& GetImpl(const Toolkit::ClusterStyle& pub) -{ - DALI_ASSERT_ALWAYS(pub); - - const Dali::RefObject& handle = pub.GetBaseObject(); - - return static_cast(handle); -} - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp index 7ba35c5..a04ff9a 100644 --- a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp +++ b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp @@ -57,7 +57,7 @@ Toolkit::ToolBar ToolBar::New() // Create the implementation, temporarily owned on stack IntrusivePtr< ToolBar > internalToolBar = new ToolBar(); - // Pass ownership to Toolkit::View + // Pass ownership to Toolkit::Toolbar Toolkit::ToolBar toolBar( *internalToolBar ); // Second-phase init of the implementation diff --git a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.h b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.h index 933943e..ebf0fcd 100644 --- a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.h +++ b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.h @@ -52,17 +52,17 @@ public: static Toolkit::ToolBar New(); /** - * @copydoc Dali::Toolkit::View::SetBackground() + * @copydoc Dali::Toolkit::ToolBar::SetBackground() */ void SetBackground( Actor background ); /** - * @copydoc Dali::Toolkit::View::AddControl() + * @copydoc Dali::Toolkit::ToolBar::AddControl() */ void AddControl( Dali::Actor control, float relativeSize, Toolkit::Alignment::Type alignment, const Toolkit::Alignment::Padding& padding ); /** - * @copydoc Dali::Toolkit::View::RemoveControl() + * @copydoc Dali::Toolkit::ToolBar::RemoveControl() */ void RemoveControl( Dali::Actor control ); diff --git a/dali-toolkit/internal/controls/view/view-impl.cpp b/dali-toolkit/internal/controls/view/view-impl.cpp deleted file mode 100644 index 70a2a15..0000000 --- a/dali-toolkit/internal/controls/view/view-impl.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/* - * 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 "view-impl.h" - -// EXTERNAL INCLUDES -#include // for strcmp -#include -#include -#include -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -namespace -{ - -BaseHandle Create() -{ - return Toolkit::View::New(); -} - -DALI_TYPE_REGISTRATION_BEGIN( Toolkit::View, Toolkit::Control, Create ) - -DALI_SIGNAL_REGISTRATION( Toolkit, View, "orientation-animation-start", SIGNAL_ORIENTATION_ANIMATION_START ) - -DALI_TYPE_REGISTRATION_END() - -const float ROTATION_ANIMATION_DURATION = 0.5f; - -} - -Toolkit::View View::New( bool fullscreen ) -{ - // Create the implementation, temporarily owned by this handle on stack - IntrusivePtr< View > internalView = new View(fullscreen); - - // Pass ownership to CustomActor handle - Toolkit::View view( *internalView ); - - // Second-phase init of the implementation - // This can only be done after the CustomActor connection has been made... - internalView->Initialize(); - - return view; -} - -Layer View::GetContentLayer( unsigned int index ) const -{ - // Returns the layer stored in the layer map. - Layer layer; - - LayerConstIt it = mContentLayers.find( index ); - - if( it != mContentLayers.end() ) - { - layer = it->second; - } - - return layer; -} - -unsigned int View::AddContentLayer( Layer layer ) -{ - // layer must exist. - DALI_ASSERT_ALWAYS( layer ); - - unsigned int index = mNextLayerIndex; - LayerIt it = FindLayer( layer ); - - if( it == mContentLayers.end() ) - { - // Add layer to the custom actor. - Self().Add( layer ); - - // Store the layer. - mContentLayers[mNextLayerIndex] = layer; - - // Increase the index. - ++mNextLayerIndex; - } - - return index; -} - -void View::RemoveContentLayer( Layer layer ) -{ - // Check if layer was added in this view. - LayerIt it = FindLayer( layer ); - if( it != mContentLayers.end() ) - { - // Remove layer from custom actor. - Self().Remove( layer ); - - // Remove layer from layer map. - mContentLayers.erase( it ); - } -} - -Layer View::GetBackgroundLayer() const -{ - return mBackgroundLayer; -} - -void View::SetBackground( ImageActor backgroundImage ) -{ - // Create background layer if doesn't exist. - - if( !mBackgroundLayer ) - { - mBackgroundLayer = Layer::New(); - - mBackgroundLayer.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - mBackgroundLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - - // Add background layer to custom actor. - Self().Add( mBackgroundLayer ); - - // Drop the background layer - - DALI_ASSERT_ALWAYS( mBackgroundLayer.OnStage() ); // We need to be on-stage to drop the layer - mBackgroundLayer.LowerToBottom(); - } - else - { - // It removes the old background - if( 0 < mBackgroundLayer.GetChildCount() ) - { - mBackgroundLayer.Remove( mBackgroundLayer.GetChildAt(0) ); - } - } - - backgroundImage.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - backgroundImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - backgroundImage.SetSizeScalePolicy( SizeScalePolicy::FILL_WITH_ASPECT_RATIO ); - mBackgroundLayer.Add( backgroundImage ); - - RelayoutRequest(); -} - -void View::SetOrientationFunction( Degree portrait, Degree landscale, Degree portraitInverse, Degree landscapeInverse ) -{ - mOrientationFunction[View::PORTRAIT] = portrait.degree; - mOrientationFunction[View::LANDSCAPE] = landscale.degree; - mOrientationFunction[View::PORTRAIT_INVERSE] = portraitInverse.degree; - mOrientationFunction[View::LANDSCAPE_INVERSE] = landscapeInverse.degree; -} - -void View::OrientationChanged( Dali::Orientation orientation ) -{ - Actor self = Self(); - - // Nothing to do if orientation doesn't really change. - if ( orientation.GetDegrees() == mOrientation || !mAutoRotateEnabled ) - { - return; - } - - mOrientation = orientation.GetDegrees(); - - // has parent so we expect it to be on stage - mRotateAnimation = Animation::New( ROTATION_ANIMATION_DURATION ); - mRotateAnimation.AnimateTo( Property( self, Actor::Property::ORIENTATION ), Quaternion( Radian( -orientation.GetRadians() ), Vector3::ZAXIS ), AlphaFunctions::EaseOut ); - - // Resize the view - if( mFullScreen ) - { - const Vector2& stageSize( Stage::GetCurrent().GetSize() ); - const Vector3& currentSize( self.GetCurrentSize() ); - - float minSize = std::min( stageSize.width, stageSize.height ); - float maxSize = std::max( stageSize.width, stageSize.height ); - - Vector3 targetSize; - View::Orientation viewOrientation = DegreeToViewOrientation( Degree( orientation.GetDegrees() ) ); - switch( viewOrientation ) - { - case View::PORTRAIT: // Fallthrough - case View::PORTRAIT_INVERSE: - targetSize = Vector3( minSize, maxSize, currentSize.depth ); - break; - case View::LANDSCAPE: // Fallthrough - case View::LANDSCAPE_INVERSE: - targetSize = Vector3( maxSize, minSize, currentSize.depth ); - break; - default: - DALI_ASSERT_ALWAYS( false ); - } - - // if we linearly resize from portrait to landscape halfway through the animation - // we get size which is square between the both. This would cause a square image to grow - // if it is fitted to be 100% of view size. Therefore we do a nonlinear size animation - // where we shrink faster - // which one grows - if( targetSize.width > currentSize.width ) - { - // width grows, shrink height faster - Vector3 shrink( currentSize );shrink.height = targetSize.height; - mRotateAnimation.AnimateTo( Property( self, Actor::Property::SIZE ), shrink, AlphaFunctions::EaseOut, TimePeriod( 0.0f, ROTATION_ANIMATION_DURATION * 0.5f ) ); - mRotateAnimation.AnimateTo( Property( self, Actor::Property::SIZE ), targetSize, AlphaFunctions::EaseIn, TimePeriod( 0.0f, ROTATION_ANIMATION_DURATION ) ); - } - else - { - // height grows, shrink width faster - Vector3 shrink( currentSize );shrink.width = targetSize.width; - mRotateAnimation.AnimateTo( Property( self, Actor::Property::SIZE ), shrink, AlphaFunctions::EaseOut, TimePeriod( 0.0f, ROTATION_ANIMATION_DURATION * 0.5f ) ); - mRotateAnimation.AnimateTo( Property( self, Actor::Property::SIZE ), targetSize, AlphaFunctions::EaseIn, TimePeriod( 0.0f, ROTATION_ANIMATION_DURATION ) ); - } - } - - Toolkit::View handle( GetOwner() ); - mOrientationAnimationStartedSignal.Emit( handle, mRotateAnimation, orientation ); - - mRotateAnimation.Play(); -} - -void View::SetAutoRotate( bool enabled ) -{ - mAutoRotateEnabled = enabled; -} - -Toolkit::View::OrientationAnimationStartedSignalType& View::OrientationAnimationStartedSignal() -{ - return mOrientationAnimationStartedSignal; -} - -bool View::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) -{ - Dali::BaseHandle handle( object ); - - bool connected( true ); - Toolkit::View view = Toolkit::View::DownCast(handle); - - if( 0 == strcmp( signalName.c_str(), SIGNAL_ORIENTATION_ANIMATION_START ) ) - { - view.OrientationAnimationStartedSignal().Connect( tracker, functor ); - } - else - { - // signalName does not match any signal - connected = false; - } - - return connected; -} - -View::View(bool fullscreen) -: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), - mOrientation( -1 ), - mFullScreen(fullscreen), - mContentLayers(), - mNextLayerIndex( 0 ), - mOrientationFunction(), - mAutoRotateEnabled( true ) -{ - mOrientationFunction[View::PORTRAIT] = 0.f; - mOrientationFunction[View::LANDSCAPE] = 90.f; - mOrientationFunction[View::PORTRAIT_INVERSE] = 180.f; - mOrientationFunction[View::LANDSCAPE_INVERSE] = 270.f; -} - -View::~View() -{ -} - -void View::OnInitialize() -{ - Self().SetAnchorPoint( AnchorPoint::CENTER ); - Self().SetParentOrigin( ParentOrigin::CENTER ); - - if( mFullScreen ) - { - Self().SetSize( Stage::GetCurrent().GetSize() ); - } -} - -View::Orientation View::DegreeToViewOrientation( Degree degree ) -{ - View::Orientation orientation = PORTRAIT; - - if( fabsf( mOrientationFunction[PORTRAIT] - degree.degree ) <= GetRangedEpsilon( mOrientationFunction[PORTRAIT], degree.degree ) ) - { - orientation = PORTRAIT; - } - else if( fabsf( mOrientationFunction[LANDSCAPE] - degree.degree ) <= GetRangedEpsilon( mOrientationFunction[LANDSCAPE], degree.degree ) ) - { - orientation = LANDSCAPE; - } - else if( fabsf( mOrientationFunction[PORTRAIT_INVERSE] - degree.degree ) <= GetRangedEpsilon( mOrientationFunction[PORTRAIT_INVERSE], degree.degree ) ) - { - orientation = PORTRAIT_INVERSE; - } - else if( fabsf( mOrientationFunction[LANDSCAPE_INVERSE] - degree.degree ) <= GetRangedEpsilon( mOrientationFunction[LANDSCAPE_INVERSE], degree.degree ) ) - { - orientation = LANDSCAPE_INVERSE; - } - - return orientation; -} - -View::LayerIt View::FindLayer( Layer layer ) -{ - for( LayerIt it = mContentLayers.begin(); it != mContentLayers.end(); ++it ) - { - if(layer == it->second) - { - return it; - } - } - - return mContentLayers.end(); -} - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/internal/controls/view/view-impl.h b/dali-toolkit/internal/controls/view/view-impl.h deleted file mode 100644 index b956eae..0000000 --- a/dali-toolkit/internal/controls/view/view-impl.h +++ /dev/null @@ -1,208 +0,0 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_VIEW_H__ -#define __DALI_TOOLKIT_INTERNAL_VIEW_H__ - -/* - * 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. - * - */ - -// EXTERNAL INCLUDES -#include -#include -#include - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace Toolkit -{ - -class View; - -namespace Internal -{ - -/** - * View is a control to add layers and a background. - * @see Dali::Toolkit::View for more details. - */ -class View : public Control -{ -private: - typedef std::map LayerContainer; - typedef std::map::iterator LayerIt; - typedef std::map::const_iterator LayerConstIt; - - /** - * Orientation declaration used internally to rotate the view. - * The angles associated with each enum value could be changed with the SetOrientationFunction method. - */ - enum Orientation - { - PORTRAIT, ///< portrait orientation. - LANDSCAPE, ///< landscape orientation. - PORTRAIT_INVERSE, ///< portrait inverse orientation. - LANDSCAPE_INVERSE ///< landscape inverse orientation. - }; - -public: - - /** - * Create an initialized View. - * @param fullscreen If true, the view's size is going to be set with the Dali::Stage size. Otherwise a size must be provided. - * @return A handle to a newly allocated Dali resource. - */ - static Toolkit::View New( bool fullscreen ); - - /** - * @copydoc Dali::Toolkit::View::GetContentLayer() - */ - Layer GetContentLayer( unsigned int index ) const; - - /** - * @copydoc Dali::Toolkit::View::AddContentLayer() - */ - unsigned int AddContentLayer( Layer layer ); - - /** - * @copydoc Dali::Toolkit::View::RemoveContentLayer() - */ - void RemoveContentLayer( Layer layer ); - - /** - * @copydoc Dali::Toolkit::View::GetBackgroundLayer() - */ - Layer GetBackgroundLayer() const; - - /** - * @copydoc Dali::Toolkit::View::SetBackground() - */ - void SetBackground( ImageActor image ); - - /** - * @copydoc Dali::Toolkit::View::SetOrientationFunction() - */ - void SetOrientationFunction( Degree portrait, Degree landscale, Degree portraitInverse, Degree landscapeInverse ); - - /** - * @copydoc Dali::Toolkit::View::OrientationChanged() - * - */ - void OrientationChanged( Dali::Orientation orientation ); - - /** - * @copydoc Dali::Toolkit::View::SetAutoRotate() - * - */ - void SetAutoRotate( bool enabled ); - -public: - - /** - * @copydoc Dali::Toolkit::View::AnimationStartedSignalOrientation() - */ - Toolkit::View::OrientationAnimationStartedSignalType& OrientationAnimationStartedSignal(); - - /** - * Connects a callback function with the object's signals. - * @param[in] object The object providing the signal. - * @param[in] tracker Used to disconnect the signal. - * @param[in] signalName The signal to connect to. - * @param[in] functor A newly allocated FunctorDelegate. - * @return True if the signal was connected. - * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor. - */ - static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); - -private: // From Control - - /** - * @copydoc Toolkit::Control::OnInitialize() - */ - virtual void OnInitialize(); - -private: - - - /** - * Constructor. - * It initializes View members. - * It initializes orientations as follows: portrait 0, landscape 90, portrait inverse 180, landscape inverse 270. - * @param fullscreen If true, the view's size is going to be set with the Dali::Stage size. Otherwise a size must be provided. - */ - View(bool fullscreen); - - /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~View(); - - /** - * Return an orientation for the given angle in degrees. - * @param degree angle in degrees. - * @return An internal orientation. - */ - View::Orientation DegreeToViewOrientation( Degree degree ); - - /** - * Find a layer in the layer container. Non const method - */ - LayerIt FindLayer( Layer layer ); - -private: - int mOrientation; ///< Stores the given orientation in degrees. - bool mFullScreen; ///< Stores if the view is fullscreen or not. - LayerContainer mContentLayers; ///< Layer container. - unsigned int mNextLayerIndex; ///< Next index to be used when a layer is added. - Layer mBackgroundLayer; ///< The background layer. - 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. - - Toolkit::View::OrientationAnimationStartedSignalType mOrientationAnimationStartedSignal; -}; - -} // namespace Internal - - -// Helpers for public-api forwarding methods - -inline Toolkit::Internal::View& GetImpl( Toolkit::View& view ) -{ - DALI_ASSERT_ALWAYS( view ); - - Dali::RefObject& handle = view.GetImplementation(); - - return static_cast( handle ); -} - -inline const Toolkit::Internal::View& GetImpl( const Toolkit::View& view ) -{ - DALI_ASSERT_ALWAYS( view ); - - const Dali::RefObject& handle = view.GetImplementation(); - - return static_cast( handle ); -} - -} // namespace Toolkit - -} // namespace Dali - -#endif // __DALI_TOOLKIT_INTERNAL_VIEW_H__ diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index 34350b1..a6b0fb1 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -19,8 +19,6 @@ toolkit_src_files = \ $(toolkit_src_dir)/controls/buttons/check-box-button-impl.cpp \ $(toolkit_src_dir)/controls/buttons/push-button-impl.cpp \ $(toolkit_src_dir)/controls/buttons/radio-button-impl.cpp \ - $(toolkit_src_dir)/controls/cluster/cluster-impl.cpp \ - $(toolkit_src_dir)/controls/cluster/cluster-style-impl.cpp \ $(toolkit_src_dir)/controls/effects-view/effects-view-impl.cpp \ $(toolkit_src_dir)/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp \ $(toolkit_src_dir)/controls/image-view/masked-image-view-impl.cpp \ @@ -62,7 +60,6 @@ toolkit_src_files = \ $(toolkit_src_dir)/controls/text-controls/text-label-impl.cpp \ $(toolkit_src_dir)/controls/text-controls/text-selection-popup-impl.cpp \ $(toolkit_src_dir)/controls/tool-bar/tool-bar-impl.cpp \ - $(toolkit_src_dir)/controls/view/view-impl.cpp \ $(toolkit_src_dir)/focus-manager/focus-manager-impl.cpp \ $(toolkit_src_dir)/focus-manager/keyboard-focus-manager-impl.cpp \ $(toolkit_src_dir)/focus-manager/keyinput-focus-manager-impl.cpp \ diff --git a/dali-toolkit/public-api/controls/cluster/cluster-style.cpp b/dali-toolkit/public-api/controls/cluster/cluster-style.cpp deleted file mode 100644 index 6fd1c4e..0000000 --- a/dali-toolkit/public-api/controls/cluster/cluster-style.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2015 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 - -// INTERNAL INCLUDES -#include - -using namespace Dali; -using namespace Dali::Toolkit; - -namespace Dali -{ - -namespace Toolkit -{ - -// ClusterStyle /////////////////////////////////////////////////////////////// - -const unsigned int ClusterStyle::UNLIMITED_CHILDREN = std::numeric_limits::max(); - -ClusterStyle::ClusterStyle() -{ -} - -ClusterStyle::~ClusterStyle() -{ -} - -ClusterStyle::ClusterStyle(Internal::ClusterStyle* internal) -: BaseHandle(internal) -{ -} - -unsigned int ClusterStyle::GetMaximumNumberOfChildren() const -{ - return GetImpl(*this).GetMaximumNumberOfChildren(); -} - -void ClusterStyle::ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds) -{ - GetImpl(*this).ApplyStyle(child, index, alpha, durationSeconds); -} - -void ClusterStyle::ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds) -{ - GetImpl(*this).ApplyStyleToBackground(background, alpha, durationSeconds); -} - -void ClusterStyle::ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds) -{ - GetImpl(*this).ApplyStyleToTitle(title, alpha, durationSeconds); -} - -// ClusterStyleStandard /////////////////////////////////////////////////////// - -ClusterStyleStandard ClusterStyleStandard::New(StyleType style) -{ - Internal::ClusterStylePtr internal = Internal::ClusterStyleStandard::New(style); - - return ClusterStyleStandard(internal.Get()); -} - -ClusterStyleStandard::ClusterStyleStandard(Internal::ClusterStyle* internal) -: ClusterStyle(internal) -{ -} - -// ClusterStyleRandom ///////////////////////////////////////////////////////// - -ClusterStyleRandom ClusterStyleRandom::New() -{ - Internal::ClusterStylePtr internal = Internal::ClusterStyleRandom::New(); - - return ClusterStyleRandom(internal.Get()); -} - -ClusterStyleRandom::ClusterStyleRandom(Internal::ClusterStyle* internal) -: ClusterStyle(internal) -{ -} - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/public-api/controls/cluster/cluster-style.h b/dali-toolkit/public-api/controls/cluster/cluster-style.h deleted file mode 100644 index 955f8e5..0000000 --- a/dali-toolkit/public-api/controls/cluster/cluster-style.h +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef __DALI_TOOLKIT_CLUSTER_STYLE_H__ -#define __DALI_TOOLKIT_CLUSTER_STYLE_H__ - -/* - * Copyright (c) 2015 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. - * - */ - -// EXTERNAL INCLUDES -#include -#include -#include -#include -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -class Actor; - -namespace Toolkit -{ - -namespace Internal DALI_INTERNAL -{ -class ClusterStyle; -class ClusterStyleRandom; -} - -class ClusterStyle; - -typedef IntrusivePtr ClusterStylePtr; ///< Pointer to a Dali::Toolkit::ClusterStyle object - -/** - * @brief A ClusterStyle describes the constraints which are imposed on the child actors in the cluster. - */ -class DALI_IMPORT_API ClusterStyle : public Dali::BaseHandle -{ -public: - - static const unsigned int UNLIMITED_CHILDREN; ///< Constant that represents an unlimited number of children. - -public: - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~ClusterStyle(); - - /** - * @brief Query the maximum number of children this Style can handle. - * - * If return value is UNLIMITED_CHILDREN, then this style has no - * limit. - * @return The maximum number of children. - */ - unsigned int GetMaximumNumberOfChildren() const; - - /** - * @brief Applies style (position) to child actor over a specified time duration. - * - * @param[in] child The child actor to apply - * @param[in] index The style position index for the actor to transform to. - * @param[in] alpha The alpha function to use. - * @param[in] durationSeconds The time period to apply this style. - */ - void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds); - - /** - * @brief Applies style to background actor over a specified time duration. - * - * @param[in] background The background actor to apply - * @param[in] alpha The alpha function to use. - * @param[in] durationSeconds The time period to apply this style. - */ - void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds); - - /** - * @brief Applies style to title actor over a specified time duration. - * - * @param[in] title The title actor to apply - * @param[in] alpha The alpha function to use. - * @param[in] durationSeconds The time period to apply this style. - */ - void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds); - -protected: - - /** - * @brief Create a new ClusterStyle; Only derived versions are instantiatable. - */ - ClusterStyle(); - -public: // Not intended for application developers - - /** - * @brief This constructor is used by Dali New() methods. - * - * @param [in] internal A pointer to a newly allocated Dali resource - */ - explicit DALI_INTERNAL ClusterStyle(Internal::ClusterStyle* internal); -}; - -/** - * @brief A ClusterStyle describes the constraints, which are imposed on the child actors in the cluster. - */ -class DALI_IMPORT_API ClusterStyleStandard : public ClusterStyle -{ -public: - - /** - * @brief Cluster Style type. - */ - enum StyleType - { - ClusterStyle1, ///< Style number 1 - ClusterStyle2, ///< Style number 2 - ClusterStyle3, ///< Style number 3 - ClusterStyle4, ///< Style number 4 - TotalClusterStyles ///< The number of styles - }; - -public: - - /** - * @brief Create an initialized style. - */ - static ClusterStyleStandard New(StyleType style); - -public: // Not intended for application developers - - /** - * @brief This constructor is used by Dali New() methods. - * - * @param [in] internal A pointer to a newly allocated Dali resource - */ - explicit DALI_INTERNAL ClusterStyleStandard(Internal::ClusterStyle* internal); -}; - -/** - * @brief A ClusterStyle describes the constraints, which are imposed on the child actors in the cluster. - */ -class DALI_IMPORT_API ClusterStyleRandom : public ClusterStyle -{ -public: - - /** - * @brief Create an initialized style. - */ - static ClusterStyleRandom New(); - -public: // Not intended for application developers - - /** - * @brief This constructor is used by Dali New() methods. - * - * @param [in] internal A pointer to a newly allocated Dali resource - */ - explicit DALI_INTERNAL ClusterStyleRandom(Internal::ClusterStyle* internal); -}; - -} // namespace Toolkit - -} // namespace Dali - -#endif // __DALI_TOOLKIT_CLUSTER_STYLE_H__ diff --git a/dali-toolkit/public-api/controls/cluster/cluster.cpp b/dali-toolkit/public-api/controls/cluster/cluster.cpp deleted file mode 100644 index ad90d64..0000000 --- a/dali-toolkit/public-api/controls/cluster/cluster.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2015 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 - -// INTERNAL INCLUDES - -#include - -namespace Dali -{ - -namespace Toolkit -{ - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Cluster -/////////////////////////////////////////////////////////////////////////////////////////////////// - -const std::string Cluster::CLUSTER_ACTOR_DEPTH( "cluster-actor-depth" ); - -Cluster::Cluster() -{ -} - -Cluster::Cluster(const Cluster& cluster) -: Control(cluster) -{ -} - -Cluster& Cluster::operator =(const Cluster& cluster) -{ - if( &cluster != this ) - { - Control::operator=( cluster ); - } - return *this; -} - -Cluster::~Cluster() -{ -} - -Cluster Cluster::New( ClusterStyle& style ) -{ - return Internal::Cluster::New(style); -} - -Cluster Cluster::DownCast( BaseHandle handle ) -{ - return Control::DownCast(handle); -} - -void Cluster::AddChild( Actor child ) -{ - GetImpl(*this).AddChild( child ); -} - -void Cluster::AddChild( Actor child, unsigned int positionIndex ) -{ - GetImpl(*this).AddChild( child, positionIndex); -} - -void Cluster::AddChildAt( Actor child, unsigned int index ) -{ - GetImpl(*this).AddChildAt( child, index ); -} - -void Cluster::AddChildAt( Actor child, unsigned int positionIndex, unsigned int index ) -{ - GetImpl(*this).AddChildAt( child, positionIndex, index ); -} - -Actor Cluster::GetChildAt( unsigned int index ) -{ - return GetImpl(*this).GetChildAt(index); -} - -Actor Cluster::RemoveChildAt( unsigned int index ) -{ - return GetImpl(*this).RemoveChildAt(index); -} - -void Cluster::ExpandChild( unsigned int index ) -{ - GetImpl(*this).ExpandChild(index); -} - -void Cluster::ExpandAllChildren() -{ - GetImpl(*this).ExpandAllChildren(); -} - -void Cluster::CollapseChild( unsigned int index, bool front ) -{ - GetImpl(*this).CollapseChild(index, front); -} - -void Cluster::CollapseAllChildren( bool front ) -{ - GetImpl(*this).CollapseAllChildren( front ); -} - -void Cluster::TransformChild( unsigned int index, const Vector3& position, const Vector3& scale, const Quaternion& rotation, AlphaFunction alpha, const TimePeriod& period ) -{ - GetImpl(*this).TransformChild( index, position, scale, rotation, alpha, period ); -} - -void Cluster::RestoreChild( unsigned int index, AlphaFunction alpha, const TimePeriod& period, bool front ) -{ - GetImpl(*this).RestoreChild( index, alpha, period, front ); -} - -void Cluster::SetBackgroundImage( Actor image ) -{ - GetImpl(*this).SetBackgroundImage(image); -} - -void Cluster::SetTitle( Actor text ) -{ - GetImpl(*this).SetTitle(text); -} - -void Cluster::SetStyle(ClusterStyle style) -{ - GetImpl(*this).SetStyle(style); -} - -ClusterStyle Cluster::GetStyle() const -{ - return GetImpl(*this).GetStyle(); -} - -unsigned int Cluster::GetExpandedCount() const -{ - return GetImpl(*this).GetExpandedCount(); -} - -unsigned int Cluster::GetTotalCount() const -{ - return GetImpl(*this).GetTotalCount(); -} - -Cluster::Cluster( Internal::Cluster& impl ) -: Control( impl ) -{ -} - -Cluster::Cluster( Dali::Internal::CustomActor* internal ) -: Control( internal ) -{ - VerifyCustomActorPointer(internal); -} - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/public-api/controls/cluster/cluster.h b/dali-toolkit/public-api/controls/cluster/cluster.h deleted file mode 100644 index 11dc5ae..0000000 --- a/dali-toolkit/public-api/controls/cluster/cluster.h +++ /dev/null @@ -1,264 +0,0 @@ -#ifndef __DALI_TOOLKIT_CLUSTER_H__ -#define __DALI_TOOLKIT_CLUSTER_H__ - -/* - * Copyright (c) 2015 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. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal DALI_INTERNAL -{ -class Cluster; -} - -class ClusterStyle; - -/** - * @brief Cluster is a container of grouped actors positioned in different cluster styles. - * - * Actions - * | %Action Name | Method | - * |---------------------------|---------------------------| - * | expand | DoExpandAction() | - * | collapse | DoCollapseAction() | - * | transform | DoTransformAction() | - */ -class DALI_IMPORT_API Cluster : public Control -{ -public: - - // Custom properties - - static const std::string CLUSTER_ACTOR_DEPTH; ///< Property, name "cluster-actor-depth", type float - -public: - - /** - * Create a Cluster handle; this can be initialised with Cluster::New() - * Calling member functions with an uninitialised handle is not allowed. - */ - Cluster(); - - /** - * Copy Constructor. - */ - Cluster( const Cluster& cluster ); - - /** - * Assignment Operator. - */ - Cluster& operator=( const Cluster& cluster ); - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~Cluster(); - - /** - * Create the Cluster control with the given style. - * @param[in] style The style of the cluster - * @return A handle to the Cluster control. - */ - static Cluster New( ClusterStyle& style ); - - /** - * Downcast an Object handle to Cluster. If handle points to a Cluster the - * downcast produces valid handle. If not the returned handle is left uninitialized. - * @param[in] handle Handle to an object - * @return handle to a Cluster or an uninitialized handle - */ - static Cluster DownCast( BaseHandle handle ); - - /** - * Adds a child to the Cluster - * Will automatically choose a position for the child. - * @pre The child actor has been initialized. - * @param[in] child The child to add - */ - void AddChild( Actor child ); - - /** - * Adds a child to the Cluster - * User specifies the position for the child. - * @pre The child actor has been initialized. - * @param[in] child The child to add - * @param[in] positionIndex The position for this child - */ - void AddChild( Actor child, unsigned int positionIndex ); - - /** - * Adds a child to the Cluster to be inserted at a specified - * depth index. - * Will automatically choose a position for the child. - * @pre The child actor has been initialized. - * @param[in] child The child to add - * @param[in] index The depth position for this child - */ - void AddChildAt( Actor child, unsigned int index ); - - /** - * Adds a child to the Cluster to be inserted at a specified - * depth index. - * User specifies the position for the child. - * @pre The child actor has been initialized. - * @param[in] child The child to add - * @param[in] positionIndex The position for this child - * @param[in] index The depth position for this child - */ - void AddChildAt( Actor child, unsigned int positionIndex, unsigned int index ); - - /** - * Returns a child from the given layout position - * Note! if there is no child in this layout position this method returns an uninitialized - * Actor handle - * @param[in] index The child index in the cluster - * @return The child that was in the layout position or an uninitialized handle - */ - Actor GetChildAt( unsigned int index ); - - /** - * Removes a child from the given layout position - * Note! if there is no child in this layout position this method does nothing - * @param[in] index The index of the child to remove - * @return The child that was removed or an uninitialized handle - */ - Actor RemoveChildAt( unsigned int index ); - - /** - * Expands a child - * A child will move away from the cluster. - * @param[in] index The child position index to expand - */ - void ExpandChild( unsigned int index ); - - /** - * Expands all children - * All children that have been collapsed will - * move away from the cluster - */ - void ExpandAllChildren(); - - /** - * Collapses a child - * A child that has been expanded will move - * back to its original positions. - * @param[in] index The child index to collapse - * @param[in] front Whether to move child to the front or - * back of cluster (depth). - */ - void CollapseChild( unsigned int index, bool front = false ); - - /** - * Collapses all children. - * All children that have been expanded will move - * back to their original positions. - * @param[in] front Whether to move child to the front or - * back of cluster (depth). - */ - void CollapseAllChildren( bool front = false ); - - /** - * Transforms Actor from default transform to new transform - * @param[in] index The child index to move - * @param[in] position The position to move to - * @param[in] scale The scale to change to - * @param[in] rotation The rotation to change to - * @param[in] alpha The alpha function to use to tween to this transform - * @param[in] period The duration for this transformation to take - */ - void TransformChild( unsigned int index, const Vector3& position, const Vector3& scale, const Quaternion& rotation, AlphaFunction alpha, const TimePeriod& period ); - - /** - * Restores Actor to the default transform (based on current style) - * @param[in] index The child index to move back - * @param[in] alpha The alpha function to use to tween to this transform - * @param[in] period The duration for this transformation to take - * @param[in] front Whether to move child to the front or - * back of cluster (depth). - */ - void RestoreChild( unsigned int index, AlphaFunction alpha, const TimePeriod& period, bool front = false ); - - /** - * Sets the background image. - * @param[in] image The background image. - */ - void SetBackgroundImage( Actor image ); - - /** - * Sets the title. - * - * @param[in] text Title text. - */ - void SetTitle( Actor text ); - - /** - * Sets the style of the cluster - * @param[in] style The style of the cluster - */ - void SetStyle(ClusterStyle style); - - /** - * Gets the style of the cluster - * @return style of the cluster - */ - ClusterStyle GetStyle() const; - - /** - * Gets the number of children that have been expanded in this cluster. - * @return the number of children expanded. - */ - unsigned int GetExpandedCount() const; - - /** - * Gets the number of children that have been added to this cluster. - * @return the total number of children. - */ - unsigned int GetTotalCount() const; - -public: // Not intended for application developers - - /** - * Creates a handle using the Toolkit::Internal implementation. - * @param[in] implementation The Control implementation. - */ - DALI_INTERNAL Cluster( Internal::Cluster& implementation ); - - /** - * Allows the creation of this Control from an Internal::CustomActor pointer. - * @param[in] internal A pointer to the internal CustomActor. - */ - explicit DALI_INTERNAL Cluster( Dali::Internal::CustomActor* internal ); -}; - -} // namespace Toolkit - -} // namespace Dali - -#endif // __DALI_TOOLKIT_CLUSTER_H__ diff --git a/dali-toolkit/public-api/controls/view/view.cpp b/dali-toolkit/public-api/controls/view/view.cpp deleted file mode 100644 index c072360..0000000 --- a/dali-toolkit/public-api/controls/view/view.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2015 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 "view.h" - -// EXTERNAL INCLUDES - -// INTERNAL INCLUDES - -#include - -namespace Dali -{ - -namespace Toolkit -{ - -View::View() -{ -} - -View::View( const View& handle ) -: Control( handle ) -{ -} - -View& View::operator=( const View& handle ) -{ - if( &handle != this ) - { - Control::operator=( handle ); - } - return *this; -} - -View::~View() -{ -} - -View View::New( bool fullscreen ) -{ - return Internal::View::New( fullscreen ); -} - -View View::DownCast( BaseHandle handle ) -{ - return Control::DownCast(handle); -} - -Layer View::GetContentLayer( unsigned int index ) const -{ - return GetImpl( *this ).GetContentLayer( index ); -} - -unsigned int View::AddContentLayer( Layer layer ) -{ - return GetImpl( *this ).AddContentLayer( layer ); -} - -void View::RemoveContentLayer( Layer layer ) -{ - GetImpl( *this ).RemoveContentLayer( layer ); -} - -Layer View::GetBackgroundLayer() const -{ - return GetImpl( *this ).GetBackgroundLayer(); -} - -void View::SetBackground( ImageActor image ) -{ - GetImpl( *this ).SetBackground( image ); -} - -void View::SetOrientationFunction( Degree portrait, Degree landscale, Degree portraitInverse, Degree landscapeInverse ) -{ - GetImpl( *this ).SetOrientationFunction( portrait, landscale, portraitInverse, landscapeInverse ); -} - -void View::OrientationChanged( Orientation orientation ) -{ - GetImpl( *this ).OrientationChanged( orientation ); -} - -void View::SetAutoRotate( bool enabled ) -{ - GetImpl( *this ).SetAutoRotate( enabled ); -} - -View::OrientationAnimationStartedSignalType& View::OrientationAnimationStartedSignal() -{ - return GetImpl( *this ).OrientationAnimationStartedSignal(); -} - -View::View( Internal::View& implementation ) -: Control( implementation ) -{ -} - -View::View( Dali::Internal::CustomActor* internal ) -: Control( internal ) -{ - VerifyCustomActorPointer(internal); -} - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/public-api/controls/view/view.h b/dali-toolkit/public-api/controls/view/view.h deleted file mode 100644 index 50de7bd..0000000 --- a/dali-toolkit/public-api/controls/view/view.h +++ /dev/null @@ -1,218 +0,0 @@ -#ifndef __DALI_TOOLKIT_VIEW_H__ -#define __DALI_TOOLKIT_VIEW_H__ - -/* - * Copyright (c) 2015 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. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal DALI_INTERNAL -{ -// Forward declarations -class View; -} - -/** - * View provides a container where different Dali::Layer instances and a background could be added. It - * also provides a View::OrientationChanged() method which could be connected to the Dali::Orientation::SignalChange() signal. - * This method rotates all layers accordingly with the given orientation, it emits an OrientationAnimationStartsSignal signal just before the rotation animation starts. - * - * By default view anchor point and parent origin are centered, the size is full screen and is got directly from the Dali::Stage. However, by passing \e false to the - * Toolkit::View::New() method a custom size could be specified, and after initialization, anchor point and parent origin could be updated. - * - * If a background is set, a background layer will be created and dropped to the bottom. - * - * Use example (application is a Dali::Application object): - * \code{.cpp} - * Stage stage = Stage::GetCurrent(); - * - * // Create default View. By default it gets the stage size. - * Toolkit::View view = Toolkit::View::New(); - * - * // Add the view to the stage before setting the background. - * stage.Add( view ); - * - * // Set background image. BACKGROUND_IMAGE is a string with the background image file path. - * Image backgroundImage = Image::New( BACKGROUND_IMAGE ); - * ImageActor backgroundImageActor = ImageActor::New( backgroundImage ); - * mView.SetBackground( backgroundImageActor ); - * - * // Connects the orientation signal with the View::OrientationChanged method. - * application.GetWindow().GetOrientation().ChangedSignal().Connect( &view, &Toolkit::View::OrientationChanged ); - * - * // Create a content layer. - * Layer contentLayer = Layer::New(); - * contentLayer.SetAnchorPoint( AnchorPoint::CENTER ); - * contentLayer.SetParentOrigin( ParentOrigin::CENTER ); - * view.AddContentLayer( contentLayer ); - * \endcode - * - * Signals - * | %Signal Name | Method | - * |-----------------------------|------------------------------------------| - * | orientation-animation-start | @ref OrientationAnimationStartedSignal() | - - */ -class DALI_IMPORT_API View : public Control -{ - -public: - - /** - * Create a View handle; this can be initialised with View::New() - * Calling member functions with an uninitialised handle is not allowed. - */ - View(); - - /** - * Copy constructor. Creates another handle that points to the same real object - * @param handle to copy from - */ - View( const View& handle ); - - /** - * Assignment operator. Changes this handle to point to another real object - */ - View& operator=( const View& handle ); - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~View(); - - /** - * Create an initialized View. - * @param fullscreen If true, the view's size is going to be set with the Dali::Stage size. Otherwise a size must be provided. By default fullscreen is set to true. - * @return A handle to a newly allocated Dali resource. - */ - static View New( bool fullscreen = true ); - - /** - * Downcast an Object handle to View. If handle points to a View the - * downcast produces valid handle. If not the returned handle is left uninitialized. - * @param[in] handle Handle to an object - * @return handle to a View or an uninitialized handle - */ - static View DownCast( BaseHandle handle ); - - /** - * Returns a content layer. - * @param index to the layer container. - * @return A Layer handle if it exists, otherwise it returns an uninitialized handle. - */ - Layer GetContentLayer( unsigned int index ) const; - - /** - * Adds a new layer in the view. - * @pre layer must be initialized. - * @param layer A Layer handle. - * @return the an index that can be used to access the layer stores in the view. - */ - unsigned int AddContentLayer( Layer layer ); - - /** - * Removes a layer from the view. - * @param layer The layer to be removed. - */ - void RemoveContentLayer( Layer layer ); - - /** - * Returns the background layer. - * @return the background layer or an empty handle if any background has been set before. - */ - Layer GetBackgroundLayer() const; - - /** - * Sets a background image. - * - * It creates a background layer the first time this method is called and it is dropped to the bottom. - * Any previous set background will be replaced by the new one. - * - * @pre View must be on stage before calling SetBackground. - * @param image An image actor. - */ - void SetBackground( ImageActor image ); - - /** - * Sets the angle values for portrait, landscape, portrait inverse and landscape inverse. - * - * These angles are used to rotate the views. - * By default, orientation angles are initialized as follows: portrait 0, landscape 90, portrait inverse 180, landscape inverse 270. - * - * @param portrait angle in degrees. - * @param landscale angle in degrees. - * @param portraitInverse angle in degrees. - * @param landscapeInverse angle in degrees. - */ - void SetOrientationFunction( Degree portrait, Degree landscale, Degree portraitInverse, Degree landscapeInverse ); - - /** - * It rotates all layers to the new given orientation. - * - * @param orientation The new orientation. - */ - void OrientationChanged( Orientation orientation ); - - /** - * Enables or disables the view's rotation when device orientation changes. - * @param enabled Whether auto-rotate should be enabled or disabled. By default is enabled. - */ - void SetAutoRotate( bool enabled ); - -public: //Signals - - // Orientation change animation starts. - typedef Signal< void ( View, Animation&, const Orientation& ) > OrientationAnimationStartedSignalType; - - /** - * Signal emitted just before the rotate animation starts when the device orientation changes. - */ - OrientationAnimationStartedSignalType& OrientationAnimationStartedSignal(); - -public: // Not intended for application developers - - /** - * Creates a handle using the Toolkit::Internal implementation. - * @param[in] implementation The Control implementation. - */ - DALI_INTERNAL View( Internal::View& implementation ); - - /** - * Allows the creation of this Control from an Internal::CustomActor pointer. - * @param[in] internal A pointer to the internal CustomActor. - */ - explicit DALI_INTERNAL View( Dali::Internal::CustomActor* internal ); -}; - -} // namespace Toolkit - -} // namespace Dali - -#endif // __DALI_TOOLKIT_VIEW_H__ diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list index 41c390a..3eea93c 100755 --- a/dali-toolkit/public-api/file.list +++ b/dali-toolkit/public-api/file.list @@ -53,12 +53,9 @@ public_api_src_files = \ $(public_api_src_dir)/controls/text-controls/text-selection-popup.cpp \ $(public_api_src_dir)/controls/tool-bar/tool-bar.cpp \ $(public_api_src_dir)/controls/bloom-view/bloom-view.cpp \ - $(public_api_src_dir)/controls/cluster/cluster-style.cpp \ - $(public_api_src_dir)/controls/cluster/cluster.cpp \ $(public_api_src_dir)/controls/effects-view/effects-view.cpp \ $(public_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.cpp \ $(public_api_src_dir)/controls/image-view/masked-image-view.cpp \ - $(public_api_src_dir)/controls/view/view.cpp \ $(public_api_src_dir)/focus-manager/focus-manager.cpp \ $(public_api_src_dir)/focus-manager/keyboard-focus-manager.cpp \ $(public_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \ @@ -131,10 +128,6 @@ public_api_bloom_view_header_files = \ public_api_bubble_emitter_header_files = \ $(public_api_src_dir)/controls/bubble-effect/bubble-emitter.h -public_api_cluster_header_files = \ - $(public_api_src_dir)/controls/cluster/cluster-style.h \ - $(public_api_src_dir)/controls/cluster/cluster.h - public_api_default_controls_header_files = \ $(public_api_src_dir)/controls/default-controls/check-button-factory.h \ $(public_api_src_dir)/controls/default-controls/push-button-factory.h \ @@ -216,9 +209,6 @@ public_api_navigation_frame_header_files = \ $(public_api_src_dir)/controls/navigation-frame/navigation-control.h \ $(public_api_src_dir)/controls/navigation-frame/page.h -public_api_view_header_files = \ - $(public_api_src_dir)/controls/view/view.h - public_api_focus_manager_header_files = \ $(public_api_src_dir)/focus-manager/focus-manager.h \ $(public_api_src_dir)/focus-manager/keyboard-focus-manager.h \