Changes after TouchedSignal changes
[platform/core/uifw/dali-demo.git] / shared / dali-table-view.cpp
index c62c84c..11f0c97 100644 (file)
@@ -105,7 +105,6 @@ const char * const DEMO_BUILD_DATE    = __DATE__ " " __TIME__;
 Control CreateBackground( std::string stylename )
 {
   Control background = Control::New();
-  Stage::GetCurrent().Add( background );
   background.SetStyleName( stylename );
   background.SetProperty( Actor::Property::NAME, "BACKGROUND" );
   background.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
@@ -229,12 +228,13 @@ void DaliTableView::SortAlphabetically( bool sortAlphabetically )
 
 void DaliTableView::Initialize( Application& application )
 {
-  Stage::GetCurrent().KeyEventSignal().Connect( this, &DaliTableView::OnKeyEvent );
-  const Vector2 stageSize = Stage::GetCurrent().GetSize();
+  Window window = application.GetWindow();
+  window.KeyEventSignal().Connect( this, &DaliTableView::OnKeyEvent );
+  const Window::WindowSize windowSize = window.GetSize();
 
   // Background
   mRootActor = CreateBackground( "LauncherBackground" );
-  Stage::GetCurrent().Add( mRootActor );
+  window.Add( mRootActor );
 
   // Add logo
   ImageView logo = ImageView::New( LOGO_PATH );
@@ -259,15 +259,15 @@ void DaliTableView::Initialize( Application& application )
   mScrollView.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT );
   mScrollView.SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3( 0.0f, 0.6f, 0.0f ) );
 
-  const float buttonsPageMargin = ( 1.0f - TABLE_RELATIVE_SIZE.x ) * 0.5f * stageSize.width;
+  const float buttonsPageMargin = ( 1.0f - TABLE_RELATIVE_SIZE.x ) * 0.5f * windowSize.GetWidth();
   mScrollView.SetProperty( Actor::Property::PADDING, Padding( buttonsPageMargin, buttonsPageMargin, 0.0f, 0.0f ) );
 
   mScrollView.SetAxisAutoLock( true );
   mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete );
   mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart );
-  mScrollView.TouchSignal().Connect( this, &DaliTableView::OnScrollTouched );
+  mScrollView.TouchedSignal().Connect( this, &DaliTableView::OnScrollTouched );
 
-  mPageWidth = stageSize.width * TABLE_RELATIVE_SIZE.x * 0.5f;
+  mPageWidth = windowSize.GetWidth() * TABLE_RELATIVE_SIZE.x * 0.5f;
 
   // Populate background and bubbles - needs to be scrollViewLayer so scroll ends show
   Actor bubbleContainer = Actor::New();
@@ -290,7 +290,7 @@ void DaliTableView::Initialize( Application& application )
 
   Dali::Window winHandle = application.GetWindow();
 
-  if( stageSize.width <= stageSize.height )
+  if( windowSize.GetWidth() <= windowSize.GetHeight() )
   {
     winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT );
     winHandle.RemoveAvailableOrientation( Dali::Window::LANDSCAPE );
@@ -358,9 +358,9 @@ void DaliTableView::CreateFocusEffect()
 
   keyboardFocusManager.SetFocusIndicatorActor( mFocusEffect[0].actor );
 
-  // Connect to the on & off stage signals of the indicator which represents when it is enabled & disabled respectively
-  mFocusEffect[0].actor.OnStageSignal().Connect( this, &DaliTableView::OnFocusIndicatorEnabled );
-  mFocusEffect[0].actor.OffStageSignal().Connect( this, &DaliTableView::OnFocusIndicatorDisabled );
+  // Connect to the on & off scene signals of the indicator which represents when it is enabled & disabled respectively
+  mFocusEffect[0].actor.OnSceneSignal().Connect( this, &DaliTableView::OnFocusIndicatorEnabled );
+  mFocusEffect[0].actor.OffSceneSignal().Connect( this, &DaliTableView::OnFocusIndicatorDisabled );
 }
 
 void DaliTableView::OnFocusIndicatorEnabled( Actor /* actor */ )
