Changes after TouchedSignal changes
[platform/core/uifw/dali-demo.git] / examples / visual-transitions / transition-application.cpp
index 5192396..be75a63 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.
@@ -27,6 +27,7 @@
 #include "beat-control.h"
 #include <cstdio>
 #include <sstream>
+#include <dali-toolkit/devel-api/controls/table-view/table-view.h>
 
 // Internal includes
 
@@ -68,27 +69,24 @@ TransitionApplication::~TransitionApplication()
 
 void TransitionApplication::Create( Application& application )
 {
-  Stage stage = Stage::GetCurrent();
-  stage.KeyEventSignal().Connect(this, &TransitionApplication::OnKeyEvent);
-  stage.SetBackgroundColor( Vector4( 0.1f, 0.1f, 0.1f, 1.0f ) );
-
-  // Hide the indicator bar
-  application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
+  Window window = application.GetWindow();
+  window.KeyEventSignal().Connect(this, &TransitionApplication::OnKeyEvent);
+  window.SetBackgroundColor( Vector4( 0.1f, 0.1f, 0.1f, 1.0f ) );
 
   // Content panes:
   TableView contentLayout = TableView::New( 4, 1 );
-  contentLayout.SetName("ContentLayout");
+  contentLayout.SetProperty( Dali::Actor::Property::NAME,"ContentLayout");
   contentLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
-  contentLayout.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  contentLayout.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  contentLayout.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  contentLayout.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
   contentLayout.SetCellPadding( Vector2( 0.0f, 5.0f ) );
 
   // Assign all rows the size negotiation property of fitting to children
 
-  stage.Add( contentLayout );
+  window.Add( contentLayout );
 
   mTitle = TextLabel::New( "Custom Control Transition Example" );
-  mTitle.SetName( "Title" );
+  mTitle.SetProperty( Dali::Actor::Property::NAME, "Title" );
   mTitle.SetStyleName("Title");
   mTitle.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
   mTitle.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
@@ -97,19 +95,19 @@ void TransitionApplication::Create( Application& application )
   contentLayout.SetFitHeight(0); // Fill width
 
   mBeatControl = BeatControl::New();
-  mBeatControl.SetName("BeatControl");
+  mBeatControl.SetProperty( Dali::Actor::Property::NAME,"BeatControl");
   mBeatControl.SetProperty( BeatControl::Property::BEAT_VISUAL, Property::Map()
                             .Add( Visual::Property::TRANSFORM, Property::Map()
                                   .Add( Visual::Transform::Property::SIZE, Vector2(0.5f, 0.5f) ) ) );
 
-  mBeatControl.SetAnchorPoint( AnchorPoint::CENTER );
-  mBeatControl.SetParentOrigin( ParentOrigin::CENTER );
+  mBeatControl.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+  mBeatControl.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
   mBeatControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
   contentLayout.Add( mBeatControl );
   // beat control should fill the tableview cell, so no change to default parameters
 
   TableView visualTypeLayout = TableView::New( 1, NUMBER_OF_VISUAL_BUTTONS );
-  visualTypeLayout.SetName("VisualTypeLayout");
+  visualTypeLayout.SetProperty( Dali::Actor::Property::NAME,"VisualTypeLayout");
   visualTypeLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
   visualTypeLayout.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
   visualTypeLayout.SetFitHeight( 0 );
@@ -125,18 +123,18 @@ void TransitionApplication::Create( Application& application )
              .Add( Visual::Transform::Property::SIZE, Vector2(0.8f, 0.8f) )  );
     mVisualButtons[i] = BeatControl::New();
     mVisualButtons[i].SetProperty( BeatControl::Property::BEAT_VISUAL, map );
-    mVisualButtons[i].SetName("VisualButton");
+    mVisualButtons[i].SetProperty( Dali::Actor::Property::NAME,"VisualButton");
     mVisualButtons[i].SetStyleName("VisualButton");
-    mVisualButtons[i].SetSize(0, 50);
+    mVisualButtons[i].SetProperty( Actor::Property::SIZE, Vector2(0, 50) );
     mVisualButtons[i].SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
     mVisualButtons[i].SetResizePolicy( ResizePolicy::FIXED, Dimension::HEIGHT );
     mVisualIndex = mVisualButtons[i].RegisterProperty( "visualId", i, Property::READ_WRITE );
-    mVisualButtons[i].TouchSignal().Connect( this, &TransitionApplication::OnVisualButtonClicked );
+    mVisualButtons[i].TouchedSignal().Connect( this, &TransitionApplication::OnVisualButtonClicked );
     visualTypeLayout.AddChild( mVisualButtons[i], TableView::CellPosition( 0, i ) );
   }
 
   TableView actionButtonLayout = TableView::New( 1, NUMBER_OF_ACTION_BUTTONS+1 );
-  actionButtonLayout.SetName("ThemeButtonsLayout");
+  actionButtonLayout.SetProperty( Dali::Actor::Property::NAME,"ThemeButtonsLayout");
   actionButtonLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
   actionButtonLayout.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
   actionButtonLayout.SetFitHeight( 0 );
@@ -150,7 +148,7 @@ void TransitionApplication::Create( Application& application )
   for( int i=0; i<NUMBER_OF_ACTION_BUTTONS; ++i )
   {
     mActionButtons[i] = PushButton::New();
-    mActionButtons[i].SetName("ActionButton");
+    mActionButtons[i].SetProperty( Dali::Actor::Property::NAME,"ActionButton");
     mActionButtons[i].SetStyleName("ActionButton");
     mActionButtons[i].SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
     mActionButtons[i].SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
@@ -278,9 +276,9 @@ void TransitionApplication::CreateVisualMap( int index, Property::Map& map )
   }
 }
 
-bool TransitionApplication::OnVisualButtonClicked( Actor actor, const TouchData& touchData )
+bool TransitionApplication::OnVisualButtonClicked( Actor actor, const TouchEvent& touch )
 {
-  if( touchData.GetState(0) == PointState::FINISHED )
+  if( touch.GetState(0) == PointState::FINISHED )
   {
     int visual = actor.GetProperty<int>( mVisualIndex );
     Property::Map map;
@@ -326,23 +324,23 @@ void TransitionApplication::OnKeyEvent( const KeyEvent& keyEvent )
 {
   static int keyPressed = 0;
 
-  if( keyEvent.state == KeyEvent::Down)
+  if( keyEvent.GetState() == KeyEvent::DOWN)
   {
     if( keyPressed == 0 ) // Is this the first down event?
     {
-      printf("Key pressed: %s %d\n", keyEvent.keyPressedName.c_str(), keyEvent.keyCode );
+      printf("Key pressed: %s %d\n", keyEvent.GetKeyName().c_str(), keyEvent.GetKeyCode() );
 
       if( IsKey( keyEvent, DALI_KEY_ESCAPE) || IsKey( keyEvent, DALI_KEY_BACK ) )
       {
         mApplication.Quit();
       }
-      else if( keyEvent.keyPressedName.compare("Return") == 0 )
+      else if( keyEvent.GetKeyName().compare("Return") == 0 )
       {
       }
     }
     keyPressed = 1;
   }
-  else if( keyEvent.state == KeyEvent::Up )
+  else if( keyEvent.GetState() == KeyEvent::UP )
   {
     keyPressed = 0;
   }