KeyEvent class pimpling
[platform/core/uifw/dali-demo.git] / examples / cube-transition-effect / cube-transition-effect-example.cpp
index 8d8acbd..bd65bb8 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.
@@ -24,7 +24,6 @@
 
 #include <dali/dali.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
 #include <dali-toolkit/devel-api/controls/buttons/toggle-button.h>
 #include <dali-toolkit/devel-api/transition-effects/cube-transition-effect.h>
 #include <dali-toolkit/devel-api/transition-effects/cube-transition-cross-effect.h>
@@ -160,11 +159,11 @@ private:
   bool OnTimerTick();
 
   /**
-   * Loads image, resizes it to the size of stage and creates a textue out of it
+   * Loads image, resizes it to the size of window and creates a textue out of it
    * @param[in] filepath Path to the image file
    * @return New texture object
    */
-  Texture LoadStageFillingTexture( const char* filepath );
+  Texture LoadWindowFillingTexture( const char* filepath );
 
 private:
   Application&                    mApplication;
@@ -211,20 +210,20 @@ CubeTransitionApp::~CubeTransitionApp()
 
 void CubeTransitionApp::OnInit( Application& application )
 {
-  Stage::GetCurrent().KeyEventSignal().Connect(this, &CubeTransitionApp::OnKeyEvent);
+  application.GetWindow().KeyEventSignal().Connect(this, &CubeTransitionApp::OnKeyEvent);
 
-  // Creates a default view with a default tool bar, the view is added to the stage.
+  // Creates a default view with a default tool bar, the view is added to the window.
   mContent = DemoHelper::CreateView( application, mView, mToolBar, "", TOOLBAR_IMAGE, "" );
-  mContent.SetBehavior( Layer::LAYER_3D );
+  mContent.SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D );
 
 
   // Add an effect changing toggle button
   Toolkit::ToggleButton effectChangeToggleButton = Toolkit::ToggleButton::ToggleButton::New();
 
   effectChangeToggleButton.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS,
-                                        Property::Array().Add( EFFECT_WAVE_IMAGE )
-                                                         .Add( EFFECT_CROSS_IMAGE)
-                                                         .Add( EFFECT_FOLD_IMAGE )
+                                        Property::Array{ EFFECT_WAVE_IMAGE,
+                                                         EFFECT_CROSS_IMAGE,
+                                                         EFFECT_FOLD_IMAGE }
                                       );
 
   effectChangeToggleButton.ClickedSignal().Connect( this, &CubeTransitionApp::OnEffectButtonClicked );
@@ -236,16 +235,16 @@ void CubeTransitionApp::OnInit( Application& application )
 
   //Add an slideshow icon on the right of the title
   mSlideshowButton = Toolkit::PushButton::New();
-  mSlideshowButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, SLIDE_SHOW_START_ICON );
-  mSlideshowButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, SLIDE_SHOW_START_ICON_SELECTED );
+  mSlideshowButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, SLIDE_SHOW_START_ICON );
+  mSlideshowButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, SLIDE_SHOW_START_ICON_SELECTED );
   mSlideshowButton.ClickedSignal().Connect( this, &CubeTransitionApp::OnSildeshowButtonClicked );
   mToolBar.AddControl( mSlideshowButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING );
 
-  // Set size to stage size to avoid seeing a black border on transition
-  mViewSize = Stage::GetCurrent().GetSize();
+  // Set size to window size to avoid seeing a black border on transition
+  mViewSize = application.GetWindow().GetSize();
 
   // show the first image
-  mCurrentTexture = LoadStageFillingTexture( IMAGES[mIndex] );
+  mCurrentTexture = LoadWindowFillingTexture( IMAGES[mIndex] );
 
   //use small cubes
   mCubeWaveEffect = Toolkit::CubeTransitionWaveEffect::New( NUM_ROWS_WAVE, NUM_COLUMNS_WAVE );
@@ -253,8 +252,8 @@ void CubeTransitionApp::OnInit( Application& application )
   mCubeWaveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT_WAVE );
   mCubeWaveEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted);
 
-  mCubeWaveEffect.SetSize( mViewSize );
-  mCubeWaveEffect.SetParentOrigin( ParentOrigin::CENTER );
+  mCubeWaveEffect.SetProperty( Actor::Property::SIZE, mViewSize );
+  mCubeWaveEffect.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
   mCubeWaveEffect.SetCurrentTexture( mCurrentTexture );
 
   // use big cubes
