[3.0] Enable to set the margin of indicator
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / common / ecore-indicator-impl.cpp
index b33cd12..e3bf901 100644 (file)
@@ -21,7 +21,9 @@
 // EXTERNAL INCLUDES
 #include <Ecore.h>
 #include <Evas.h>
-#ifndef WAYLAND
+#ifdef WAYLAND
+#include <Ecore_Wayland.h>
+#else
 #include <Ecore_X.h>
 #endif
 
@@ -35,8 +37,6 @@
 #include <dali/public-api/events/touch-event.h>
 #include <dali/public-api/events/touch-point.h>
 #include <dali/public-api/common/stage.h>
-#include <dali/public-api/actors/blending.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
 #include <dali/public-api/images/buffer-image.h>
 
 #include <dali/integration-api/debug.h>
@@ -291,11 +291,15 @@ namespace Adaptor
 Debug::Filter* gIndicatorLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_INDICATOR");
 #endif
 
-#ifndef WAYLAND
 // Impl to hide EFL implementation.
+
 struct Indicator::Impl
 {
-  // Construction & Destruction
+  enum // operation mode
+  {
+    INDICATOR_HIDE,
+    INDICATOR_STAY_WITH_DURATION
+  };
 
   /**
    * Constructor
@@ -304,8 +308,13 @@ struct Indicator::Impl
   : mIndicator(indicator),
     mEcoreEventHandler(NULL)
   {
-    // Register Client message events for quick panel state.
+#if defined(DALI_PROFILE_MOBILE)
+#if defined(WAYLAND)
+    mEcoreEventHandler = ecore_event_handler_add(ECORE_WL_EVENT_INDICATOR_FLICK,  EcoreEventIndicator, this);
+#else
     mEcoreEventHandler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,  EcoreEventClientMessage, this);
+#endif
+#endif // WAYLAND && DALI_PROFILE_MOBILE
   }
 
   /**
@@ -313,24 +322,21 @@ struct Indicator::Impl
    */
   ~Impl()
   {
-    ecore_event_handler_del(mEcoreEventHandler);
+    if ( mEcoreEventHandler )
+    {
+      ecore_event_handler_del(mEcoreEventHandler);
+    }
   }
 
-  /**
-   * Called when the client messages (i.e. quick panel state) are received.
-   */
-  static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
+  static void SetIndicatorVisibility( void* data, int operation )
   {
-    Ecore_X_Event_Client_Message* clientMessageEvent((Ecore_X_Event_Client_Message*)event);
     Indicator::Impl* indicatorImpl((Indicator::Impl*)data);
 
-    if (clientMessageEvent == NULL || indicatorImpl == NULL || indicatorImpl->mIndicator == NULL)
+    if ( indicatorImpl == NULL || indicatorImpl->mIndicator == NULL)
     {
-      return ECORE_CALLBACK_PASS_ON;
+      return;
     }
-
-#ifndef DALI_PROFILE_UBUNTU
-    if (clientMessageEvent->message_type == ECORE_X_ATOM_E_INDICATOR_FLICK_DONE)
+    if ( operation == INDICATOR_STAY_WITH_DURATION )
     {
       // if indicator is not showing, INDICATOR_FLICK_DONE is given
       if( indicatorImpl->mIndicator->mVisible == Dali::Window::AUTO &&
@@ -339,7 +345,7 @@ struct Indicator::Impl
         indicatorImpl->mIndicator->ShowIndicator( AUTO_INDICATOR_STAY_DURATION );
       }
     }
-    else if( clientMessageEvent->message_type == ECORE_X_ATOM_E_MOVE_QUICKPANEL_STATE )
+    else if( operation == INDICATOR_HIDE )
     {
       if( indicatorImpl->mIndicator->mVisible == Dali::Window::AUTO &&
           indicatorImpl->mIndicator->mIsShowing )
@@ -347,16 +353,45 @@ struct Indicator::Impl
         indicatorImpl->mIndicator->ShowIndicator( HIDE_NOW );
       }
     }
-#endif
+  }
+#if defined(DALI_PROFILE_MOBILE)
+#if defined(WAYLAND)
+  /**
+   * Called when the Ecore indicator event is received.
+   */
+  static Eina_Bool EcoreEventIndicator( void* data, int type, void* event )
+  {
+    SetIndicatorVisibility( data, INDICATOR_STAY_WITH_DURATION );
+    return ECORE_CALLBACK_PASS_ON;
+  }
+#else
+  /**
+   * Called when the client messages (i.e. quick panel state) are received.
+   */
+  static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
+  {
+    Ecore_X_Event_Client_Message* clientMessageEvent((Ecore_X_Event_Client_Message*)event);
 
+    if ( clientMessageEvent != NULL )
+    {
+      if (clientMessageEvent->message_type == ECORE_X_ATOM_E_INDICATOR_FLICK_DONE)
+      {
+        SetIndicatorVisibility( data, INDICATOR_STAY_WITH_DURATION );
+      }
+      else if ( clientMessageEvent->message_type == ECORE_X_ATOM_E_MOVE_QUICKPANEL_STATE )
+      {
+        SetIndicatorVisibility( data, INDICATOR_HIDE );
+      }
+    }
     return ECORE_CALLBACK_PASS_ON;
   }
