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 | 1 | #include <dali-toolkit/dali-toolkit.h> |
| 2 | 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 | 6 | using namespace Dali; |
| 5 | 7 | using namespace Dali::Toolkit; |
| ... | ... | @@ -321,6 +323,9 @@ public: |
| 321 | 323 | //Create mesh property map |
| 322 | 324 | Property::Map map; |
| 323 | 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 | 329 | map.Insert( MeshVisual::Property::OBJECT_URL, MODEL_FILE_TABLE[mModelIndex] ); |
| 325 | 330 | map.Insert( MeshVisual::Property::MATERIAL_URL, MATERIAL_FILE_TABLE[mModelIndex] ); |
| 326 | 331 | map.Insert( MeshVisual::Property::TEXTURES_PATH, TEXTURES_PATH ); | ... | ... |
examples/primitive-shapes/primitive-shapes-example.cpp
| ... | ... | @@ -17,7 +17,9 @@ |
| 17 | 17 | |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali/public-api/object/property-map.h> |
| 20 | +#include <dali-toolkit/devel-api/align-enums.h> | |
| 20 | 21 | #include <dali-toolkit/devel-api/controls/buttons/button-devel.h> |
| 22 | +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> | |
| 21 | 23 | #include <dali-toolkit/public-api/controls/slider/slider.h> |
| 22 | 24 | |
| 23 | 25 | using namespace Dali; |
| ... | ... | @@ -355,6 +357,9 @@ public: |
| 355 | 357 | mVisualMap.Clear(); |
| 356 | 358 | mVisualMap[ Visual::Property::TYPE ] = Visual::PRIMITIVE; |
| 357 | 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 | 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 | 17 | #include "beat-control-impl.h" |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali/public-api/object/type-registry-helper.h> |
| 20 | -#include <dali-toolkit/devel-api/align-enums.h> | |
| 21 | 20 | #include <dali-toolkit/devel-api/controls/control-devel.h> |
| 22 | 21 | #include <dali-toolkit/devel-api/visual-factory/visual-factory.h> |
| 23 | 22 | #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> |
| 24 | 23 | |
| 25 | -#include <cstdio> | |
| 26 | - | |
| 27 | 24 | using namespace Dali; // Needed for macros |
| 28 | 25 | using namespace Dali::Toolkit; |
| 29 | 26 | |
| ... | ... | @@ -60,13 +57,18 @@ Toolkit::TransitionData ConvertPropertyToTransition( const Property::Value& valu |
| 60 | 57 | { |
| 61 | 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 | 73 | return transitionData; |
| 72 | 74 | } |
| ... | ... | @@ -77,6 +79,8 @@ Toolkit::TransitionData ConvertPropertyToTransition( const Property::Value& valu |
| 77 | 79 | Internal::BeatControl::BeatControl() |
| 78 | 80 | : Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ), |
| 79 | 81 | mTransformSize(1.0f, 1.0f), |
| 82 | + mTransformOrigin(Align::CENTER), | |
| 83 | + mTransformAnchorPoint(Align::CENTER), | |
| 80 | 84 | mAnimationPlaying(0) |
| 81 | 85 | { |
| 82 | 86 | } |
| ... | ... | @@ -209,6 +213,8 @@ void BeatControl::RelayoutVisuals( const Vector2& targetSize ) |
| 209 | 213 | // Make the visual half the size of the control, but leave |
| 210 | 214 | // origin and anchor point at center, position is relative, but Zer0 |
| 211 | 215 | transformMap[ DevelVisual::Transform::Property::SIZE ] = mTransformSize; |
| 216 | + transformMap[ DevelVisual::Transform::Property::ORIGIN ] = mTransformOrigin; | |
| 217 | + transformMap[ DevelVisual::Transform::Property::ANCHOR_POINT ] = mTransformAnchorPoint; | |
| 212 | 218 | mVisual.SetTransformAndSize( transformMap, size ); |
| 213 | 219 | } |
| 214 | 220 | } |
| ... | ... | @@ -249,7 +255,7 @@ void BeatControl::SetProperty( BaseObject* object, Property::Index index, const |
| 249 | 255 | { |
| 250 | 256 | case Demo::BeatControl::Property::BEAT_VISUAL: |
| 251 | 257 | { |
| 252 | - bool sizeOnly = false; | |
| 258 | + bool sizeAndPositionOnly = false; | |
| 253 | 259 | |
| 254 | 260 | // Determine if a transform.size property exists in the map, and |
| 255 | 261 | // save it. |
| ... | ... | @@ -262,18 +268,47 @@ void BeatControl::SetProperty( BaseObject* object, Property::Index index, const |
| 262 | 268 | Property::Map* transformMap = value->GetMap(); |
| 263 | 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 | 275 | Property::Value* sizeValue = transformMap->Find( DevelVisual::Transform::Property::SIZE, "size" ); |
| 266 | 276 | if( sizeValue ) |
| 267 | 277 | { |
| 268 | 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 | 313 | // Only register a visual if there is more than just a size setting |
| 279 | 314 | impl.mVisual = Toolkit::VisualFactory::Get().CreateVisual( *map ); | ... | ... |
examples/visual-transitions/beat-control-impl.h
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 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 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | 8 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -20,6 +20,7 @@ |
| 20 | 20 | #include "beat-control.h" |
| 21 | 21 | #include <dali/public-api/animation/animation.h> |
| 22 | 22 | #include <dali-toolkit/public-api/controls/control-impl.h> |
| 23 | +#include <dali-toolkit/devel-api/align-enums.h> | |
| 23 | 24 | #include <dali-toolkit/devel-api/visual-factory/visual-base.h> |
| 24 | 25 | #include <dali-toolkit/devel-api/visual-factory/transition-data.h> |
| 25 | 26 | |
| ... | ... | @@ -128,6 +129,8 @@ private: |
| 128 | 129 | Dali::Animation mYAnimation; |
| 129 | 130 | Dali::Animation mFadeAnimation; |
| 130 | 131 | Dali::Vector2 mTransformSize; |
| 132 | + Dali::Toolkit::Align::Type mTransformOrigin; | |
| 133 | + Dali::Toolkit::Align::Type mTransformAnchorPoint; | |
| 131 | 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 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -124,7 +124,7 @@ void TransitionApplication::Create( Application& application ) |
| 124 | 124 | Property::Map map; |
| 125 | 125 | CreateVisualMap( i, map ); |
| 126 | 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 | 128 | mVisualButtons[i] = BeatControl::New(); |
| 129 | 129 | mVisualButtons[i].SetProperty( BeatControl::Property::BEAT_VISUAL, map ); |
| 130 | 130 | mVisualButtons[i].SetName("VisualButton"); | ... | ... |