Use Window instead of Stage
[platform/core/uifw/dali-demo.git] / examples / text-fonts / text-fonts-example.cpp
index be78963..7559df8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 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.
@@ -68,7 +68,7 @@ public:
   void CreateTextLabel( TextLabel& textLabel, std::string textString, const Vector4& color, bool infoLabel=false )
   {
     textLabel = TextLabel::New( textString );
-    textLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+    textLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
     textLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
     textLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
     textLabel.SetProperty( TextLabel::Property::MULTI_LINE, true );
@@ -80,8 +80,10 @@ public:
     }
     else
     {
-      textLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 0.3f, 0.3f ) );
-      textLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK );
+      Property::Map shadowMap;
+      shadowMap.Insert( "color", Color::BLACK );
+      shadowMap.Insert( "offset", Vector2( 0.3f, 0.3f ) );
+      textLabel.SetProperty( TextLabel::Property::SHADOW, shadowMap );
       textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
     }
     textLabel.SetBackgroundColor( color );
@@ -90,17 +92,17 @@ public:
   void CreateContainer( Control& container, const Vector2 size )
   {
     container = Control::New();
-    container.SetSize( size );
-    container.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    container.SetDrawMode( DrawMode::OVERLAY_2D );
+    container.SetProperty( Actor::Property::SIZE, size );
+    container.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+    container.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
   }
 
   void CreateFolderButton( PushButton& button )
   {
     button = PushButton::New();
-    button.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+    button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER );
     button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
-    button.SetSize( 50.0f, 50.0f );
+    button.SetProperty( Actor::Property::SIZE, Vector2( 50.0f, 50.0f ) );
   }
 
   bool OnButtonClicked( Toolkit::Button button )
@@ -113,13 +115,13 @@ public:
     if ( !mContainer4 )
     {
       CreateContainer ( mContainer4 , mLayoutSize);
-      Stage stage = Stage::GetCurrent();
-      Vector2 stageSize = stage.GetSize();
-      mContainer4.SetPosition( 0, stageSize.height*0.25f*3 );
-      stage.Add( mContainer4 );
+      Window window = mApplication.GetWindow();
+      Vector2 windowSize = window.GetSize();
+      mContainer4.SetProperty( Actor::Property::POSITION, Vector2( 0, windowSize.height*0.25f*3 ));
+      window.Add( mContainer4 );
       // Info
       CreateContainer ( mContainer4Info , mLayoutSize );
-      mContainer4Info.SetParentOrigin( ParentOrigin::TOP_RIGHT );
+      mContainer4Info.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
       mContainer4.Add( mContainer4Info );
       CreateTextLabel ( mLabel4Info, "system free", Color::BLACK, true  );
       mContainer4Info.Add ( mLabel4Info );
@@ -146,17 +148,17 @@ public:
    */
   void Create( Application& application )
   {
-    Stage stage = Stage::GetCurrent();
-    Vector2 stageSize = stage.GetSize();
+    Window window = application.GetWindow();
+    Vector2 windowSize = window.GetSize();
 
-    stage.KeyEventSignal().Connect(this, &TextFontsExample::OnKeyEvent);
+    window.KeyEventSignal().Connect(this, &TextFontsExample::OnKeyEvent);
 
     CreateFolderButton ( mButton );
-    mButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
+    mButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER );
     mButton.ClickedSignal().Connect( this, &TextFontsExample::OnButtonClicked );
-    stage.Add( mButton );
+    window.Add( mButton );
 
-    mLayoutSize = Vector2( stageSize.width*0.5f, stageSize.height*0.10f );
+    mLayoutSize = Vector2( windowSize.width*0.5f, windowSize.height*0.10f );
     CreateContainer ( mContainer , mLayoutSize);
     CreateContainer ( mContainer2 , mLayoutSize );
     CreateContainer ( mContainer3 , mLayoutSize );
@@ -165,9 +167,9 @@ public:
     CreateContainer ( mContainerInfo , mLayoutSize );
     CreateContainer ( mContainer2Info , mLayoutSize );
     CreateContainer ( mContainer3Info , mLayoutSize );
-    mContainerInfo.SetParentOrigin( ParentOrigin::TOP_RIGHT );
-    mContainer2Info.SetParentOrigin( ParentOrigin::TOP_RIGHT );
-    mContainer3Info.SetParentOrigin( ParentOrigin::TOP_RIGHT );
+    mContainerInfo.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
+    mContainer2Info.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
+    mContainer3Info.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
     mContainer.Add( mContainerInfo );
     mContainer2.Add( mContainer2Info );
     mContainer3.Add( mContainer3Info );
@@ -178,9 +180,9 @@ public:
     mContainer2Info.Add( mLabel2Info );
     mContainer3Info.Add( mLabel3Info );
 
-    stage.Add( mContainer );
-    stage.Add( mContainer2 );
-    stage.Add( mContainer3 );
+    window.Add( mContainer );
+    window.Add( mContainer2 );
+    window.Add( mContainer3 );
 
     CreateTextLabel ( mLabel, LABEL_TEXT, Color::WHITE  );
 
@@ -190,9 +192,9 @@ public:
     CreateTextLabel ( mLabel3, LABEL_TEXT, Color::WHITE  );
     mLabel3.SetProperty( TextLabel::Property::FONT_FAMILY, "SamsungOneUI" );
 
-    mContainer.SetPosition( 0, 0 );
-    mContainer2.SetPosition( 0, stageSize.height*0.25f );
-    mContainer3.SetPosition( 0, stageSize.height*0.25f*2 );
+    mContainer.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+    mContainer2.SetProperty( Actor::Property::POSITION, Vector2( 0, windowSize.height*0.25f ));
+    mContainer3.SetProperty( Actor::Property::POSITION, Vector2( 0, windowSize.height*0.25f*2 ));
 
     mContainer.Add( mLabel );
     mContainer2.Add( mLabel2 );
@@ -245,19 +247,10 @@ private:
   bool mToggle;
 };
 
-void RunTest( Application& application )
-{
-  TextFontsExample 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, DEMO_THEME_PATH );
-
-  RunTest( application );
-
+  TextFontsExample test( application );
+  application.MainLoop();
   return 0;
 }