Merge "(ArcVisual) Add code to update properties" into devel/master
[platform/core/uifw/dali-demo.git] / examples / text-memory-profiling / text-memory-profiling-example.cpp
index 2fb3d2d..475b594 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 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.
@@ -97,8 +97,8 @@ public:
   TextLabel SetupTextLabel( int type )
   {
     TextLabel label = TextLabel::New();
-    label.SetAnchorPoint( ParentOrigin::TOP_LEFT );
-    label.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+    label.SetProperty( Actor::Property::ANCHOR_POINT, ParentOrigin::TOP_LEFT );
+    label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
     label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLACK );
     label.SetProperty( TextLabel::Property::POINT_SIZE, 12.0f );
     Property::Map shadowMap;
@@ -107,7 +107,7 @@ public:
     label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
 
     Vector2 stageSize = Stage::GetCurrent().GetSize();
-    label.SetPosition( Vector3( Random::Range( 0.0f, stageSize.x ), Random::Range( 0.0f, stageSize.y ), 0.0f) );
+    label.SetProperty( Actor::Property::POSITION, Vector3( Random::Range( 0.0f, stageSize.x ), Random::Range( 0.0f, stageSize.y ), 0.0f) );
 
     switch ( type )
     {
@@ -181,7 +181,7 @@ public:
 
         shadowMap.Insert( "offset", Vector2( 0.0f, 0.0f ) );
         label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
-        label.SetSize(stageSize.x, stageSize.y * 0.25f); // Set the text label in larger size
+        label.SetProperty( Actor::Property::SIZE, Vector2(stageSize.x, stageSize.y * 0.25f) ); // Set the text label in larger size
         break;
       }
       default:
@@ -205,8 +205,8 @@ public:
     // Create an item view for the main menu
     mItemView = ItemView::New( *this );
 
-    mItemView.SetParentOrigin( ParentOrigin::CENTER );
-    mItemView.SetAnchorPoint( AnchorPoint::CENTER );
+    mItemView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    mItemView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
 
     mLayout = DefaultItemLayout::New( DefaultItemLayout::LIST );
     mLayout->SetItemSize( Vector3( stageSize.width, 60.0f, 0.0f ) );
@@ -247,29 +247,6 @@ public:
   {
     Stage stage = Stage::GetCurrent();
 
-    // Render tasks may have been setup last load so remove them
-    RenderTaskList taskList = stage.GetRenderTaskList();
-    if( taskList.GetTaskCount() > 1 )
-    {
-      typedef std::vector<RenderTask> Collection;
-      typedef Collection::iterator ColIter;
-      Collection tasks;
-
-      for( unsigned int i = 1; i < taskList.GetTaskCount(); ++i )
-      {
-        tasks.push_back( taskList.GetTask(i) );
-      }
-
-      for( ColIter iter = tasks.begin(); iter != tasks.end(); ++iter )
-      {
-        taskList.RemoveTask(*iter);
-      }
-
-      RenderTask defaultTask = taskList.GetTask( 0 );
-      defaultTask.SetSourceActor( stage.GetRootLayer() );
-      defaultTask.SetTargetFrameBuffer( FrameBufferImage() );
-    }
-
     // Delete any existing text labels
     unsigned int numChildren = mLayer.GetChildCount();
 
@@ -278,11 +255,11 @@ public:
       mLayer.Remove( mLayer.GetChildAt( 0 ) );
     }
 
-    mLayer.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
-    mLayer.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+    mLayer.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER );
+    mLayer.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER );
     mLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
     mLayer.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::HEIGHT );
-    mLayer.SetSizeModeFactor( Vector3( 0.0f, -DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight, 0.0f ) );
+    mLayer.SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3( 0.0f, -DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight, 0.0f ) );
 
     mNavigationView.Push( mLayer );
 
@@ -322,8 +299,8 @@ public:
     mLayer = Layer::New();
 
     mIndicator = Toolkit::ImageView::New(INDICATOR_IMAGE);
-    mIndicator.SetParentOrigin( ParentOrigin::CENTER );
-    mIndicator.SetAnchorPoint( AnchorPoint::CENTER );
+    mIndicator.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    mIndicator.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
     mIndicator.SetProperty( Actor::Property::VISIBLE, false );
 
     // Create a back button in the left of toolbar
@@ -331,13 +308,13 @@ public:
     backButton.SetProperty( Button::Property::UNSELECTED_BACKGROUND_VISUAL, BACK_IMAGE );
     backButton.SetProperty( Button::Property::SELECTED_BACKGROUND_VISUAL, BACK_IMAGE_SELECTED );
     backButton.ClickedSignal().Connect( this, &TextMemoryProfilingExample::OnBackButtonPressed );
-    backButton.SetLeaveRequired( true );
+    backButton.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
     mToolBar.AddControl( backButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
 
     // Create a navigation view to navigate different types of text labels
     mNavigationView = NavigationView::New();
     mNavigationView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
-    mNavigationView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+    mNavigationView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
     mNavigationView.SetBackgroundColor( Color::WHITE );
     stage.Add( mNavigationView );
 
@@ -412,7 +389,7 @@ public:
    */
   void ReturnToPreviousScreen()
   {
-    if ( mItemView.OnStage() )
+    if ( mItemView.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) )
     {
       // Quit the application if it is in the main menu
       mApplication.Quit();