Remove non-touch related deprecated APIs
[platform/core/uifw/dali-demo.git] / examples / native-image-source / native-image-source-example.cpp
index 267452a..a389a27 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.
@@ -18,8 +18,6 @@
 // EXTERNAL INCLUDES
 #include <dali/dali.h>
 #include <dali/devel-api/images/native-image-interface-extension.h>
-#include <dali/public-api/rendering/renderer.h>
-#include <dali/public-api/rendering/frame-buffer.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include <cstring>
 
@@ -132,9 +130,6 @@ public:
     Stage stage = Stage::GetCurrent();
     stage.SetBackgroundColor( Color::WHITE );
 
-    // Hide the indicator bar
-    application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
-
     stage.KeyEventSignal().Connect(this, &NativeImageSourceController::OnKeyEvent);
 
     CreateButtonArea();
@@ -148,54 +143,54 @@ public:
     Vector2 stageSize = stage.GetSize();
 
     mButtonArea = Layer::New();
-    mButtonArea.SetSize( stageSize.x, BUTTON_HEIGHT );
-    mButtonArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
-    mButtonArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+    mButtonArea.SetProperty( Actor::Property::SIZE, Vector2( stageSize.x, BUTTON_HEIGHT ) );
+    mButtonArea.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER );
+    mButtonArea.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER );
     stage.Add( mButtonArea );
 
     mButtonShow = PushButton::New();
     mButtonShow.SetProperty( Button::Property::TOGGLABLE, true );
     mButtonShow.SetProperty( Toolkit::Button::Property::LABEL, "SHOW" );
-    mButtonShow.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mButtonShow.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mButtonShow.SetSize( stageSize.x / BUTTON_COUNT, BUTTON_HEIGHT );
+    mButtonShow.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+    mButtonShow.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+    mButtonShow.SetProperty( Actor::Property::SIZE, Vector2( stageSize.x / BUTTON_COUNT, BUTTON_HEIGHT ) );
     mButtonShow.ClickedSignal().Connect( this, &NativeImageSourceController::OnButtonSelected );
     mButtonArea.Add( mButtonShow );
 
     mButtonRefreshAlways = PushButton::New();
     mButtonRefreshAlways.SetProperty( Button::Property::TOGGLABLE, true );
     mButtonRefreshAlways.SetProperty( Toolkit::Button::Property::LABEL, "ALWAYS" );
-    mButtonRefreshAlways.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mButtonRefreshAlways.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mButtonRefreshAlways.SetSize( stageSize.x / BUTTON_COUNT, BUTTON_HEIGHT );
-    mButtonRefreshAlways.SetPosition( (stageSize.x / BUTTON_COUNT)*1.0f, 0.0f );
+    mButtonRefreshAlways.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+    mButtonRefreshAlways.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+    mButtonRefreshAlways.SetProperty( Actor::Property::SIZE, Vector2( stageSize.x / BUTTON_COUNT, BUTTON_HEIGHT ) );
+    mButtonRefreshAlways.SetProperty( Actor::Property::POSITION, Vector2( (stageSize.x / BUTTON_COUNT)*1.0f, 0.0f ));
     mButtonRefreshAlways.StateChangedSignal().Connect( this, &NativeImageSourceController::OnButtonSelected );
     mButtonArea.Add( mButtonRefreshAlways );
 
     mButtonRefreshOnce = PushButton::New();
     mButtonRefreshOnce.SetProperty( Toolkit::Button::Property::LABEL, "ONCE" );
-    mButtonRefreshOnce.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mButtonRefreshOnce.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mButtonRefreshOnce.SetSize( stageSize.x / BUTTON_COUNT, BUTTON_HEIGHT );
-    mButtonRefreshOnce.SetPosition( (stageSize.x / BUTTON_COUNT)*2.0f, 0.0f );
+    mButtonRefreshOnce.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+    mButtonRefreshOnce.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+    mButtonRefreshOnce.SetProperty( Actor::Property::SIZE, Vector2( stageSize.x / BUTTON_COUNT, BUTTON_HEIGHT ) );
+    mButtonRefreshOnce.SetProperty( Actor::Property::POSITION, Vector2( (stageSize.x / BUTTON_COUNT)*2.0f, 0.0f ));
     mButtonRefreshOnce.ClickedSignal().Connect( this, &NativeImageSourceController::OnButtonSelected );
     mButtonArea.Add( mButtonRefreshOnce );
 
     mButtonCapture = PushButton::New();
     mButtonCapture.SetProperty( Toolkit::Button::Property::LABEL, "CAPTURE" );
-    mButtonCapture.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mButtonCapture.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mButtonCapture.SetSize( stageSize.x / BUTTON_COUNT, BUTTON_HEIGHT );
-    mButtonCapture.SetPosition( (stageSize.x / BUTTON_COUNT)*3.0f, 0.0f );
+    mButtonCapture.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+    mButtonCapture.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+    mButtonCapture.SetProperty( Actor::Property::SIZE, Vector2( stageSize.x / BUTTON_COUNT, BUTTON_HEIGHT ) );
+    mButtonCapture.SetProperty( Actor::Property::POSITION, Vector2( (stageSize.x / BUTTON_COUNT)*3.0f, 0.0f ));
     mButtonCapture.ClickedSignal().Connect( this, &NativeImageSourceController::OnButtonSelected );
     mButtonArea.Add( mButtonCapture );
 
     mButtonReset = PushButton::New();
     mButtonReset.SetProperty( Toolkit::Button::Property::LABEL, "RESET" );