@@ -398,7 +398,7 @@ void DaliTableView::OnButtonsPageRelayout( const Dali::Actor& actor )
 
 void DaliTableView::Populate()
 {
-  const Vector2 stageSize = Stage::GetCurrent().GetSize();
+  const Window::WindowSize windowSize = mApplication.GetWindow().GetSize();
 
   mTotalPages = ( mExampleList.size() + EXAMPLES_PER_PAGE - 1 ) / EXAMPLES_PER_PAGE;
 
@@ -472,7 +472,7 @@ void DaliTableView::Populate()
   // Update Ruler info.
   mScrollRulerX = new FixedRuler( mPageWidth );
   mScrollRulerY = new DefaultRuler();
-  mScrollRulerX->SetDomain( RulerDomain( 0.0f, (mTotalPages+1) * stageSize.width * TABLE_RELATIVE_SIZE.x * 0.5f, true ) );
+  mScrollRulerX->SetDomain( RulerDomain( 0.0f, (mTotalPages+1) * windowSize.GetWidth() * TABLE_RELATIVE_SIZE.x * 0.5f, true ) );
   mScrollRulerY->Disable();
   mScrollView.SetRulerX( mScrollRulerX );
   mScrollView.SetRulerY( mScrollRulerY );
@@ -481,12 +481,13 @@ void DaliTableView::Populate()
 void DaliTableView::Rotate( unsigned int degrees )
 {
   // Resize the root actor
-  Vector2 stageSize = Stage::GetCurrent().GetSize();
-  Vector3 targetSize( stageSize.x, stageSize.y, 1.0f );
+  const Window::WindowSize windowSize = mApplication.GetWindow().GetSize();
+  const Vector2 originalSize( windowSize.GetWidth(), windowSize.GetHeight() );
+  Vector3 targetSize( originalSize.x, originalSize.y, 1.0f );
 
   if( degrees == 90 || degrees == 270 )
   {
-    targetSize = Vector3( stageSize.y, stageSize.x, 1.0f );
+    targetSize = Vector3( originalSize.y, originalSize.x, 1.0f );
   }
 
   if( mRotateAnimation )
@@ -522,7 +523,7 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit
   // and pass it to the shader uniform, along with the tile's position.
   Constraint shaderPosition = Constraint::New < Vector3 > ( focusableTile, propertyIndex, TileShaderPositionConstraint( mPageWidth, position.x ) );
   shaderPosition.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) );
-  shaderPosition.SetRemoveAction( Constraint::Discard );
+  shaderPosition.SetRemoveAction( Constraint::DISCARD );
   shaderPosition.Apply();
   //focusableTile.Add( tileContent );
 
@@ -550,13 +551,13 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit
   focusableTile.Add( label );
 
   // Connect to the touch events
-  focusableTile.TouchSignal().Connect( this, &DaliTableView::OnTilePressed );
+  focusableTile.TouchedSignal().Connect( this, &DaliTableView::OnTilePressed );
   focusableTile.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered );
 
   return focusableTile;
 }
 
-bool DaliTableView::OnTilePressed( Actor actor, const TouchData& event )
+bool DaliTableView::OnTilePressed( Actor actor, const TouchEvent& event )
 {
   return DoTilePress( actor, event.GetState( 0 ) );
 }
@@ -595,7 +596,7 @@ bool DaliTableView::DoTilePress( Actor actor, PointState::Type pointState )
     if( consumed )
     {
       mPressedAnimation = Animation::New( BUTTON_PRESS_ANIMATION_TIME );
-      mPressedAnimation.SetEndAction( Animation::Discard );
+      mPressedAnimation.SetEndAction( Animation::DISCARD );
 
       // scale the content actor within the Tile, as to not affect the placement within the Table.
       Actor content = actor.GetChildAt(0);
@@ -643,7 +644,7 @@ void DaliTableView::OnScrollComplete( const Dali::Vector2& position )
   accessibilityManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) );
 }
 
-bool DaliTableView::OnScrollTouched( Actor actor, const TouchData& event )
+bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event )
 {
   if( PointState::DOWN == event.GetState( 0 ) )
   {
@@ -670,34 +671,35 @@ void DaliTableView::ApplyScrollViewEffect()
 
 void DaliTableView::SetupInnerPageCubeEffect()
 {
-  const Vector2 stageSize = Stage::GetCurrent().GetSize();
+  const Window::WindowSize windowDimensions = mApplication.GetWindow().GetSize();
+  const Vector2 windowSize(windowDimensions.GetWidth(), windowDimensions.GetHeight());
 
   Dali::Path path = Dali::Path::New();
   Dali::Property::Array points;
   points.Resize(3);
-  points[0] = Vector3( stageSize.x*0.5, 0.0f,  stageSize.x*0.5f);
+  points[0] = Vector3( windowSize.x*0.5, 0.0f,  windowSize.x*0.5f);
   points[1] = Vector3( 0.0f, 0.0f, 0.0f );
-  points[2] = Vector3( -stageSize.x*0.5f, 0.0f, stageSize.x*0.5f);
+  points[2] = Vector3( -windowSize.x*0.5f, 0.0f, windowSize.x*0.5f);
   path.SetProperty( Path::Property::POINTS, points );
 
   Dali::Property::Array controlPoints;
   controlPoints.Resize(4);
-  controlPoints[0] = Vector3( stageSize.x*0.5f, 0.0f, stageSize.x*0.3f );
-  controlPoints[1] = Vector3( stageSize.x*0.3f, 0.0f, 0.0f );
-  controlPoints[2] = Vector3(-stageSize.x*0.3f, 0.0f, 0.0f );
-  controlPoints[3] = Vector3(-stageSize.x*0.5f, 0.0f,  stageSize.x*0.3f );
+  controlPoints[0] = Vector3( windowSize.x*0.5f, 0.0f, windowSize.x*0.3f );
+  controlPoints[1] = Vector3( windowSize.x*0.3f, 0.0f, 0.0f );
+  controlPoints[2] = Vector3(-windowSize.x*0.3f, 0.0f, 0.0f );
+  controlPoints[3] = Vector3(-windowSize.x*0.5f, 0.0f,  windowSize.x*0.3f );
   path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints );
 
 
   mScrollViewEffect = ScrollViewPagePathEffect::New(path,
                                                     Vector3(-1.0f,0.0f,0.0f),
                                                     Toolkit::ScrollView::Property::SCROLL_FINAL_X,
-                                                    Vector3(stageSize.x*TABLE_RELATIVE_SIZE.x,stageSize.y*TABLE_RELATIVE_SIZE.y,0.0f),mTotalPages);
+                                                    Vector3(windowSize.x*TABLE_RELATIVE_SIZE.x,windowSize.y*TABLE_RELATIVE_SIZE.y,0.0f),mTotalPages);
 }
 
 void DaliTableView::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) )
     {
@@ -746,7 +748,7 @@ void DaliTableView::InitialiseBackgroundActors( Actor actor )
     animConstraint.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) );
     animConstraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) );
     animConstraint.AddSource( Dali::LocalSource( Dali::Actor::Property::SIZE ) );
-    animConstraint.SetRemoveAction( Constraint::Discard );
+    animConstraint.SetRemoveAction( Constraint::DISCARD );
     animConstraint.Apply();
 
     // Kickoff animation
@@ -935,7 +937,7 @@ void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap
       mVersionPopup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
 
       mVersionPopup.OutsideTouchedSignal().Connect( this, &DaliTableView::HideVersionPopup );
-      Stage::GetCurrent().Add( mVersionPopup );
+      mApplication.GetWindow().Add( mVersionPopup );
     }
 
     mVersionPopup.SetDisplayState( Popup::SHOWN );