[Tizen] Add Effect Start/End signal
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.cpp
index 9483164..7e9a4fd 100644 (file)
 #include <dali/devel-api/adaptor-framework/orientation.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 
-#ifdef DALI_ADAPTOR_COMPILATION
-#include <dali/integration-api/render-surface-interface.h>
-#else
-#include <dali/integration-api/adaptors/render-surface-interface.h>
-#endif
-
 // INTERNAL HEADERS
+#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
 #include <dali/internal/window-system/common/event-handler.h>
 #include <dali/internal/window-system/common/orientation-impl.h>
 #include <dali/internal/window-system/common/render-surface-factory.h>
@@ -77,13 +72,18 @@ Window::Window()
   mOpaqueState( false ),
   mResizeEnabled( false ),
   mType( Dali::Window::NORMAL ),
+  mParentWindow( NULL ),
   mPreferredOrientation( Dali::Window::PORTRAIT ),
   mRotationAngle( 0 ),
   mWindowWidth( 0 ),
   mWindowHeight( 0 ),
   mFocusChangedSignal(),
   mResizedSignal(),
-  mDeleteRequestSignal()
+  mDeleteRequestSignal(),
+  mFocusChangeSignal(),
+  mResizeSignal(),
+  mVisibilityChangedSignal(),
+  mTransitionEffectEventSignal()
 {
 }
 
@@ -110,6 +110,7 @@ void Window::Initialize(const PositionSize& positionSize, const std::string& nam
   mWindowBase->IconifyChangedSignal().Connect( this, &Window::OnIconifyChanged );
   mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged );
   mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest );
+  mWindowBase->TransitionEffectEventSignal().Connect( this, &Window::OnTransitionEffectEvent );
 
   mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
 
@@ -288,6 +289,9 @@ void Window::Show()
   {
     WindowVisibilityObserver* observer( mAdaptor );
     observer->OnWindowShown();
+
+    Dali::Window handle( this );
+    mVisibilityChangedSignal.Emit( handle, true );
   }
 
   DALI_LOG_RELEASE_INFO( "Window (%p) Show(): iconified = %d\n", this, mIconified );
@@ -303,6 +307,9 @@ void Window::Hide()
   {
     WindowVisibilityObserver* observer( mAdaptor );
     observer->OnWindowHidden();
+
+    Dali::Window handle( this );
+    mVisibilityChangedSignal.Emit( handle, false );
   }
 
   DALI_LOG_RELEASE_INFO( "Window (%p) Hide(): iconified = %d\n", this, mIconified );
@@ -451,11 +458,19 @@ void Window::SetSize( Dali::Window::WindowSize size )
   {
     Uint16Pair newSize( newRect.width, newRect.height );
 
-    SurfaceResized();
+    bool forceUpdate = false;
+    if( mWindowBase->IsEglWindowRotationSupported() )
+    {
+      forceUpdate = true;
+    }
+
+    SurfaceResized( forceUpdate );
 
     mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
 
+    Dali::Window handle( this );
     mResizedSignal.Emit( newSize );
+    mResizeSignal.Emit( handle, newSize );
 
     mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
   }
@@ -507,12 +522,19 @@ void Window::SetPositionSize( PositionSize positionSize )
   {
     Uint16Pair newSize( newRect.width, newRect.height );
 
-    SurfaceResized();
+    bool forceUpdate = false;
+    if( mWindowBase->IsEglWindowRotationSupported() )
+    {
+      forceUpdate = true;
+    }
+
+    SurfaceResized( forceUpdate );
 
     mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
 
+    Dali::Window handle( this );
     mResizedSignal.Emit( newSize );
-
+    mResizeSignal.Emit( handle, newSize );
     mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
   }
 }
@@ -557,6 +579,9 @@ void Window::OnIconifyChanged( bool iconified )
     {
       WindowVisibilityObserver* observer( mAdaptor );
       observer->OnWindowHidden();
+
+      Dali::Window handle( this );
+      mVisibilityChangedSignal.Emit( handle, false );
     }
 
     DALI_LOG_RELEASE_INFO( "Window (%p) Iconified: visible = %d\n", this, mVisible );
@@ -569,6 +594,9 @@ void Window::OnIconifyChanged( bool iconified )
     {
       WindowVisibilityObserver* observer( mAdaptor );
       observer->OnWindowShown();
+
+      Dali::Window handle( this );
+      mVisibilityChangedSignal.Emit( handle, true );
     }
 
     DALI_LOG_RELEASE_INFO( "Window (%p) Deiconified: visible = %d\n", this, mVisible );
@@ -577,13 +605,20 @@ void Window::OnIconifyChanged( bool iconified )
 
 void Window::OnFocusChanged( bool focusIn )
 {
+  Dali::Window handle( this );
   mFocusChangedSignal.Emit( focusIn );
+  mFocusChangeSignal.Emit( handle, focusIn );
 }
 
 void Window::OnOutputTransformed()
 {
+  bool forceUpdate = false;
+  if( mWindowBase->IsEglWindowRotationSupported() )
+  {
+    forceUpdate = true;
+  }
   PositionSize positionSize = mSurface->GetPositionSize();
-  SurfaceResized();
+  SurfaceResized( forceUpdate );
   mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
   mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
 }
@@ -593,6 +628,12 @@ void Window::OnDeleteRequest()
   mDeleteRequestSignal.Emit();
 }
 
+void Window::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
+{
+  Dali::Window handle( this );
+  mTransitionEffectEventSignal.Emit( handle, state, type );
+}
+
 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
 {
   FeedTouchPoint( point, timeStamp );
@@ -619,14 +660,22 @@ void Window::OnRotation( const RotationEvent& rotation )
 
   mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight );
 
-  SurfaceResized();
+  bool forceUpdate = false;
+  if( mWindowBase->IsEglWindowRotationSupported() )
+  {
+    forceUpdate = true;
+  }
 
-  mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mRotationAngle, mWindowHeight ) );
+  SurfaceResized( forceUpdate );
+
+  mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
 
   // Emit signal
-  mResizedSignal.Emit( Dali::Window::WindowSize( mRotationAngle, mWindowHeight ) );
+  Dali::Window handle( this );
+  mResizedSignal.Emit( Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
+  mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
 
-  mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mRotationAngle, mWindowHeight ) );
+  mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
 }
 
 void Window::OnPause()
@@ -693,6 +742,32 @@ Dali::Window Window::Get( Dali::Actor actor )
   return Dali::Window( windowImpl );
 }
 
+void Window::SetParent( Dali::Window& parent )
+{
+  if ( DALI_UNLIKELY( parent ) )
+  {
+    mParentWindow = parent;
+    Dali::Window self = Dali::Window( this );
+    // check circular parent window setting
+    if ( Dali::DevelWindow::GetParent( parent ) == self )
+    {
+      Dali::DevelWindow::Unparent( parent );
+    }
+    mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
+  }
+}
+
+void Window::Unparent()
+{
+  mWindowBase->SetParent( nullptr );
+  mParentWindow.Reset();
+}
+
+Dali::Window Window::GetParent()
+{
+  return mParentWindow;
+}
+
 } // Adaptor
 
 } // Internal