-    mButtonReset.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mButtonReset.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mButtonReset.SetSize( stageSize.x / BUTTON_COUNT, BUTTON_HEIGHT );
-    mButtonReset.SetPosition( (stageSize.x / BUTTON_COUNT)*4.0f, 0.0f );
+    mButtonReset.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+    mButtonReset.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+    mButtonReset.SetProperty( Actor::Property::SIZE, Vector2( stageSize.x / BUTTON_COUNT, BUTTON_HEIGHT ) );
+    mButtonReset.SetProperty( Actor::Property::POSITION, Vector2( (stageSize.x / BUTTON_COUNT)*4.0f, 0.0f ));
     mButtonReset.ClickedSignal().Connect( this, &NativeImageSourceController::OnButtonSelected );
     mButtonArea.Add( mButtonReset );
   }
@@ -208,21 +203,21 @@ public:
     float contentHeight( (stageSize.y - BUTTON_HEIGHT)/2.0f );
 
     mTopContentArea = Actor::New();
-    mTopContentArea.SetSize( stageSize.x, contentHeight );
-    mTopContentArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
-    mTopContentArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
-    mTopContentArea.SetY( BUTTON_HEIGHT );
+    mTopContentArea.SetProperty( Actor::Property::SIZE, Vector2( stageSize.x, contentHeight ) );
+    mTopContentArea.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER );
+    mTopContentArea.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER );
+    mTopContentArea.SetProperty( Actor::Property::POSITION_Y,  BUTTON_HEIGHT );
     stage.Add( mTopContentArea );
 
     mBottomContentArea = Actor::New();
-    mBottomContentArea.SetSize( stageSize.x, contentHeight );
-    mBottomContentArea.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
-    mBottomContentArea.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+    mBottomContentArea.SetProperty( Actor::Property::SIZE, Vector2( stageSize.x, contentHeight ) );
+    mBottomContentArea.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER );
+    mBottomContentArea.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER );
     stage.Add( mBottomContentArea );
 
     mSourceActor = ImageView::New(JPG_FILENAME);
-    mSourceActor.SetParentOrigin( ParentOrigin::CENTER);
-    mSourceActor.SetAnchorPoint( AnchorPoint::CENTER );
+    mSourceActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+    mSourceActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
     mTopContentArea.Add( mSourceActor );
 
     Animation animation = Animation::New(2.f);
@@ -236,15 +231,15 @@ public:
     animation.Play();
 
     TextLabel textLabel1 = TextLabel::New( "Image" );
-    textLabel1.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
-    textLabel1.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+    textLabel1.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER );
+    textLabel1.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER );
     mTopContentArea.Add( textLabel1 );
 
     // Wait until button press before creating mOffscreenRenderTask
 
     TextLabel textLabel2 = TextLabel::New( "Native Image" );
-    textLabel2.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
-    textLabel2.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+    textLabel2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER );
+    textLabel2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER );
     mBottomContentArea.Add( textLabel2 );
   }
 
@@ -265,8 +260,8 @@ public:
       mFrameBuffer.AttachColorTexture( mNativeTexture );
 
       mCameraActor = CameraActor::New( imageSize );
-      mCameraActor.SetParentOrigin( ParentOrigin::CENTER );
-      mCameraActor.SetParentOrigin( AnchorPoint::CENTER );
+      mCameraActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+      mCameraActor.SetProperty( Actor::Property::PARENT_ORIGIN, AnchorPoint::CENTER );
       mTopContentArea.Add( mCameraActor );
 
       RenderTaskList taskList = stage.GetRenderTaskList();
@@ -299,8 +294,8 @@ public:
         SetupNativeImage();
 
         mDisplayActor = Actor::New();
-        mDisplayActor.SetParentOrigin( ParentOrigin::CENTER );
-        mDisplayActor.SetAnchorPoint( AnchorPoint::CENTER );
+        mDisplayActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+        mDisplayActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
 
         Geometry geometry = DemoHelper::CreateTexturedQuad();
 
@@ -313,7 +308,7 @@ public:
         renderer.SetTextures( textureSet );
 
         mDisplayActor.AddRenderer( renderer );
-        mDisplayActor.SetSize( mNativeTexture.GetWidth(), mNativeTexture.GetHeight() );
+        mDisplayActor.SetProperty( Actor::Property::SIZE, Vector2( mNativeTexture.GetWidth(), mNativeTexture.GetHeight() ) );
 
         mBottomContentArea.Add( mDisplayActor );
       }
@@ -434,20 +429,10 @@ private:
   bool mRefreshAlways;
 };
 
-void RunTest( Application& application )
-{
-  NativeImageSourceController test( application );
-
-  application.MainLoop();
-}
-
-// Entry point for Linux & Tizen applications
-//
 int DALI_EXPORT_API main( int argc, char **argv )
 {
   Application application = Application::New( &argc, &argv );
-
-  RunTest( application );
-
+  NativeImageSourceController test( application );
+  application.MainLoop();
   return 0;
 }