Remove more public Setter/Getter APIs from Dali::Actor
[platform/core/uifw/dali-demo.git] / examples / image-policies / image-policies-example.cpp
index a630742..2f8c93a 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.
@@ -23,7 +23,6 @@
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
-#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
 
 using namespace Dali;
 using namespace Toolkit;
@@ -100,23 +99,23 @@ class ImagePolicies: public ConnectionTracker
    * param[in] imageFilenameId Which image to load, referring to the array of filenames for this example.
    * return An ImageView with the required set up
    */
-  ImageView CreateImageView( bool correctionEnabled, DevelImageVisual::LoadPolicy::Type loadPolicy, DevelImageVisual::ReleasePolicy::Type releasePolicy, bool synchronousLoading, unsigned int imageFilenameId )
+  ImageView CreateImageView( bool correctionEnabled, ImageVisual::LoadPolicy::Type loadPolicy, ImageVisual::ReleasePolicy::Type releasePolicy, bool synchronousLoading, unsigned int imageFilenameId )
   {
     ImageView imageView = ImageView::New( );
     Property::Map imagePropertyMap;
     imagePropertyMap.Insert( Visual::Property::TYPE,  Visual::IMAGE );
     imagePropertyMap.Insert( ImageVisual::Property::URL,  IMAGE_PATH[imageFilenameId ]  );
-    imagePropertyMap.Insert( DevelImageVisual::Property::ORIENTATION_CORRECTION, correctionEnabled  );
-    imagePropertyMap.Insert( DevelImageVisual::Property::LOAD_POLICY,  loadPolicy  );
-    imagePropertyMap.Insert( DevelImageVisual::Property::RELEASE_POLICY,  releasePolicy  );
+    imagePropertyMap.Insert( ImageVisual::Property::ORIENTATION_CORRECTION, correctionEnabled  );
+    imagePropertyMap.Insert( ImageVisual::Property::LOAD_POLICY,  loadPolicy  );
+    imagePropertyMap.Insert( ImageVisual::Property::RELEASE_POLICY,  releasePolicy  );
     if( synchronousLoading )
     {
       imagePropertyMap.Insert( DevelImageVisual::Property::SYNCHRONOUS_LOADING,  true  );
     }
     imageView.SetProperty(ImageView::Property::IMAGE , imagePropertyMap );
 
-    imageView.SetParentOrigin( ParentOrigin::CENTER );
-    imageView.SetAnchorPoint( AnchorPoint::CENTER );
+    imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
     imageView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
 
     return imageView;
@@ -144,7 +143,7 @@ class ImagePolicies: public ConnectionTracker
     mInstructions.SetProperty( TextLabel::Property::TEXT, "Orientation Correction not applied");
     mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
     DisableButtonWhilstLoading();
-    ImageView imageView01 = CreateImageView( false, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    ImageView imageView01 = CreateImageView( false, ImageVisual::LoadPolicy::ATTACHED, ImageVisual::ReleasePolicy::DESTROYED, false, 3 );
     imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
 
     mTable.AddChild( imageView01, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
@@ -158,7 +157,7 @@ class ImagePolicies: public ConnectionTracker
     mInstructions.SetProperty( TextLabel::Property::TEXT, "Orientation Correction applied based on Exif data, now shown in landscape");
     mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
     DisableButtonWhilstLoading();
-    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    ImageView imageView01 = CreateImageView( true, ImageVisual::LoadPolicy::ATTACHED, ImageVisual::ReleasePolicy::DESTROYED, false, 3 );
     imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
     mTable.AddChild( imageView01, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
   }
@@ -173,9 +172,9 @@ class ImagePolicies: public ConnectionTracker
     mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
     mInstructions.SetProperty( TextLabel::Property::TEXT, "Loading Image before staging, press next to see it in right column");
     TableView dualImageViewTable = TableView::New( 1, 2 );
-    dualImageViewTable.SetAnchorPoint( AnchorPoint::CENTER );
-    dualImageViewTable.SetName("dualTable");
-    dualImageViewTable.SetParentOrigin( ParentOrigin::CENTER );
+    dualImageViewTable.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    dualImageViewTable.SetProperty( Dali::Actor::Property::NAME,"dualTable");
+    dualImageViewTable.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     dualImageViewTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
     dualImageViewTable.SetCellPadding( Vector2( 6.0f, 0.0f ) );
     TextLabel attached = TextLabel::New("ATTACHED loaded image \nWill appear here");
@@ -188,7 +187,7 @@ class ImagePolicies: public ConnectionTracker
     mTable.AddChild( dualImageViewTable, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
 
     DisableButtonWhilstLoading();
-    mPersistantImageView = CreateImageView( true, DevelImageVisual::LoadPolicy::IMMEDIATE, DevelImageVisual::ReleasePolicy::DESTROYED, false, 4 );
+    mPersistantImageView = CreateImageView( true, ImageVisual::LoadPolicy::IMMEDIATE, ImageVisual::ReleasePolicy::DESTROYED, false, 4 );
     mPersistantImageView.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
   }
 
@@ -202,9 +201,9 @@ class ImagePolicies: public ConnectionTracker
     mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
 
     TableView dualImageViewTable = TableView::New( 2, 2 );
-    dualImageViewTable.SetAnchorPoint( AnchorPoint::CENTER );
-    dualImageViewTable.SetName("dualTable");
-    dualImageViewTable.SetParentOrigin( ParentOrigin::CENTER );
+    dualImageViewTable.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    dualImageViewTable.SetProperty( Dali::Actor::Property::NAME,"dualTable");
+    dualImageViewTable.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     dualImageViewTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
     dualImageViewTable.SetCellPadding( Vector2( 6.0f, 0.0f ) );
 
@@ -216,7 +215,7 @@ class ImagePolicies: public ConnectionTracker
 
     mTable.AddChild( dualImageViewTable, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
 
-    ImageView imageView02 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    ImageView imageView02 = CreateImageView( true, ImageVisual::LoadPolicy::ATTACHED, ImageVisual::ReleasePolicy::DESTROYED, false, 3 );
     imageView02.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
     dualImageViewTable.AddChild( imageView02, TableView::CellPosition( 0, 0 ) );
     dualImageViewTable.AddChild( mPersistantImageView, TableView::CellPosition( 0, 1 ) );
@@ -233,14 +232,14 @@ class ImagePolicies: public ConnectionTracker
     mInstructions.SetProperty( TextLabel::Property::TEXT, "ReleasePolicy::DESTROYED shown in first column, press next to destroy it.");
     DisableButtonWhilstLoading();
     TableView dualImageViewTable = TableView::New( 1, 2 );
-    dualImageViewTable.SetAnchorPoint( AnchorPoint::CENTER );
-    dualImageViewTable.SetParentOrigin( ParentOrigin::CENTER );
+    dualImageViewTable.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    dualImageViewTable.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     dualImageViewTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
     dualImageViewTable.SetCellPadding( Vector2( 6.0f, 0.0f ) );
 
     mTable.AddChild( dualImageViewTable, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
 
-    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    ImageView imageView01 = CreateImageView( true, ImageVisual::LoadPolicy::ATTACHED, ImageVisual::ReleasePolicy::DESTROYED, false, 3 );
     imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
 
     dualImageViewTable.AddChild( imageView01, TableView::CellPosition( 0, 0 ) );
@@ -256,14 +255,14 @@ class ImagePolicies: public ConnectionTracker
     mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
     DisableButtonWhilstLoading();
     TableView dualImageViewTable = TableView::New( 1, 2 );
-    dualImageViewTable.SetAnchorPoint( AnchorPoint::CENTER );
-    dualImageViewTable.SetParentOrigin( ParentOrigin::CENTER );
+    dualImageViewTable.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    dualImageViewTable.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     dualImageViewTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
     dualImageViewTable.SetCellPadding( Vector2( 6.0f, 0.0f ) );
 
     mTable.AddChild( dualImageViewTable, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
 
-    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    ImageView imageView01 = CreateImageView( true, ImageVisual::LoadPolicy::ATTACHED, ImageVisual::ReleasePolicy::DESTROYED, false, 3 );
     imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
 
     dualImageViewTable.AddChild( imageView01, TableView::CellPosition( 0, 1 ) );
@@ -279,14 +278,14 @@ class ImagePolicies: public ConnectionTracker
     mInstructions.SetProperty( TextLabel::Property::TEXT, "Image with ReleasePolicy::DESTROYED shown in first column, Image will be detached, reusing it will be fast");
     DisableButtonWhilstLoading();
     TableView dualImageViewTable = TableView::New( 1, 2 );
-    dualImageViewTable.SetAnchorPoint( AnchorPoint::CENTER );
-    dualImageViewTable.SetParentOrigin( ParentOrigin::CENTER );
+    dualImageViewTable.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    dualImageViewTable.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     dualImageViewTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
     dualImageViewTable.SetCellPadding( Vector2( 6.0f, 0.0f ) );
 
     mTable.AddChild( dualImageViewTable, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
 
-    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    ImageView imageView01 = CreateImageView( true, ImageVisual::LoadPolicy::ATTACHED, ImageVisual::ReleasePolicy::DESTROYED, false, 3 );
     imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
 
     dualImageViewTable.AddChild( imageView01, TableView::CellPosition( 0, 0 ) );
@@ -303,7 +302,7 @@ class ImagePolicies: public ConnectionTracker
     ImageView imageViewDetached = ImageView::DownCast( dualImageViewTable.GetChildAt( TableView::CellPosition( 0, 0 ) ) );
     dualImageViewTable.RemoveChildAt( TableView::CellPosition( 0, 0 ) );
 
-    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    ImageView imageView01 = CreateImageView( true, ImageVisual::LoadPolicy::ATTACHED, ImageVisual::ReleasePolicy::DESTROYED, false, 3 );
     imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
 
     dualImageViewTable.AddChild( imageView01, TableView::CellPosition( 0, 1 ) );
@@ -319,14 +318,14 @@ class ImagePolicies: public ConnectionTracker
     mInstructions.SetProperty( TextLabel::Property::TEXT, "Image with ReleasePolicy::DETACHED shown in first column, will be detached and reloaded");
     DisableButtonWhilstLoading();
     TableView dualImageViewTable = TableView::New( 1, 2 );
-    dualImageViewTable.SetAnchorPoint( AnchorPoint::CENTER );
-    dualImageViewTable.SetParentOrigin( ParentOrigin::CENTER );
+    dualImageViewTable.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    dualImageViewTable.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     dualImageViewTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
     dualImageViewTable.SetCellPadding( Vector2( 6.0f, 0.0f ) );
 
     mTable.AddChild( dualImageViewTable, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
 
-    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DETACHED, false, 3 );
+    ImageView imageView01 = CreateImageView( true, ImageVisual::LoadPolicy::ATTACHED, ImageVisual::ReleasePolicy::DETACHED, false, 3 );
     imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
 
     dualImageViewTable.AddChild( imageView01, TableView::CellPosition( 0, 0 ) );
@@ -344,7 +343,7 @@ class ImagePolicies: public ConnectionTracker
     ImageView imageViewDetached = ImageView::DownCast( dualImageViewTable.GetChildAt( TableView::CellPosition( 0, 0 ) ) );
     dualImageViewTable.RemoveChildAt( TableView::CellPosition( 0, 0 ) );
 
-    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    ImageView imageView01 = CreateImageView( true, ImageVisual::LoadPolicy::ATTACHED, ImageVisual::ReleasePolicy::DESTROYED, false, 3 );
     imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
 
     dualImageViewTable.AddChild( imageView01, TableView::CellPosition( 0, 1 ) );
@@ -387,19 +386,19 @@ class ImagePolicies: public ConnectionTracker
 
     // Create default View.
     Toolkit::Control view = Toolkit::Control::New();
-    view.SetAnchorPoint( Dali::AnchorPoint::CENTER );
-    view.SetParentOrigin( Dali::ParentOrigin::CENTER );
+    view.SetProperty( Actor::Property::ANCHOR_POINT, Dali::AnchorPoint::CENTER );
+    view.SetProperty( Actor::Property::PARENT_ORIGIN, Dali::ParentOrigin::CENTER );
     view.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS );
     view.SetProperty( Toolkit::Control::Property::BACKGROUND , gradientBackground );
     stage.Add( view );
 
     // Create a table view to show a pair of buttons above each image.
     mTable = TableView::New( TableRowPlacement::NUMBER_OF_ROWS, 1 );
-    mTable.SetAnchorPoint( AnchorPoint::CENTER );
-    mTable.SetParentOrigin( ParentOrigin::CENTER );
+    mTable.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    mTable.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     mTable.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
     Vector3 offset( 0.9f, 0.90f, 0.0f );
-    mTable.SetSizeModeFactor( offset );
+    mTable.SetProperty( Actor::Property::SIZE_MODE_FACTOR, offset );
     mTable.SetFitHeight( TableRowPlacement::NEXT_BUTTON );
     mTable.SetFitHeight( TableRowPlacement::LOADING_STATUS );
     view.Add( mTable );
@@ -409,14 +408,14 @@ class ImagePolicies: public ConnectionTracker
     Property::Map imagePropertyMap;
     imagePropertyMap.Insert( Visual::Property::TYPE,  Visual::IMAGE );
     imagePropertyMap.Insert( ImageVisual::Property::URL, NEXT_BUTTON_IMAGE );
-    mNextButton.SetProperty( DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, imagePropertyMap );
+    mNextButton.SetProperty( Button::Property::UNSELECTED_BACKGROUND_VISUAL, imagePropertyMap );
     imagePropertyMap.Clear();
     imagePropertyMap.Insert( Visual::Property::TYPE,  Visual::IMAGE );
     imagePropertyMap.Insert( ImageVisual::Property::URL, NEXT_BUTTON_PRESSED_IMAGE );
-    mNextButton.SetProperty( DevelButton::Property::SELECTED_BACKGROUND_VISUAL, imagePropertyMap );
-    mNextButton.SetProperty( DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL, LOADING_IMAGE );
-    mNextButton.SetProperty( DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL, NEXT_BUTTON_DISABLED_IMAGE );
-    mNextButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
+    mNextButton.SetProperty( Button::Property::SELECTED_BACKGROUND_VISUAL, imagePropertyMap );
+    mNextButton.SetProperty( Button::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL, LOADING_IMAGE );
+    mNextButton.SetProperty( Button::Property::DISABLED_SELECTED_BACKGROUND_VISUAL, NEXT_BUTTON_DISABLED_IMAGE );
+    mNextButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER );
     mNextButton.SetY( -50.0f );
     mNextButton.SetSize( 100.0f, 100.0f );
     mNextButton.ClickedSignal().Connect( this, &ImagePolicies::ChangeImageClicked );
@@ -507,8 +506,8 @@ private:
       {
         ReleasePolicyDestroyedExample06();
         // Change Next button to complete button ( will quit app once pressed )
-        button.SetProperty( DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, OK_IMAGE_IMAGE );
-        button.SetProperty( DevelButton::Property::SELECTED_BACKGROUND_VISUAL, OK_IMAGE_IMAGE );
+        button.SetProperty( Button::Property::UNSELECTED_BACKGROUND_VISUAL, OK_IMAGE_IMAGE );
+        button.SetProperty( Button::Property::SELECTED_BACKGROUND_VISUAL, OK_IMAGE_IMAGE );
         break;
       }
       default: