Revert "KeyEvent class pimpling"
[platform/core/uifw/dali-demo.git] / examples / renderer-stencil / renderer-stencil-example.cpp
index a5f24c0..d159f61 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.
@@ -38,7 +38,7 @@ const char * const BACKGROUND_IMAGE( DEMO_IMAGE_DIR "background-gradient.jpg" );
 const char * const CUBE_TEXTURE( DEMO_IMAGE_DIR "people-medium-1.jpg" );
 const char * const FLOOR_TEXTURE( DEMO_IMAGE_DIR "wood.png" );
 
-// Scale dimensions: These values are relative to the stage size. EG. width = 0.32f * stageSize.
+// Scale dimensions: These values are relative to the window size. EG. width = 0.32f * windowSize.
 const float   CUBE_WIDTH_SCALE( 0.32f );                   ///< The width (and height + depth) of the main and reflection cubes.
 const Vector2 FLOOR_DIMENSION_SCALE( 0.67f, 0.017f );      ///< The width and height of the floor object.
 
@@ -113,10 +113,7 @@ private:
    */
   void Create( Application& application )
   {
-    Stage stage = Stage::GetCurrent();
-
-    // Hide the indicator bar
-    application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
+    Window window = application.GetWindow();
 
     // Use a gradient visual to render the background gradient.
     Toolkit::Control background = Dali::Toolkit::Control::New();
@@ -131,17 +128,17 @@ private:
     Property::Array stopColors;
     stopColors.PushBack( Vector4( 0.17f, 0.24f, 0.35f, 1.0f ) ); // Dark, medium saturated blue  ( top   of screen)
     stopColors.PushBack( Vector4( 0.45f, 0.70f, 0.80f, 1.0f ) ); // Medium bright, pastel blue   (bottom of screen)
-    const float percentageStageHeight = stage.GetSize().height * 0.7f;
+    const float percentageWindowHeight = window.GetSize().GetHeight() * 0.7f;
 
     background.SetProperty( Toolkit::Control::Property::BACKGROUND, Dali::Property::Map()
       .Add( Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::GRADIENT )
       .Add( Toolkit::GradientVisual::Property::STOP_OFFSET, stopOffsets )
       .Add( Toolkit::GradientVisual::Property::STOP_COLOR, stopColors )
-      .Add( Toolkit::GradientVisual::Property::START_POSITION, Vector2( 0.0f, -percentageStageHeight ) )
-      .Add( Toolkit::GradientVisual::Property::END_POSITION, Vector2( 0.0f, percentageStageHeight ) )
+      .Add( Toolkit::GradientVisual::Property::START_POSITION, Vector2( 0.0f, -percentageWindowHeight ) )
+      .Add( Toolkit::GradientVisual::Property::END_POSITION, Vector2( 0.0f, percentageWindowHeight ) )
       .Add( Toolkit::GradientVisual::Property::UNITS, Toolkit::GradientVisual::Units::USER_SPACE ) );
 
-    stage.Add( background );
+    window.Add( background );
 
     // Create a TextLabel for the application title.
     Toolkit::TextLabel label = Toolkit::TextLabel::New( APPLICATION_TITLE );
@@ -151,21 +148,22 @@ private:
     label.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
     label.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
     label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, TEXT_COLOR );
-    stage.Add( label );
+    window.Add( label );
 
     // Layer to hold the 3D scene.
     Layer layer = Layer::New();
     layer.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
     // Set the parent origin to a small percentage below the center (so the demo will scale for different resolutions).
     layer.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5f, 0.58f, 0.5f ) );
-    layer.SetBehavior( Layer::LAYER_UI );
-    layer.SetDepthTestDisabled( false );
-    stage.Add( layer );
+    layer.SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_UI );
+    layer.SetProperty( Layer::Property::DEPTH_TEST, true );
+    window.Add( layer );
 
     // Main cube:
     // Make the demo scalable with different resolutions by basing
-    // the cube size on a percentage of the stage size.
-    float scaleSize( std::min( stage.GetSize().width, stage.GetSize().height ) );
+    // the cube size on a percentage of the window size.
+    Vector2 windowSize = window.GetSize();
+    float scaleSize( std::min( windowSize.width, windowSize.height ) );
     float cubeWidth( scaleSize * CUBE_WIDTH_SCALE );
     Vector3 cubeSize( cubeWidth, cubeWidth, cubeWidth );
     // Create the geometry for the cube, and the texture.
