Commit 36aae0a78668419cae359b026bca56eedf9a369d
Committed by
Gerrit Code Review
Merge "Changes for std::vector removal from api" into tizen
Showing
2 changed files
with
50 additions
and
34 deletions
examples/cluster/cluster-impl.cpp
| ... | ... | @@ -23,7 +23,9 @@ |
| 23 | 23 | #include <cstring> // for strcmp |
| 24 | 24 | #include <dali/public-api/animation/animation.h> |
| 25 | 25 | #include <dali/public-api/object/type-registry.h> |
| 26 | +#include <dali/public-api/object/property-array.h> | |
| 26 | 27 | #include <dali/devel-api/object/type-registry-helper.h> |
| 28 | +#include <dali/devel-api/scripting/scripting.h> | |
| 27 | 29 | #include <dali/integration-api/debug.h> |
| 28 | 30 | |
| 29 | 31 | // INTERNAL INCLUDES |
| ... | ... | @@ -475,17 +477,21 @@ void Cluster::UpdateTitle(float duration) |
| 475 | 477 | } |
| 476 | 478 | } |
| 477 | 479 | |
| 478 | -void Cluster::DoExpandAction(const PropertyValueContainer& attributes) | |
| 480 | +void Cluster::DoExpandAction(const Property::Map& attributes) | |
| 479 | 481 | { |
| 480 | - if(attributes.size() >= 1) | |
| 482 | + Property::Value* value = attributes.Find( "indices" ); | |
| 483 | + | |
| 484 | + if( value ) | |
| 481 | 485 | { |
| 482 | - for(PropertyValueConstIter iter = attributes.begin(); iter != attributes.end(); ++iter) | |
| 486 | + if( value->GetType() == Property::ARRAY ) | |
| 483 | 487 | { |
| 484 | - const Property::Value& value = *iter; | |
| 485 | - | |
| 486 | - DALI_ASSERT_ALWAYS(value.GetType() == Property::FLOAT); | |
| 487 | - unsigned int index = value.Get<float>(); | |
| 488 | - ExpandChild( index ); | |
| 488 | + Property::Array array = value->Get<Property::Array>(); | |
| 489 | + for( size_t i = 0; i < array.Size(); i++ ) | |
| 490 | + { | |
| 491 | + Property::Value& item = array[i]; | |
| 492 | + DALI_ASSERT_ALWAYS(item.GetType() == Property::INTEGER); | |
| 493 | + ExpandChild( item.Get<int>() ); | |
| 494 | + } | |
| 489 | 495 | } |
| 490 | 496 | } |
| 491 | 497 | else |
| ... | ... | @@ -494,17 +500,21 @@ void Cluster::DoExpandAction(const PropertyValueContainer& attributes) |
| 494 | 500 | } |
| 495 | 501 | } |
| 496 | 502 | |
| 497 | -void Cluster::DoCollapseAction(const PropertyValueContainer& attributes) | |
| 503 | +void Cluster::DoCollapseAction(const Property::Map& attributes) | |
| 498 | 504 | { |
| 499 | - if(attributes.size() >= 1) | |
| 505 | + Property::Value* value = attributes.Find( "indices" ); | |
| 506 | + | |
| 507 | + if( value ) | |
| 500 | 508 | { |
| 501 | - for(PropertyValueConstIter iter = attributes.begin(); iter != attributes.end(); ++iter) | |
| 509 | + if( value->GetType() == Property::ARRAY ) | |
| 502 | 510 | { |
| 503 | - const Property::Value& value = *iter; | |
| 504 | - | |
| 505 | - DALI_ASSERT_ALWAYS(value.GetType() == Property::FLOAT); | |
| 506 | - unsigned int index = value.Get<float>(); | |
| 507 | - CollapseChild( index, false ); | |
| 511 | + Property::Array array = value->Get<Property::Array>(); | |
| 512 | + for( size_t i = 0; i < array.Size(); i++ ) | |
| 513 | + { | |
| 514 | + Property::Value& item = array[i]; | |
| 515 | + DALI_ASSERT_ALWAYS(item.GetType() == Property::INTEGER); | |
| 516 | + CollapseChild( item.Get<int>(), false ); | |
| 517 | + } | |
| 508 | 518 | } |
| 509 | 519 | } |
| 510 | 520 | else |
| ... | ... | @@ -513,27 +523,33 @@ void Cluster::DoCollapseAction(const PropertyValueContainer& attributes) |
| 513 | 523 | } |
| 514 | 524 | } |
| 515 | 525 | |
| 516 | -void Cluster::DoTransformAction(const PropertyValueContainer& attributes) | |
| 526 | + | |
| 527 | +void Cluster::DoTransformAction(const Property::Map& attributes) | |
| 517 | 528 | { |
| 518 | - DALI_ASSERT_ALWAYS(attributes.size() >= 2); | |
| 529 | + typedef Dali::StringValuePair StringValuePair; | |
| 519 | 530 | |
| 520 | - DALI_ASSERT_ALWAYS(attributes[0].GetType() == Property::FLOAT); | |
| 521 | - unsigned int index = attributes[0].Get<float>(); | |
| 531 | + int index = 0; | |
| 522 | 532 | Vector3 position; |
| 523 | 533 | Vector3 scale(Vector3::ONE); |
| 524 | 534 | Quaternion rotation( Dali::ANGLE_0, Vector3::ZAXIS ); |
| 525 | 535 | |
| 526 | - DALI_ASSERT_ALWAYS(attributes[1].GetType() == Property::VECTOR3); | |
| 527 | - attributes[1].Get(position); | |
| 528 | - | |
| 529 | - if(attributes.size()>2) | |
| 536 | + for(size_t i = 0; i < attributes.Count(); i++) | |
| 530 | 537 | { |
| 531 | - attributes[2].Get(scale); | |
| 532 | - } | |
| 538 | + StringValuePair& stringValue = attributes.GetPair(i); | |
| 539 | + Property::Type type = stringValue.second.GetType(); | |
| 533 | 540 | |
| 534 | - if(attributes.size()>3) | |
| 535 | - { | |
| 536 | - attributes[3].Get(rotation); | |
| 541 | + if( Property::VECTOR3 == type && "position" == stringValue.first ) | |
| 542 | + { | |
| 543 | + stringValue.second.Get(position); | |
| 544 | + } | |
| 545 | + else if( Property::VECTOR3 == type && "scale" == stringValue.first ) | |
| 546 | + { | |
| 547 | + stringValue.second.Get(scale); | |
| 548 | + } | |
| 549 | + else if( "rotation" == stringValue.first ) | |
| 550 | + { | |
| 551 | + (void)Scripting::SetRotation(stringValue.second, rotation); | |
| 552 | + } | |
| 537 | 553 | } |
| 538 | 554 | |
| 539 | 555 | // wrap index around -1 => size - 1 |
| ... | ... | @@ -547,7 +563,7 @@ void Cluster::OnControlChildRemove(Actor& child) |
| 547 | 563 | child.RemoveConstraints(); |
| 548 | 564 | } |
| 549 | 565 | |
| 550 | -bool Cluster::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes) | |
| 566 | +bool Cluster::DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes) | |
| 551 | 567 | { |
| 552 | 568 | bool ret = false; |
| 553 | 569 | ... | ... |
examples/cluster/cluster-impl.h
| ... | ... | @@ -212,7 +212,7 @@ private: |
| 212 | 212 | * @param[in] attributes list of indices of actors to expand. |
| 213 | 213 | * (if no attributes specifies, then all actors expand) |
| 214 | 214 | */ |
| 215 | - void DoExpandAction(const PropertyValueContainer& attributes); | |
| 215 | + void DoExpandAction(const Property::Map& attributes); | |
| 216 | 216 | |
| 217 | 217 | /** |
| 218 | 218 | * Action: Collapse |
| ... | ... | @@ -221,7 +221,7 @@ private: |
| 221 | 221 | * @param[in] attributes list of indices of actors to collapse. |
| 222 | 222 | * (if no attributes specifies, then all actors collapse) |
| 223 | 223 | */ |
| 224 | - void DoCollapseAction(const PropertyValueContainer& attributes); | |
| 224 | + void DoCollapseAction(const Property::Map& attributes); | |
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | 227 | * Action: Transform |
| ... | ... | @@ -230,7 +230,7 @@ private: |
| 230 | 230 | * |
| 231 | 231 | * @param[in] attributes index and transform values. |
| 232 | 232 | */ |
| 233 | - void DoTransformAction(const PropertyValueContainer& attributes); | |
| 233 | + void DoTransformAction(const Property::Map& attributes); | |
| 234 | 234 | |
| 235 | 235 | private: // From Control |
| 236 | 236 | /** |
| ... | ... | @@ -248,7 +248,7 @@ public: |
| 248 | 248 | * @param[in] attributes The attributes with which to perfrom this action. |
| 249 | 249 | * @return true if action has been accepted by this control |
| 250 | 250 | */ |
| 251 | - static bool DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes); | |
| 251 | + static bool DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes); | |
| 252 | 252 | |
| 253 | 253 | private: // From Control |
| 254 | 254 | ... | ... |