Remove use of deprecated Control flag REQUIRES_STYLE_CHANGE_SIGNALS
[platform/core/uifw/dali-demo.git] / examples / transitions / shadow-button-impl.cpp
index 8a6ea56..51867d6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 
 #include "shadow-button-impl.h"
 #include <dali-toolkit/dali-toolkit.h>
-#include <dali/public-api/object/type-registry-helper.h>
 #include <dali/devel-api/scripting/enum-helper.h>
-#include <dali-toolkit/devel-api/align-enums.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
-#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
 
 #include <cstdio>
 
@@ -82,7 +80,7 @@ Toolkit::TransitionData ConvertPropertyToTransition( const Property::Value& valu
 
 
 Internal::ShadowButton::ShadowButton()
-: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
   mCheckState(false),
   mActiveState(false)
 {
@@ -124,8 +122,8 @@ bool ShadowButton::GetActiveState()
 void ShadowButton::SetCheckState( bool checkState )
 {
   mCheckState = checkState;
-  EnableVisual( Demo::ShadowButton::Property::CHECKBOX_FG_VISUAL, true );
-  if( Self().OnStage() )
+  DevelControl::EnableVisual( *this, Demo::ShadowButton::Property::CHECKBOX_FG_VISUAL, true );
+  if( Self().GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) )
   {
     if( checkState )
     {
@@ -157,7 +155,7 @@ void ShadowButton::StartTransition( Property::Index transitionId )
       iter->mAnimation.FinishedSignal().Disconnect( this, &ShadowButton::OnTransitionFinished );
     }
 
-    iter->mAnimation = CreateTransition( iter->mTransitionData );
+    iter->mAnimation = DevelControl::CreateTransition( *this, iter->mTransitionData );
     StoreTargetLayouts( iter->mTransitionData );
 
     iter->mAnimation.FinishedSignal().Connect( this, &ShadowButton::OnTransitionFinished );
@@ -189,7 +187,7 @@ void ShadowButton::OnTransitionFinished( Animation& src )
         }
         case Demo::ShadowButton::Property::UNCHECK_TRANSITION:
         {
-          EnableVisual( Demo::ShadowButton::Property::CHECKBOX_FG_VISUAL, false );
+          DevelControl::EnableVisual( *this, Demo::ShadowButton::Property::CHECKBOX_FG_VISUAL, false );
           break;
         }
       }
@@ -203,14 +201,14 @@ void ShadowButton::OnInitialize()
   Actor self = Self();
 }
 
-void ShadowButton::OnStageConnection( int depth )
+void ShadowButton::OnSceneConnection( int depth )
 {
-  Control::OnStageConnection( depth );
+  Control::OnSceneConnection( depth );
 }
 
-void ShadowButton::OnStageDisconnection()
+void ShadowButton::OnSceneDisconnection()
 {
-  Control::OnStageDisconnection();
+  Control::OnSceneDisconnection();
 }
 
 void ShadowButton::OnSizeSet( const Vector3& targetSize )
@@ -352,32 +350,28 @@ void ShadowButton::ResetVisual(
     {
       case Demo::ShadowButton::Property::BACKGROUND_VISUAL:
       {
-        RegisterVisual( index, visual );
-        visual.SetDepthIndex(0.0f);
+        DevelControl::RegisterVisual( *this, index, visual, 0 );
         break;
       }
       case Demo::ShadowButton::Property::CHECKBOX_BG_VISUAL:
       {
-        RegisterVisual( index, visual );
-        visual.SetDepthIndex(1.0f);
+        DevelControl::RegisterVisual( *this, index, visual, 1 );
         break;
       }
       case Demo::ShadowButton::Property::CHECKBOX_FG_VISUAL:
       {
-        RegisterVisual( index, visual, mCheckState );
-        visual.SetDepthIndex(2.0f);
+        DevelControl::RegisterVisual( *this, index, visual, mCheckState, 2 );
         break;
       }
       case Demo::ShadowButton::Property::LABEL_VISUAL:
       {
-        RegisterVisual( index, visual );
-        visual.SetDepthIndex(1.0f);
+        DevelControl::RegisterVisual( *this, index, visual, 1 );
         break;
       }
     }
 
     // Extract transform maps out of the visual definition and store them
-    Property::Value* value = map->Find( DevelVisual::Property::TRANSFORM, "transform");
+    Property::Value* value = map->Find( Visual::Property::TRANSFORM, "transform");
     if( value )
     {
       Property::Map* transformMap = value->GetMap();
@@ -399,7 +393,7 @@ void ShadowButton::ResetVisual(
 
 bool IsTransformProperty( const std::string& property )
 {
-  const char* transformProperties[]= { "size", "offset", "origin", "anchorPoint", "offsetSizeMode" };
+  const char* transformProperties[]= { "size", "offset", "origin", "anchorPoint", "offsetPolicy", "sizePolicy" };
   const int NUM_TRANSFORM_PROPERTIES = sizeof( transformProperties ) / sizeof( const char * );
 
   bool found=false;
@@ -418,7 +412,7 @@ void ShadowButton::StoreTargetLayouts( TransitionData transitionData )
 {
   // Pseudo code
   // foreach animator in transitionData
-  //   if animator{"property"} in [ "size", "offset", "origin", "anchorPoint", "offsetSizeMode" ]
+  //   if animator{"property"} in [ "size", "offset", "origin", "anchorPoint", "offsetPolicy", "sizePolicy" ]
   //     transforms{ animator{"target"} }->{animator{"property"}} = animator{"targetValue"}
 
 
@@ -429,7 +423,7 @@ void ShadowButton::StoreTargetLayouts( TransitionData transitionData )
     if( target )
     {
       // Convert to index
-      Property::Index index;
+      Property::Index index = Property::INVALID_INDEX;
       if( Scripting::GetEnumerationProperty( *target, VISUAL_PROPERTIES_TABLE, VISUAL_PROPERTIES_TABLE_COUNT, index ) )
       {
         ShadowButton::Transforms::iterator iter = FindTransform( index );
@@ -496,7 +490,7 @@ void ShadowButton::SetProperty( BaseObject* object, Property::Index index, const
       case Demo::ShadowButton::Property::CHECKBOX_FG_VISUAL:
       {
         impl.ResetVisual( index, impl.mCheckboxFgVisual, value );
-        impl.EnableVisual( Demo::ShadowButton::Property::CHECKBOX_FG_VISUAL, impl.mCheckState );
+        DevelControl::EnableVisual( impl, Demo::ShadowButton::Property::CHECKBOX_FG_VISUAL, impl.mCheckState );
         break;
       }
       case Demo::ShadowButton::Property::LABEL_VISUAL: