Commit 386c24d26e97c645a7a6dbecb16710293fe455e7
1 parent
fd844cdb
Changes required after Visual parent-origin & anchor-point defaults change
Change-Id: Ia9ba3566e226a73c2ccdc5716e6d64c638bbfc1b
Showing
5 changed files
with
62 additions
and
14 deletions
examples/mesh-visual/mesh-visual-example.cpp
| 1 | #include <dali-toolkit/dali-toolkit.h> | 1 | #include <dali-toolkit/dali-toolkit.h> |
| 2 | #include <dali/public-api/object/property-map.h> | 2 | #include <dali/public-api/object/property-map.h> |
| 3 | +#include <dali-toolkit/devel-api/align-enums.h> | ||
| 4 | +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> | ||
| 3 | 5 | ||
| 4 | using namespace Dali; | 6 | using namespace Dali; |
| 5 | using namespace Dali::Toolkit; | 7 | using namespace Dali::Toolkit; |
| @@ -321,6 +323,9 @@ public: | @@ -321,6 +323,9 @@ public: | ||
| 321 | //Create mesh property map | 323 | //Create mesh property map |
| 322 | Property::Map map; | 324 | Property::Map map; |
| 323 | map.Insert( Visual::Property::TYPE, Visual::MESH ); | 325 | map.Insert( Visual::Property::TYPE, Visual::MESH ); |
| 326 | + map.Insert( DevelVisual::Property::TRANSFORM, | ||
| 327 | + Property::Map().Add( DevelVisual::Transform::Property::ORIGIN, Align::CENTER ) | ||
| 328 | + .Add( DevelVisual::Transform::Property::ANCHOR_POINT, Align::CENTER ) ); | ||
| 324 | map.Insert( MeshVisual::Property::OBJECT_URL, MODEL_FILE_TABLE[mModelIndex] ); | 329 | map.Insert( MeshVisual::Property::OBJECT_URL, MODEL_FILE_TABLE[mModelIndex] ); |
| 325 | map.Insert( MeshVisual::Property::MATERIAL_URL, MATERIAL_FILE_TABLE[mModelIndex] ); | 330 | map.Insert( MeshVisual::Property::MATERIAL_URL, MATERIAL_FILE_TABLE[mModelIndex] ); |
| 326 | map.Insert( MeshVisual::Property::TEXTURES_PATH, TEXTURES_PATH ); | 331 | map.Insert( MeshVisual::Property::TEXTURES_PATH, TEXTURES_PATH ); |
examples/primitive-shapes/primitive-shapes-example.cpp
| @@ -17,7 +17,9 @@ | @@ -17,7 +17,9 @@ | ||
| 17 | 17 | ||
| 18 | #include <dali-toolkit/dali-toolkit.h> | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | #include <dali/public-api/object/property-map.h> | 19 | #include <dali/public-api/object/property-map.h> |
| 20 | +#include <dali-toolkit/devel-api/align-enums.h> | ||
| 20 | #include <dali-toolkit/devel-api/controls/buttons/button-devel.h> | 21 | #include <dali-toolkit/devel-api/controls/buttons/button-devel.h> |
| 22 | +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> | ||
| 21 | #include <dali-toolkit/public-api/controls/slider/slider.h> | 23 | #include <dali-toolkit/public-api/controls/slider/slider.h> |
| 22 | 24 | ||
| 23 | using namespace Dali; | 25 | using namespace Dali; |
| @@ -355,6 +357,9 @@ public: | @@ -355,6 +357,9 @@ public: | ||
| 355 | mVisualMap.Clear(); | 357 | mVisualMap.Clear(); |
| 356 | mVisualMap[ Visual::Property::TYPE ] = Visual::PRIMITIVE; | 358 | mVisualMap[ Visual::Property::TYPE ] = Visual::PRIMITIVE; |
| 357 | mVisualMap[ PrimitiveVisual::Property::MIX_COLOR ] = mColor; | 359 | mVisualMap[ PrimitiveVisual::Property::MIX_COLOR ] = mColor; |
| 360 | + mVisualMap[ DevelVisual::Property::TRANSFORM ] = | ||
| 361 | + Property::Map().Add( DevelVisual::Transform::Property::ORIGIN, Align::CENTER ) | ||
| 362 | + .Add( DevelVisual::Transform::Property::ANCHOR_POINT, Align::CENTER ); | ||
| 358 | } | 363 | } |
| 359 | 364 | ||
| 360 | //Sets the 3D model to a sphere and modifies the sliders appropriately. | 365 | //Sets the 3D model to a sphere and modifies the sliders appropriately. |
examples/visual-transitions/beat-control-impl.cpp
| @@ -17,13 +17,10 @@ | @@ -17,13 +17,10 @@ | ||
| 17 | #include "beat-control-impl.h" | 17 | #include "beat-control-impl.h" |
| 18 | #include <dali-toolkit/dali-toolkit.h> | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | #include <dali/public-api/object/type-registry-helper.h> | 19 | #include <dali/public-api/object/type-registry-helper.h> |
| 20 | -#include <dali-toolkit/devel-api/align-enums.h> | ||
| 21 | #include <dali-toolkit/devel-api/controls/control-devel.h> | 20 | #include <dali-toolkit/devel-api/controls/control-devel.h> |
| 22 | #include <dali-toolkit/devel-api/visual-factory/visual-factory.h> | 21 | #include <dali-toolkit/devel-api/visual-factory/visual-factory.h> |
| 23 | #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> | 22 | #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> |
| 24 | 23 | ||
| 25 | -#include <cstdio> | ||
| 26 | - | ||
| 27 | using namespace Dali; // Needed for macros | 24 | using namespace Dali; // Needed for macros |
| 28 | using namespace Dali::Toolkit; | 25 | using namespace Dali::Toolkit; |
| 29 | 26 | ||
| @@ -60,13 +57,18 @@ Toolkit::TransitionData ConvertPropertyToTransition( const Property::Value& valu | @@ -60,13 +57,18 @@ Toolkit::TransitionData ConvertPropertyToTransition( const Property::Value& valu | ||
| 60 | { | 57 | { |
| 61 | Toolkit::TransitionData transitionData; | 58 | Toolkit::TransitionData transitionData; |
| 62 | 59 | ||
| 63 | - if( value.GetType() == Property::ARRAY ) | 60 | + const Property::Array* array = value.GetArray(); |
| 61 | + if( array ) | ||
| 64 | { | 62 | { |
| 65 | - transitionData = Toolkit::TransitionData::New( *value.GetArray()); | 63 | + transitionData = Toolkit::TransitionData::New( *array ); |
| 66 | } | 64 | } |
| 67 | - else if( value.GetType() == Property::MAP ) | 65 | + else |
| 68 | { | 66 | { |
| 69 | - transitionData = Toolkit::TransitionData::New( *value.GetMap() ); | 67 | + const Property::Map* map = value.GetMap(); |
| 68 | + if( map ) | ||
| 69 | + { | ||
| 70 | + transitionData = Toolkit::TransitionData::New( *map ); | ||
| 71 | + } | ||
| 70 | } | 72 | } |
| 71 | return transitionData; | 73 | return transitionData; |
| 72 | } | 74 | } |
| @@ -77,6 +79,8 @@ Toolkit::TransitionData ConvertPropertyToTransition( const Property::Value& valu | @@ -77,6 +79,8 @@ Toolkit::TransitionData ConvertPropertyToTransition( const Property::Value& valu | ||
| 77 | Internal::BeatControl::BeatControl() | 79 | Internal::BeatControl::BeatControl() |
| 78 | : Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ), | 80 | : Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ), |
| 79 | mTransformSize(1.0f, 1.0f), | 81 | mTransformSize(1.0f, 1.0f), |
| 82 | + mTransformOrigin(Align::CENTER), | ||
| 83 | + mTransformAnchorPoint(Align::CENTER), | ||
| 80 | mAnimationPlaying(0) | 84 | mAnimationPlaying(0) |
| 81 | { | 85 | { |
| 82 | } | 86 | } |
| @@ -209,6 +213,8 @@ void BeatControl::RelayoutVisuals( const Vector2& targetSize ) | @@ -209,6 +213,8 @@ void BeatControl::RelayoutVisuals( const Vector2& targetSize ) | ||
| 209 | // Make the visual half the size of the control, but leave | 213 | // Make the visual half the size of the control, but leave |
| 210 | // origin and anchor point at center, position is relative, but Zer0 | 214 | // origin and anchor point at center, position is relative, but Zer0 |
| 211 | transformMap[ DevelVisual::Transform::Property::SIZE ] = mTransformSize; | 215 | transformMap[ DevelVisual::Transform::Property::SIZE ] = mTransformSize; |
| 216 | + transformMap[ DevelVisual::Transform::Property::ORIGIN ] = mTransformOrigin; | ||
| 217 | + transformMap[ DevelVisual::Transform::Property::ANCHOR_POINT ] = mTransformAnchorPoint; | ||
| 212 | mVisual.SetTransformAndSize( transformMap, size ); | 218 | mVisual.SetTransformAndSize( transformMap, size ); |
| 213 | } | 219 | } |
| 214 | } | 220 | } |
| @@ -249,7 +255,7 @@ void BeatControl::SetProperty( BaseObject* object, Property::Index index, const | @@ -249,7 +255,7 @@ void BeatControl::SetProperty( BaseObject* object, Property::Index index, const | ||
| 249 | { | 255 | { |
| 250 | case Demo::BeatControl::Property::BEAT_VISUAL: | 256 | case Demo::BeatControl::Property::BEAT_VISUAL: |
| 251 | { | 257 | { |
| 252 | - bool sizeOnly = false; | 258 | + bool sizeAndPositionOnly = false; |
| 253 | 259 | ||
| 254 | // Determine if a transform.size property exists in the map, and | 260 | // Determine if a transform.size property exists in the map, and |
| 255 | // save it. | 261 | // save it. |
| @@ -262,18 +268,47 @@ void BeatControl::SetProperty( BaseObject* object, Property::Index index, const | @@ -262,18 +268,47 @@ void BeatControl::SetProperty( BaseObject* object, Property::Index index, const | ||
| 262 | Property::Map* transformMap = value->GetMap(); | 268 | Property::Map* transformMap = value->GetMap(); |
| 263 | if( transformMap ) | 269 | if( transformMap ) |
| 264 | { | 270 | { |
| 271 | + // We'll increment this whenever SIZE, ORIGIN or ANCHOR_POINT's are modified as we won't need to create a new visual if only these properties are used | ||
| 272 | + // If there are more properties in the transform map, then we need to create a new visual | ||
| 273 | + unsigned int sizeAndPositionPropertyCount = 0; | ||
| 274 | + | ||
| 265 | Property::Value* sizeValue = transformMap->Find( DevelVisual::Transform::Property::SIZE, "size" ); | 275 | Property::Value* sizeValue = transformMap->Find( DevelVisual::Transform::Property::SIZE, "size" ); |
| 266 | if( sizeValue ) | 276 | if( sizeValue ) |
| 267 | { | 277 | { |
| 268 | sizeValue->Get( impl.mTransformSize ); | 278 | sizeValue->Get( impl.mTransformSize ); |
| 269 | - if( map->Count() == 1 && transformMap->Count() == 1 ) | 279 | + ++sizeAndPositionPropertyCount; |
| 280 | + } | ||
| 281 | + | ||
| 282 | + Property::Value* originValue = transformMap->Find( DevelVisual::Transform::Property::ORIGIN, "origin" ); | ||
| 283 | + if( originValue ) | ||
| 284 | + { | ||
| 285 | + int intValue = 0; | ||
| 286 | + if( originValue->Get( intValue ) ) | ||
| 270 | { | 287 | { |
| 271 | - sizeOnly = true; | 288 | + impl.mTransformOrigin = static_cast< Toolkit::Align::Type >( intValue ); |
| 289 | + ++sizeAndPositionPropertyCount; | ||
| 272 | } | 290 | } |
| 273 | } | 291 | } |
| 292 | + | ||
| 293 | + Property::Value* anchorPointValue = transformMap->Find( DevelVisual::Transform::Property::ANCHOR_POINT, "anchorPoint" ); | ||
| 294 | + if( anchorPointValue ) | ||
| 295 | + { | ||
| 296 | + int intValue = 0; | ||
| 297 | + if( anchorPointValue->Get( intValue ) ) | ||
| 298 | + { | ||
| 299 | + impl.mTransformAnchorPoint = static_cast< Toolkit::Align::Type >( intValue ); | ||
| 300 | + ++sizeAndPositionPropertyCount; | ||
| 301 | + } | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + // If the only properties that the application is overriding are the size and the position properties, then we do not need to create another visual. | ||
| 305 | + if( map->Count() == 1 && transformMap->Count() == sizeAndPositionPropertyCount ) | ||
| 306 | + { | ||
| 307 | + sizeAndPositionOnly = true; | ||
| 308 | + } | ||
| 274 | } | 309 | } |
| 275 | } | 310 | } |
| 276 | - if( ! sizeOnly ) | 311 | + if( ! sizeAndPositionOnly ) |
| 277 | { | 312 | { |
| 278 | // Only register a visual if there is more than just a size setting | 313 | // Only register a visual if there is more than just a size setting |
| 279 | impl.mVisual = Toolkit::VisualFactory::Get().CreateVisual( *map ); | 314 | impl.mVisual = Toolkit::VisualFactory::Get().CreateVisual( *map ); |
examples/visual-transitions/beat-control-impl.h
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | #define DALI_DEMO_INTERNAL_BEAT_CONTROL_IMPL_H | 2 | #define DALI_DEMO_INTERNAL_BEAT_CONTROL_IMPL_H |
| 3 | 3 | ||
| 4 | /* | 4 | /* |
| 5 | - * Copyright (c) 2016 Samsung Electronics Co., Ltd. | 5 | + * Copyright (c) 2017 Samsung Electronics Co., Ltd. |
| 6 | * | 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. | 8 | * you may not use this file except in compliance with the License. |
| @@ -20,6 +20,7 @@ | @@ -20,6 +20,7 @@ | ||
| 20 | #include "beat-control.h" | 20 | #include "beat-control.h" |
| 21 | #include <dali/public-api/animation/animation.h> | 21 | #include <dali/public-api/animation/animation.h> |
| 22 | #include <dali-toolkit/public-api/controls/control-impl.h> | 22 | #include <dali-toolkit/public-api/controls/control-impl.h> |
| 23 | +#include <dali-toolkit/devel-api/align-enums.h> | ||
| 23 | #include <dali-toolkit/devel-api/visual-factory/visual-base.h> | 24 | #include <dali-toolkit/devel-api/visual-factory/visual-base.h> |
| 24 | #include <dali-toolkit/devel-api/visual-factory/transition-data.h> | 25 | #include <dali-toolkit/devel-api/visual-factory/transition-data.h> |
| 25 | 26 | ||
| @@ -128,6 +129,8 @@ private: | @@ -128,6 +129,8 @@ private: | ||
| 128 | Dali::Animation mYAnimation; | 129 | Dali::Animation mYAnimation; |
| 129 | Dali::Animation mFadeAnimation; | 130 | Dali::Animation mFadeAnimation; |
| 130 | Dali::Vector2 mTransformSize; | 131 | Dali::Vector2 mTransformSize; |
| 132 | + Dali::Toolkit::Align::Type mTransformOrigin; | ||
| 133 | + Dali::Toolkit::Align::Type mTransformAnchorPoint; | ||
| 131 | int mAnimationPlaying; | 134 | int mAnimationPlaying; |
| 132 | }; | 135 | }; |
| 133 | 136 |
examples/visual-transitions/transition-application.cpp
| 1 | /* | 1 | /* |
| 2 | - * Copyright (c) 2016 Samsung Electronics Co., Ltd. | 2 | + * Copyright (c) 2017 Samsung Electronics Co., Ltd. |
| 3 | * | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
| @@ -124,7 +124,7 @@ void TransitionApplication::Create( Application& application ) | @@ -124,7 +124,7 @@ void TransitionApplication::Create( Application& application ) | ||
| 124 | Property::Map map; | 124 | Property::Map map; |
| 125 | CreateVisualMap( i, map ); | 125 | CreateVisualMap( i, map ); |
| 126 | map.Add( DevelVisual::Property::TRANSFORM, Property::Map() | 126 | map.Add( DevelVisual::Property::TRANSFORM, Property::Map() |
| 127 | - .Add( DevelVisual::Transform::Property::SIZE, Vector2(0.8f, 0.8f) ) ); | 127 | + .Add( DevelVisual::Transform::Property::SIZE, Vector2(0.8f, 0.8f) ) ); |
| 128 | mVisualButtons[i] = BeatControl::New(); | 128 | mVisualButtons[i] = BeatControl::New(); |
| 129 | mVisualButtons[i].SetProperty( BeatControl::Property::BEAT_VISUAL, map ); | 129 | mVisualButtons[i].SetProperty( BeatControl::Property::BEAT_VISUAL, map ); |
| 130 | mVisualButtons[i].SetName("VisualButton"); | 130 | mVisualButtons[i].SetName("VisualButton"); |