Remove more public Setter/Getter APIs from Dali::Actor
[platform/core/uifw/dali-demo.git] / examples / shadows-and-lights / shadows-and-lights-example.cpp
index 65a8859..d69e958 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
@@ -20,7 +20,6 @@
 
 #include <dali/dali.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
 #include <dali-toolkit/devel-api/controls/shadow-view/shadow-view.h>
 
 #include <iostream>
@@ -167,8 +166,8 @@ public:
 
     // Add an effect-changing button on the right of the tool bar.
     Toolkit::PushButton effectChangeButton = Toolkit::PushButton::New();
-    effectChangeButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_EFFECT_IMAGE );
-    effectChangeButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_EFFECT_IMAGE_SELECTED );
+    effectChangeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_EFFECT_IMAGE );
+    effectChangeButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_EFFECT_IMAGE_SELECTED );
     effectChangeButton.ClickedSignal().Connect( this, &TestApp::OnEffectButtonClicked );
     toolBar.AddControl( effectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
 
@@ -181,8 +180,8 @@ public:
 
     //Add a reset button
     Toolkit::PushButton resetButton = Toolkit::PushButton::New();
-    resetButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, RESET_ICON );
-    resetButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, RESET_ICON_SELECTED );
+    resetButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, RESET_ICON );
+    resetButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, RESET_ICON_SELECTED );
     resetButton.ClickedSignal().Connect( this, &TestApp::OnResetPressed );
     toolBar.AddControl( resetButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING );
 
@@ -191,7 +190,7 @@ public:
 
     mContents.SetBehavior(Layer::LAYER_3D);
     mContents.SetPosition(mTranslation);
-    mContents.SetOrientation( CalculateWorldRotation( mSceneXRotation, mSceneYRotation ) );
+    mContents.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mSceneXRotation, mSceneYRotation ) );
     mContents.SetScale(mPinchScale, mPinchScale, mPinchScale);
 
     mPanGestureDetector = PanGestureDetector::New();
@@ -212,17 +211,17 @@ public:
   void CreateShadowViewAndLights()
   {
     mShadowView = Toolkit::ShadowView::New();
-    mShadowView.SetName("Container");
-    mShadowView.SetParentOrigin(ParentOrigin::CENTER);
-    mShadowView.SetAnchorPoint(AnchorPoint::CENTER);
+    mShadowView.SetProperty( Dali::Actor::Property::NAME,"Container");
+    mShadowView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+    mShadowView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
     mShadowView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
     mShadowView.SetPointLightFieldOfView( Math::PI / 2.0f);
     mContents.Add(mShadowView);
 
     mShadowPlaneBg = ImageView::New( DEMO_IMAGE_DIR "brick-wall.jpg" );
-    mShadowPlaneBg.SetParentOrigin(ParentOrigin::CENTER);
-    mShadowPlaneBg.SetAnchorPoint(AnchorPoint::CENTER);
-    mShadowPlaneBg.SetName("Plane");
+    mShadowPlaneBg.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+    mShadowPlaneBg.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
+    mShadowPlaneBg.SetProperty( Dali::Actor::Property::NAME,"Plane");
     mShadowPlaneBg.SetSize(1000.0f, 1000.0f);
     mContents.Add(mShadowPlaneBg);
     mShadowPlaneBg.SetPosition(Vector3(50.0f, 50.0f, -200.0f));
@@ -231,9 +230,9 @@ public:
     mShadowView.Activate();
 
     mLightAnchor = Actor::New();
-    mLightAnchor.SetParentOrigin(ParentOrigin::CENTER);
-    mLightAnchor.SetAnchorPoint(AnchorPoint::CENTER);
-    mLightAnchor.SetOrientation( CalculateWorldRotation( mLightXRotation, mLightYRotation ) );
+    mLightAnchor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+    mLightAnchor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
+    mLightAnchor.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mLightXRotation, mLightYRotation ) );
 
     // Work out a scaling factor as the initial light position was calculated for desktop
     // Need to scale light position as scene actor size is based on stage size (i.e. much bigger on device)
@@ -241,27 +240,27 @@ public:
     float scaleFactor = stageSize.x / DEFAULT_STAGE_SIZE.x;
 
     mCastingLight = Actor::New();