+#endif
+#endif // WAYLAND && DALI_PROFILE_MOBILE
 
   // Data
   Indicator*           mIndicator;
   Ecore_Event_Handler* mEcoreEventHandler;
 };
-#endif
 
 Indicator::LockFile::LockFile(const std::string filename)
 : mFilename(filename),
@@ -466,7 +501,8 @@ Indicator::Indicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientat
   mCurrentSharedFile( 0 ),
   mSharedBufferType( BUFFER_TYPE_SHM ),
   mImpl( NULL ),
-  mBackgroundVisible( false )
+  mBackgroundVisible( false ),
+  mTopMargin( 0 )
 {
   mIndicatorContentActor = Dali::Actor::New();
   mIndicatorContentActor.SetParentOrigin( ParentOrigin::TOP_CENTER );
@@ -504,21 +540,17 @@ Indicator::Indicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientat
   // hide the indicator by default
   mIndicatorActor.SetVisible( false );
 
-#ifndef WAYLAND
   // create impl to handle ecore event
   mImpl = new Impl(this);
-#endif
 }
 
 Indicator::~Indicator()
 {
-#ifndef WAYLAND
   if(mImpl)
   {
     delete mImpl;
     mImpl = NULL;
   }
-#endif
 
   if(mEventActor)
   {
@@ -617,6 +649,7 @@ void Indicator::SetOpacityMode( Dali::Window::IndicatorBgOpacity mode )
     mIndicatorContentActor.RemoveRenderer( mBackgroundRenderer );
     mBackgroundVisible = false;
   }
+  UpdateTopMargin();
 }
 
 void Indicator::SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool forceUpdate )
@@ -647,6 +680,7 @@ void Indicator::SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool
     }
 
     mVisible = visibleMode;
+    UpdateTopMargin();
 
     if( mForegroundRenderer && mForegroundRenderer.GetTextures().GetTexture( 0u ) )
     {
@@ -724,6 +758,7 @@ bool Indicator::OnTouched(Dali::Actor indicator, const Dali::TouchEvent& touchEv
         break;
 
         case Dali::PointState::UP:
+        case Dali::PointState::INTERRUPTED:
         {
           IpcDataEvMouseUp ipcUp( touchEvent.time );
           mServerConnection->SendEvent( OP_EV_MOUSE_UP, &ipcUp, sizeof(ipcUp) );
@@ -844,6 +879,7 @@ void Indicator::Resize( int width, int height )
     mIndicatorContentActor.SetSize( mImageWidth, mImageHeight );
     mIndicatorActor.SetSize( mImageWidth, mImageHeight );
     mEventActor.SetSize(mImageWidth, mImageHeight);
+    UpdateTopMargin();
   }
 }
 
@@ -982,6 +1018,16 @@ void Indicator::LoadPixmapImage( Ecore_Ipc_Event_Server_Data *epcEvent )
   }
 }
 
+void Indicator::UpdateTopMargin()
+{
+  int newMargin = (mVisible == Dali::Window::VISIBLE && mOpacityMode == Dali::Window::OPAQUE) ? mImageHeight : 0;
+  if (mTopMargin != newMargin)
+  {
+    mTopMargin = newMargin;
+    mAdaptor->IndicatorSizeChanged( mTopMargin );
+  }
+}
+
 void Indicator::UpdateVisibility()
 {
   if( CheckVisibleState() )
@@ -1063,6 +1109,7 @@ void Indicator::CreateNewPixmapImage()
     mIndicatorContentActor.SetSize( mImageWidth, mImageHeight );
     mIndicatorActor.SetSize( mImageWidth, mImageHeight );
     mEventActor.SetSize( mImageWidth, mImageHeight );
+    UpdateTopMargin();
   }
   else
   {
@@ -1276,7 +1323,7 @@ void Indicator::DataReceived( void* event )
       DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_UPDATE\n" );
       if( mIsShowing )
       {
-        //mAdaptor->RequestUpdateOnce();
+        mAdaptor->RequestUpdateOnce();
       }
       break;
     }
@@ -1284,7 +1331,7 @@ void Indicator::DataReceived( void* event )
     {
       DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_UPDATE_DONE [%d]\n", epcEvent->response );
       // epcEvent->response == display buffer #
-      //UpdateImageData( epcEvent->response );
+      UpdateImageData( epcEvent->response );
       break;
     }
     case OP_SHM_REF0: