From 3d4dc75a2f08d9002c57064a066a99e468916536 Mon Sep 17 00:00:00 2001 From: Lee Morgan Date: Fri, 29 May 2015 14:52:11 +0100 Subject: [PATCH] Changes for std::vector removal from api Change-Id: I9f0acd2d9f4c70911e883d6637772e62c5e509e7 --- examples/cluster/cluster-impl.cpp | 76 +++++++++++++++++++++++---------------- examples/cluster/cluster-impl.h | 8 ++--- 2 files changed, 50 insertions(+), 34 deletions(-) diff --git a/examples/cluster/cluster-impl.cpp b/examples/cluster/cluster-impl.cpp index 0edda67..a37214e 100644 --- a/examples/cluster/cluster-impl.cpp +++ b/examples/cluster/cluster-impl.cpp @@ -23,7 +23,9 @@ #include // for strcmp #include #include +#include #include +#include #include // INTERNAL INCLUDES @@ -475,17 +477,21 @@ void Cluster::UpdateTitle(float duration) } } -void Cluster::DoExpandAction(const PropertyValueContainer& attributes) +void Cluster::DoExpandAction(const Property::Map& attributes) { - if(attributes.size() >= 1) + Property::Value* value = attributes.Find( "indices" ); + + if( value ) { - for(PropertyValueConstIter iter = attributes.begin(); iter != attributes.end(); ++iter) + if( value->GetType() == Property::ARRAY ) { - const Property::Value& value = *iter; - - DALI_ASSERT_ALWAYS(value.GetType() == Property::FLOAT); - unsigned int index = value.Get(); - ExpandChild( index ); + Property::Array array = value->Get(); + for( size_t i = 0; i < array.Size(); i++ ) + { + Property::Value& item = array[i]; + DALI_ASSERT_ALWAYS(item.GetType() == Property::INTEGER); + ExpandChild( item.Get() ); + } } } else @@ -494,17 +500,21 @@ void Cluster::DoExpandAction(const PropertyValueContainer& attributes) } } -void Cluster::DoCollapseAction(const PropertyValueContainer& attributes) +void Cluster::DoCollapseAction(const Property::Map& attributes) { - if(attributes.size() >= 1) + Property::Value* value = attributes.Find( "indices" ); + + if( value ) { - for(PropertyValueConstIter iter = attributes.begin(); iter != attributes.end(); ++iter) + if( value->GetType() == Property::ARRAY ) { - const Property::Value& value = *iter; - - DALI_ASSERT_ALWAYS(value.GetType() == Property::FLOAT); - unsigned int index = value.Get(); - CollapseChild( index, false ); + Property::Array array = value->Get(); + for( size_t i = 0; i < array.Size(); i++ ) + { + Property::Value& item = array[i]; + DALI_ASSERT_ALWAYS(item.GetType() == Property::INTEGER); + CollapseChild( item.Get(), false ); + } } } else @@ -513,27 +523,33 @@ void Cluster::DoCollapseAction(const PropertyValueContainer& attributes) } } -void Cluster::DoTransformAction(const PropertyValueContainer& attributes) + +void Cluster::DoTransformAction(const Property::Map& attributes) { - DALI_ASSERT_ALWAYS(attributes.size() >= 2); + typedef Dali::StringValuePair StringValuePair; - DALI_ASSERT_ALWAYS(attributes[0].GetType() == Property::FLOAT); - unsigned int index = attributes[0].Get(); + int index = 0; 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) + for(size_t i = 0; i < attributes.Count(); i++) { - attributes[2].Get(scale); - } + StringValuePair& stringValue = attributes.GetPair(i); + Property::Type type = stringValue.second.GetType(); - if(attributes.size()>3) - { - attributes[3].Get(rotation); + if( Property::VECTOR3 == type && "position" == stringValue.first ) + { + stringValue.second.Get(position); + } + else if( Property::VECTOR3 == type && "scale" == stringValue.first ) + { + stringValue.second.Get(scale); + } + else if( "rotation" == stringValue.first ) + { + (void)Scripting::SetRotation(stringValue.second, rotation); + } } // wrap index around -1 => size - 1 @@ -547,7 +563,7 @@ void Cluster::OnControlChildRemove(Actor& child) child.RemoveConstraints(); } -bool Cluster::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes) +bool Cluster::DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes) { bool ret = false; diff --git a/examples/cluster/cluster-impl.h b/examples/cluster/cluster-impl.h index 7c8a408..a81a5ea 100644 --- a/examples/cluster/cluster-impl.h +++ b/examples/cluster/cluster-impl.h @@ -212,7 +212,7 @@ private: * @param[in] attributes list of indices of actors to expand. * (if no attributes specifies, then all actors expand) */ - void DoExpandAction(const PropertyValueContainer& attributes); + void DoExpandAction(const Property::Map& attributes); /** * Action: Collapse @@ -221,7 +221,7 @@ private: * @param[in] attributes list of indices of actors to collapse. * (if no attributes specifies, then all actors collapse) */ - void DoCollapseAction(const PropertyValueContainer& attributes); + void DoCollapseAction(const Property::Map& attributes); /** * Action: Transform @@ -230,7 +230,7 @@ private: * * @param[in] attributes index and transform values. */ - void DoTransformAction(const PropertyValueContainer& attributes); + void DoTransformAction(const Property::Map& attributes); private: // From Control /** @@ -248,7 +248,7 @@ public: * @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); + static bool DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes); private: // From Control -- 2.7.4