Changes after Visual Depth Index API changed from float to int
[platform/core/uifw/dali-demo.git] / examples / transitions / shadow-button-impl.cpp
index aa82ce1..135ea16 100644 (file)
@@ -21,6 +21,7 @@
 #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>
 
@@ -45,7 +46,8 @@ DALI_TYPE_REGISTRATION_BEGIN( ShadowButton, Dali::Toolkit::Button, Create );
 
 DALI_PROPERTY_REGISTRATION( Demo, ShadowButton, "activeTransition", ARRAY, ACTIVE_TRANSITION );
 DALI_PROPERTY_REGISTRATION( Demo, ShadowButton, "inactiveTransition", ARRAY, INACTIVE_TRANSITION );
-DALI_PROPERTY_REGISTRATION( Demo, ShadowButton, "clickTransition", ARRAY, CLICK_TRANSITION );
+DALI_PROPERTY_REGISTRATION( Demo, ShadowButton, "checkTransition", ARRAY, CHECK_TRANSITION );
+DALI_PROPERTY_REGISTRATION( Demo, ShadowButton, "uncheckTransition", ARRAY, UNCHECK_TRANSITION );
 DALI_PROPERTY_REGISTRATION( Demo, ShadowButton, "backgroundVisual", MAP, BACKGROUND_VISUAL );
 DALI_PROPERTY_REGISTRATION( Demo, ShadowButton, "checkboxBgVisual", MAP, CHECKBOX_BG_VISUAL );
 DALI_PROPERTY_REGISTRATION( Demo, ShadowButton, "checkboxFgVisual", MAP, CHECKBOX_FG_VISUAL );
@@ -123,7 +125,18 @@ bool ShadowButton::GetActiveState()
 void ShadowButton::SetCheckState( bool checkState )
 {
   mCheckState = checkState;
-  EnableVisual( Demo::ShadowButton::Property::CHECKBOX_FG_VISUAL, mCheckState );
+  DevelControl::EnableVisual( *this, Demo::ShadowButton::Property::CHECKBOX_FG_VISUAL, true );
+  if( Self().OnStage() )
+  {
+    if( checkState )
+    {
+      StartTransition( Demo::ShadowButton::Property::CHECK_TRANSITION );
+    }
+    else
+    {
+      StartTransition( Demo::ShadowButton::Property::UNCHECK_TRANSITION );
+    }
+  }
   RelayoutRequest();
 }
 
@@ -145,7 +158,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 );
@@ -175,6 +188,11 @@ void ShadowButton::OnTransitionFinished( Animation& src )
           // Consider relayouting the text.
           break;
         }
+        case Demo::ShadowButton::Property::UNCHECK_TRANSITION:
+        {
+          DevelControl::EnableVisual( *this, Demo::ShadowButton::Property::CHECKBOX_FG_VISUAL, false );
+          break;
+        }
       }
       break;
     }
@@ -328,7 +346,6 @@ void ShadowButton::ResetVisual(
   if( map )
   {
     visual = Toolkit::VisualFactory::Get().CreateVisual( *map );
-    RegisterVisual( index, visual );
 
     // Set the appropriate depth index.
     // @todo Should be able to set this from the style sheet
@@ -336,22 +353,22 @@ void ShadowButton::ResetVisual(
     {
       case Demo::ShadowButton::Property::BACKGROUND_VISUAL:
       {
-        visual.SetDepthIndex(0.0f);
+        DevelControl::RegisterVisual( *this, index, visual, 0 );
         break;
       }
       case Demo::ShadowButton::Property::CHECKBOX_BG_VISUAL:
       {
-        visual.SetDepthIndex(1.0f);
+        DevelControl::RegisterVisual( *this, index, visual, 1 );
         break;
       }
       case Demo::ShadowButton::Property::CHECKBOX_FG_VISUAL:
       {
-        visual.SetDepthIndex(2.0f);
+        DevelControl::RegisterVisual( *this, index, visual, mCheckState, 2 );
         break;
       }
       case Demo::ShadowButton::Property::LABEL_VISUAL:
       {
-        visual.SetDepthIndex(1.0f);
+        DevelControl::RegisterVisual( *this, index, visual, 1 );
         break;
       }
     }
@@ -379,7 +396,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;
@@ -398,7 +415,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"}
 
 
@@ -476,7 +493,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:
@@ -486,7 +503,8 @@ void ShadowButton::SetProperty( BaseObject* object, Property::Index index, const
       }
       case Demo::ShadowButton::Property::ACTIVE_TRANSITION:
       case Demo::ShadowButton::Property::INACTIVE_TRANSITION:
-      case Demo::ShadowButton::Property::CLICK_TRANSITION:
+      case Demo::ShadowButton::Property::CHECK_TRANSITION:
+      case Demo::ShadowButton::Property::UNCHECK_TRANSITION:
       {
         impl.ResetTransition( index, value );
         break;