@@ -263,16 +262,16 @@ void CubeTransitionApp::OnInit( Application& application )
   mCubeCrossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT_CROSS );
   mCubeCrossEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted);
 
-  mCubeCrossEffect.SetSize( mViewSize );
-  mCubeCrossEffect.SetParentOrigin( ParentOrigin::CENTER );
+  mCubeCrossEffect.SetProperty( Actor::Property::SIZE, mViewSize );
+  mCubeCrossEffect.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
   mCubeCrossEffect.SetCurrentTexture( mCurrentTexture );
 
   mCubeFoldEffect = Toolkit::CubeTransitionFoldEffect::New( NUM_ROWS_FOLD, NUM_COLUMNS_FOLD );
   mCubeFoldEffect.SetTransitionDuration( ANIMATION_DURATION_FOLD );
   mCubeFoldEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted);
 
-  mCubeFoldEffect.SetSize( mViewSize );
-  mCubeFoldEffect.SetParentOrigin( ParentOrigin::CENTER );
+  mCubeFoldEffect.SetProperty( Actor::Property::SIZE, mViewSize );
+  mCubeFoldEffect.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
   mCubeFoldEffect.SetCurrentTexture( mCurrentTexture );
 
   mViewTimer = Timer::New( VIEWINGTIME );
@@ -316,7 +315,7 @@ void CubeTransitionApp::OnPanGesture( Actor actor, const PanGesture& gesture )
 
 void CubeTransitionApp::GoToNextImage()
 {
-  mNextTexture = LoadStageFillingTexture( IMAGES[ mIndex ] );
+  mNextTexture = LoadWindowFillingTexture( IMAGES[ mIndex ] );
   mCurrentEffect.SetTargetTexture( mNextTexture );
   mIsImageLoading = false;
   mCurrentEffect.StartTransition( mPanPosition, mPanDisplacement );
@@ -355,8 +354,8 @@ bool CubeTransitionApp::OnSildeshowButtonClicked( Toolkit::Button button )
   if( mSlideshow )
   {
     mPanGestureDetector.Detach( mContent );
-    mSlideshowButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, SLIDE_SHOW_STOP_ICON );
-    mSlideshowButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, SLIDE_SHOW_STOP_ICON_SELECTED );
+    mSlideshowButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, SLIDE_SHOW_STOP_ICON );
+    mSlideshowButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, SLIDE_SHOW_STOP_ICON_SELECTED );
     mPanPosition = Vector2( mViewSize.width, mViewSize.height*0.5f );
     mPanDisplacement = Vector2( -10.f, 0.f );
     mViewTimer.Start();
@@ -364,8 +363,8 @@ bool CubeTransitionApp::OnSildeshowButtonClicked( Toolkit::Button button )
   else
   {
     mPanGestureDetector.Attach( mContent );
-    mSlideshowButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, SLIDE_SHOW_START_ICON );
-    mSlideshowButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, SLIDE_SHOW_START_ICON_SELECTED );
+    mSlideshowButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, SLIDE_SHOW_START_ICON );
+    mSlideshowButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, SLIDE_SHOW_START_ICON_SELECTED );
     mViewTimer.Stop();
   }
   return true;
@@ -391,9 +390,9 @@ bool CubeTransitionApp::OnTimerTick()
   return false;
 }
 
-Texture CubeTransitionApp::LoadStageFillingTexture( const char* filepath )
+Texture CubeTransitionApp::LoadWindowFillingTexture( const char* filepath )
 {
-  ImageDimensions dimensions( Stage::GetCurrent().GetSize().x, Stage::GetCurrent().GetSize().y );
+  ImageDimensions dimensions( mApplication.GetWindow().GetSize() );
   Devel::PixelBuffer pixelBuffer = LoadImageFromFile( filepath, dimensions, FittingMode::SCALE_TO_FILL );
   PixelData pixelData = Devel::PixelBuffer::Convert(pixelBuffer);
 
@@ -404,7 +403,7 @@ Texture CubeTransitionApp::LoadStageFillingTexture( const char* filepath )
 
 void CubeTransitionApp::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) )
     {
@@ -413,7 +412,6 @@ void CubeTransitionApp::OnKeyEvent(const KeyEvent& event)
   }
 }
 
-// Entry point for Linux & Tizen applications
 int DALI_EXPORT_API main( int argc, char **argv )
 {
   Application application = Application::New( &argc, &argv, DEMO_THEME_PATH );