Further Setter/Getter public API removal from Dali::Actor
[platform/core/uifw/dali-demo.git] / examples / rendering-cube / rendering-cube.cpp
index a42e832..c80ca3a 100644 (file)
@@ -100,6 +100,9 @@ public:
 
     // Respond to a click anywhere on the stage
     stage.GetRootLayer().TouchSignal().Connect( this, &DrawCubeController::OnTouch );
+
+    // Respond to key events
+    stage.KeyEventSignal().Connect( this, &DrawCubeController::OnKeyEvent );
   }
 
   bool OnTouch( Actor actor, const TouchData& touch )
@@ -110,6 +113,23 @@ public:
   }
 
   /**
+   * @brief Called when any key event is received
+   *
+   * Will use this to quit the application if Back or the Escape key is received
+   * @param[in] event The key event information
+   */
+  void OnKeyEvent( const KeyEvent& event )
+  {
+    if( event.state == KeyEvent::Down )
+    {
+      if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
+      {
+        mApplication.Quit();
+      }
+    }
+  }
+
+  /**
    * This function creates a cube geometry including texture coordinates.
    * Also it demonstrates using the indexed draw feature by setting an index array.
    */
@@ -227,10 +247,10 @@ public:
 
     float quarterStageWidth = stage.GetSize().x * 0.25f;
     mActor = Actor::New();
-    mActor.SetAnchorPoint( AnchorPoint::CENTER );
-    mActor.SetParentOrigin( ParentOrigin::CENTER );
-    mActor.SetPosition( Vector3( 0.0f, 0.0f, 0.0f ) );
-    mActor.SetSize( Vector3( quarterStageWidth, quarterStageWidth, quarterStageWidth ) );
+    mActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    mActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    mActor.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ) );
+    mActor.SetProperty( Actor::Property::SIZE, Vector3( quarterStageWidth, quarterStageWidth, quarterStageWidth ) );
     mActor.AddRenderer( mRenderer );
     stage.Add( mActor );
   }
@@ -258,20 +278,10 @@ private:
   Animation mAnimation;
 };
 
-void RunTest( Application& application )
-{
-  DrawCubeController 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 );
-
+  DrawCubeController test( application );
+  application.MainLoop();
   return 0;
 }