-    mCastingLight.SetParentOrigin(ParentOrigin::CENTER);
-    mCastingLight.SetAnchorPoint(AnchorPoint::CENTER);
+    mCastingLight.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+    mCastingLight.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
     mCastingLight.SetPosition( Vector3( 0.0f, 0.0f, 800.0f ) * scaleFactor );
 
     TextLabel text = TextLabel::New( "Light" );
     text.SetProperty( TextLabel::Property::POINT_SIZE, 20.0f );
     text.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-    text.SetColor( Color::BLUE );
+    text.SetProperty( Actor::Property::COLOR, Color::BLUE );
 
     mCastingLight.Add(text);
     mLightAnchor.Add(mCastingLight);
     mShadowPlaneBg.Add(mLightAnchor);
 
-    text.SetParentOrigin(ParentOrigin::CENTER);
+    text.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
     mShadowView.SetPointLight(mCastingLight);
   }
 
   void CreateScene()
   {
     mSceneActor = Actor::New();
-    mSceneActor.SetParentOrigin(ParentOrigin::CENTER);
+    mSceneActor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
 
     // Create and add images to the scene actor:
     mImageActor1 = ImageView::New( SCENE_IMAGE_1 );
@@ -272,13 +271,13 @@ public:
     mImageActor2.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
     mImageActor3.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
 
-    mImageActor2.SetParentOrigin(ParentOrigin::CENTER);
+    mImageActor2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
 
-    mImageActor1.SetParentOrigin(ParentOrigin::CENTER_LEFT);
-    mImageActor1.SetAnchorPoint(AnchorPoint::CENTER_RIGHT);
+    mImageActor1.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER_LEFT);
+    mImageActor1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER_RIGHT);
 
-    mImageActor3.SetParentOrigin(ParentOrigin::CENTER_RIGHT);
-    mImageActor3.SetAnchorPoint(AnchorPoint::CENTER_LEFT);
+    mImageActor3.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER_RIGHT);
+    mImageActor3.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER_LEFT);
 
     mSceneActor.Add(mImageActor2);
     mImageActor2.Add(mImageActor1);
@@ -348,7 +347,7 @@ public:
             mLightXRotation = Clamp(mLightXRotation, -Dali::ANGLE_45, Dali::ANGLE_45 );
             mLightYRotation = mLightYRotation + gesture.displacement.x * LIGHT_PAN_Y_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
             mLightYRotation = Clamp(mLightYRotation, -Dali::ANGLE_45, Dali::ANGLE_45 );
-            mLightAnchor.SetOrientation( CalculateWorldRotation( mLightXRotation, mLightYRotation ) );
+            mLightAnchor.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mLightXRotation, mLightYRotation ) );
             break;
           }
 
@@ -365,7 +364,7 @@ public:
             mSceneXRotation = Clamp( mSceneXRotation, -Dali::ANGLE_90, Dali::ANGLE_90 );
             mSceneYRotation = mSceneYRotation + gesture.displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
             mSceneYRotation = Clamp( mSceneYRotation, -Dali::ANGLE_90, Dali::ANGLE_90 );
-            mContents.SetOrientation( CalculateWorldRotation( mSceneXRotation, mSceneYRotation ) );
+            mContents.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mSceneXRotation, mSceneYRotation ) );
             break;
           }
 
@@ -373,7 +372,7 @@ public:
           {
             mObjectXRotation = mObjectXRotation - gesture.displacement.y / X_ROTATION_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
             mObjectYRotation = mObjectYRotation + gesture.displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
-            mSceneActor.SetOrientation( CalculateWorldRotation( mObjectXRotation, mObjectYRotation ) );
+            mSceneActor.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mObjectXRotation, mObjectYRotation ) );
             break;
           }
         }
@@ -393,7 +392,7 @@ public:
   {
     if (gesture.state == Gesture::Started)
     {
-      mScaleAtPinchStart = mContents.GetCurrentScale().x;
+      mScaleAtPinchStart = mContents.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).x;
     }
     mPinchScale = Clamp(mScaleAtPinchStart * gesture.scale, MIN_PINCH_SCALE, MAX_PINCH_SCALE);
 
@@ -459,7 +458,7 @@ public:
     // Align scene so that light anchor orientation is Z Axis
     mSceneXRotation = -mLightXRotation;
     mSceneYRotation = -mLightYRotation;
-    mContents.SetOrientation( CalculateWorldRotation( mSceneXRotation, mSceneYRotation ) );
+    mContents.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mSceneXRotation, mSceneYRotation ) );
 
     return true;
   }