@@ -256,10 +254,10 @@ private:
     mRotationAnimation.Play();
     mBounceAnimation.Play();
 
-    // Respond to a click anywhere on the stage
-    stage.GetRootLayer().TouchSignal().Connect( this, &RendererStencilExample::OnTouch );
+    // Respond to a click anywhere on the window
+    window.GetRootLayer().TouchSignal().Connect( this, &RendererStencilExample::OnTouch );
     // Connect signals to allow Back and Escape to exit.
-    stage.KeyEventSignal().Connect( this, &RendererStencilExample::OnKeyEvent );
+    window.KeyEventSignal().Connect( this, &RendererStencilExample::OnKeyEvent );
   }
 
 private:
@@ -280,7 +278,7 @@ private:
     Toolkit::Control container = Toolkit::Control::New();
     container.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER );
     container.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER );
-    container.SetSize( size );
+    container.SetProperty( Actor::Property::SIZE, Vector2( size ) );
     container.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
 
     // Create a renderer from the geometry and add the texture.
@@ -317,7 +315,7 @@ private:
     Toolkit::Control container = Toolkit::Control::New();
     container.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER );
     container.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER );
-    container.SetSize( size );
+    container.SetProperty( Actor::Property::SIZE, Vector2( size ) );
     container.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
 
     // Create a renderer from the geometry and add the texture.
@@ -355,7 +353,7 @@ private:
     Toolkit::Control container = Toolkit::Control::New();
     container.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
     container.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
-    container.SetSize( size );
+    container.SetProperty( Actor::Property::SIZE, Vector2( size ) );
     container.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
 
     // We rotate the plane as the geometry is created flat in X & Y. We want it to span X & Z axis.
@@ -404,7 +402,7 @@ private:
     Toolkit::Control container = Toolkit::Control::New();
     container.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER );
     container.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER );
-    container.SetSize( size );
+    container.SetProperty( Actor::Property::SIZE, Vector2( size ) );
     container.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
 
     // Create the cube geometry of unity size.
@@ -462,7 +460,7 @@ private:
     vertexFormat[NORMAL] =   Property::VECTOR3;
     vertexFormat[TEXTURE] =  Property::VECTOR2;
 
-    PropertyBuffer surfaceVertices = PropertyBuffer::New( vertexFormat );
+    VertexBuffer surfaceVertices = VertexBuffer::New( vertexFormat );
     surfaceVertices.SetData( &vertices[0u], vertices.Size() );
 
     Geometry geometry = Geometry::New();
@@ -483,7 +481,8 @@ private:
    */
   Renderer CreateRenderer( Geometry geometry, Vector3 dimensions, bool textured, Vector4 color )
   {
-    Stage stage = Stage::GetCurrent();
+    Window window = mApplication.GetWindow();
+    Vector2 windowSize = window.GetSize();
     Shader shader;
 
     if( textured )
@@ -495,9 +494,9 @@ private:
       shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
     }
 
-    // Here we modify the light position based on half the stage size as a pre-calculation step.
+    // Here we modify the light position based on half the window size as a pre-calculation step.
     // This avoids the work having to be done in the shader.
-    shader.RegisterProperty( LIGHT_POSITION_UNIFORM_NAME, Vector3( -stage.GetSize().width / 2.0f, -stage.GetSize().width / 2.0f, 1000.0f ) );
+    shader.RegisterProperty( LIGHT_POSITION_UNIFORM_NAME, Vector3( -windowSize.width / 2.0f, -windowSize.width / 2.0f, 1000.0f ) );
     shader.RegisterProperty( COLOR_UNIFORM_NAME, color );
     shader.RegisterProperty( OBJECT_DIMENSIONS_UNIFORM_NAME, dimensions );
 
@@ -719,7 +718,7 @@ private:
    * @param[in] touch The touch information
    * @return True if the event has been handled
    */
-  bool OnTouch( Actor actor, const TouchData& touch )
+  bool OnTouch( Actor actor, const TouchEvent& touch )
   {
     // Quit the application.
     mApplication.Quit();