Changes after TouchedSignal changes
[platform/core/uifw/dali-demo.git] / examples / rendering-basic-light / rendering-basic-light-example.cpp
index a5fdcb3..b82d38d 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.
@@ -157,26 +157,26 @@ public:
   // The Init signal is received once (only) during the Application lifetime
   void Create( Application& application )
   {
-    // Get a handle to the stage
-    Stage stage = Stage::GetCurrent();
-    stage.SetBackgroundColor( Color::BLACK );
+    // Get a handle to the window
+    Window window = application.GetWindow();
+    window.SetBackgroundColor( Color::BLACK );
     mLabel = TextLabel::New( material[MaterialID].name );
-    mLabel.SetAnchorPoint( AnchorPoint::TOP_CENTER );
-    mLabel.SetParentOrigin( Vector3( 0.5f, 0.0f, 0.5f ) );
-    mLabel.SetSize( stage.GetSize().x * 0.5f, stage.GetSize().y * 0.083f );
+    mLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER );
+    mLabel.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5f, 0.0f, 0.5f ) );
+    mLabel.SetProperty( Actor::Property::SIZE, Vector2( window.GetSize().GetWidth() * 0.5f, window.GetSize().GetHeight() * 0.083f ) );
     mLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
     mLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
     mLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ));
-    stage.Add( mLabel );
+    window.Add( mLabel );
     mButton = PushButton::New();
     mButton.SetProperty( Button::Property::LABEL, "Exit" );
-    mButton.SetParentOrigin( ParentOrigin::CENTER );
-    mButton.SetAnchorPoint( AnchorPoint::CENTER );
+    mButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    mButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
     mButton.ClickedSignal().Connect( this, &BasicLightController::OnExit );
-    mButton.SetParentOrigin( Vector3( 0.5f, 0.1f, 0.5f ) );
+    mButton.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5f, 0.1f, 0.5f ) );
     mButton.SetStyleName(CUSTOM_BASIC_LIGHT_THEME);
-    mButton.SetColor( Vector4( material[MaterialID].diffuse) + Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
-    stage.Add(mButton);
+    mButton.SetProperty( Actor::Property::COLOR, Vector4( material[MaterialID].diffuse) + Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
+    window.Add(mButton);
 
     // Step 1. Create shader
     CreateCubeShader();
@@ -193,17 +193,17 @@ public:
     // Step 5. Play animation to rotate the cube
     PlayAnimation();
 
-    // Respond to a click anywhere on the stage
-    stage.GetRootLayer().TouchSignal().Connect( this, &BasicLightController::OnTouch );
+    // Respond to a click anywhere on the window
+    window.GetRootLayer().TouchedSignal().Connect( this, &BasicLightController::OnTouch );
 
     // Respond to key events
-    stage.KeyEventSignal().Connect( this, &BasicLightController::OnKeyEvent );
+    window.KeyEventSignal().Connect( this, &BasicLightController::OnKeyEvent );
   }
 
   /**
    * This function will change the material of the cube when touched
    */
-  bool OnTouch( Actor actor, const TouchData& touch )
+  bool OnTouch( Actor actor, const TouchEvent& touch )
   {
     if(touch.GetState(0) == PointState::UP)
     {
@@ -215,7 +215,7 @@ public:
         mShader.SetProperty( mShader.GetPropertyIndex( "material.specular" ), material[MaterialID].specular );
         mShader.SetProperty( mShader.GetPropertyIndex( "material.shininess" ), material[MaterialID].shininess * 128.0f );
         mLabel.SetProperty( TextLabel::Property::TEXT, material[MaterialID].name );
-        mButton.SetColor( Vector4(material[MaterialID].diffuse) + Vector4(0.0f, 0.0f, 0.0f, 1.0f) );
+        mButton.SetProperty( Actor::Property::COLOR, Vector4(material[MaterialID].diffuse) + Vector4(0.0f, 0.0f, 0.0f, 1.0f) );
     }
     return true;
   }
@@ -237,7 +237,7 @@ public:
    */
   void OnKeyEvent( const KeyEvent& event )
   {
-    if( event.state == KeyEvent::Down )
+    if( event.GetState() == KeyEvent::DOWN )
     {
       if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
       {
@@ -308,7 +308,7 @@ public:
     property.Insert( "aPosition", Property::VECTOR3 );
     property.Insert( "aNormal", Property::VECTOR3 );
 
-    PropertyBuffer vertexBuffer = PropertyBuffer::New( property );
+    VertexBuffer vertexBuffer = VertexBuffer::New( property );
 
     vertexBuffer.SetData( vertices, sizeof(vertices) / sizeof(Vertex) );
 
@@ -373,16 +373,16 @@ public:
    */
   void CreateActor()
   {
-    Stage stage = Stage::GetCurrent();
+    Window window = mApplication.GetWindow();
 
-    float quarterStageWidth = stage.GetSize().x * 0.25f;
+    float quarterWindowWidth = window.GetSize().GetWidth() * 0.25f;
     mActor = Actor::New();
-    mActor.SetColor( Vector4( 1.0f, 1.0f, 0.6f, 1.0f ) );
-    mActor.SetAnchorPoint( AnchorPoint::CENTER );
-    mActor.SetParentOrigin( ParentOrigin::CENTER );
-    mActor.SetSize( Vector3( quarterStageWidth, quarterStageWidth, quarterStageWidth ) );
+    mActor.SetProperty( Actor::Property::COLOR, Vector4( 1.0f, 1.0f, 0.6f, 1.0f ) );
+    mActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    mActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    mActor.SetProperty( Actor::Property::SIZE, Vector3( quarterWindowWidth, quarterWindowWidth, quarterWindowWidth ) );
     mActor.AddRenderer( mRenderer );
-    stage.Add( mActor );
+    window.Add( mActor );
   }
 
   /**