Changes after TouchedSignal changes
[platform/core/uifw/dali-demo.git] / examples / compressed-texture-formats / compressed-texture-formats-example.cpp
index d53b8cf..cf081f5 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,6 +18,7 @@
 // EXTERNAL INCLUDES
 #include <dali/dali.h>
 #include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/table-view/table-view.h>
 
 // INTERNAL INCLUDES
 #include "shared/utility.h"
@@ -77,7 +78,7 @@ void AddImage( const char*imagePath, Actor& actor, Geometry& geometry, Shader& s
   renderer.SetTextures( textureSet );
 
   //Set actor size and add the renderer
-  actor.SetSize( texture.GetWidth(), texture.GetHeight() );
+  actor.SetProperty( Actor::Property::SIZE, Vector2( texture.GetWidth(), texture.GetHeight() ) );
   actor.AddRenderer( renderer );
 }
 
@@ -106,14 +107,14 @@ 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::WHITE );
+    // Get a handle to the window
+    Window window = application.GetWindow();
+    window.SetBackgroundColor( Color::WHITE );
 
     // Setup a TableView to hold a grid of images and labels.
     Toolkit::TableView table = Toolkit::TableView::New( 3u, 2u );
-    table.SetAnchorPoint( AnchorPoint::CENTER );
-    table.SetParentOrigin( ParentOrigin::CENTER );
+    table.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    table.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     table.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
     table.SetRelativeWidth( 0u, 0.5f );
     table.SetRelativeWidth( 1u, 0.5f );
@@ -124,24 +125,24 @@ public:
 
     // Add text labels.
     TextLabel textLabel = TextLabel::New( "ETC1 (KTX):" );
-    textLabel.SetAnchorPoint( AnchorPoint::CENTER );
-    textLabel.SetParentOrigin( ParentOrigin::CENTER );
+    textLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    textLabel.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     textLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
     textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true );
     table.AddChild( textLabel, Toolkit::TableView::CellPosition( 0u, 0u ) );
     table.SetCellAlignment( Toolkit::TableView::CellPosition( 0u, 0u ), HorizontalAlignment::LEFT, VerticalAlignment::CENTER );
 
     textLabel = TextLabel::New( "ASTC (KTX) 4x4 linear:" );
-    textLabel.SetAnchorPoint( AnchorPoint::CENTER );
-    textLabel.SetParentOrigin( ParentOrigin::CENTER );
+    textLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    textLabel.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     textLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
     textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true );
     table.AddChild( textLabel, Toolkit::TableView::CellPosition( 1u, 0u ) );
     table.SetCellAlignment( Toolkit::TableView::CellPosition( 1u, 0u ), HorizontalAlignment::LEFT, VerticalAlignment::CENTER );
 
     textLabel = TextLabel::New( "ASTC (Native) 4x4 linear:" );
-    textLabel.SetAnchorPoint( AnchorPoint::CENTER );
-    textLabel.SetParentOrigin( ParentOrigin::CENTER );
+    textLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    textLabel.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     textLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
     textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true );
     table.AddChild( textLabel, Toolkit::TableView::CellPosition( 2u, 0u ) );
@@ -153,34 +154,34 @@ public:
 
     // Add images.
     Actor actor = Actor::New();
-    actor.SetAnchorPoint( AnchorPoint::CENTER );
-    actor.SetParentOrigin( ParentOrigin::CENTER );
+    actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     AddImage( IMAGE_FILENAME_ETC, actor, geometry, shader  );
     table.AddChild( actor, Toolkit::TableView::CellPosition( 0u, 1u ) );
     table.SetCellAlignment( Toolkit::TableView::CellPosition( 0u, 1u ), HorizontalAlignment::CENTER, VerticalAlignment::CENTER );
 
     actor = Actor::New();
-    actor.SetAnchorPoint( AnchorPoint::CENTER );
-    actor.SetParentOrigin( ParentOrigin::CENTER );
+    actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     AddImage( IMAGE_FILENAME_ASTC_LINEAR, actor, geometry, shader );
     table.AddChild( actor, Toolkit::TableView::CellPosition( 1u, 1u ) );
     table.SetCellAlignment( Toolkit::TableView::CellPosition( 1u, 1u ), HorizontalAlignment::CENTER, VerticalAlignment::CENTER );
 
     actor = Actor::New();
-    actor.SetAnchorPoint( AnchorPoint::CENTER );
-    actor.SetParentOrigin( ParentOrigin::CENTER );
+    actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
     AddImage( IMAGE_FILENAME_ASTC_LINEAR_NATIVE, actor, geometry, shader );
     table.AddChild( actor, Toolkit::TableView::CellPosition( 2u, 1u ) );
     table.SetCellAlignment( Toolkit::TableView::CellPosition( 2u, 1u ), HorizontalAlignment::CENTER, VerticalAlignment::CENTER );
 
-    stage.Add( table );
+    window.Add( table );
 
     // Respond to touch and key signals
-    stage.GetRootLayer().TouchSignal().Connect( this, &CompressedTextureFormatsController::OnTouch );
-    stage.KeyEventSignal().Connect(this, &CompressedTextureFormatsController::OnKeyEvent);
+    window.GetRootLayer().TouchedSignal().Connect( this, &CompressedTextureFormatsController::OnTouch );
+    window.KeyEventSignal().Connect(this, &CompressedTextureFormatsController::OnKeyEvent);
   }
 
-  bool OnTouch( Actor actor, const TouchData& touch )
+  bool OnTouch( Actor actor, const TouchEvent& touch )
   {
     // quit the application
     mApplication.Quit();
@@ -189,7 +190,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) )
       {
@@ -202,20 +203,10 @@ private:
   Application&  mApplication;
 };
 
-void RunTest( Application& application )
-{
-  CompressedTextureFormatsController 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 );
-
+  CompressedTextureFormatsController test( application );
+  application.MainLoop();
   return 0;
 }