[3.0] Replaced deprecated touch api in indicator
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / common / ecore-indicator-impl.h
index 5f2b9be..544e92b 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_ECORE_INDICATOR_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/animation/animation.h>
-#include <dali/public-api/actors/image-actor.h>
 #include <dali/public-api/events/pan-gesture.h>
 #include <dali/public-api/events/pan-gesture-detector.h>
-#include <dali/devel-api/rendering/renderer.h>
+#include <dali/public-api/rendering/renderer.h>
+#include <dali/public-api/images/image.h>
+#include <dali/public-api/object/any.h>
 
 // INTERNAL INCLUDES
 #include <base/interfaces/indicator-interface.h>
+#include <native-image-source.h>
 #include <indicator-buffer.h>
 #include <ecore-server-connection.h>
 #include <shared-file.h>
@@ -62,6 +64,16 @@ public:
     CONNECTED
   };
 
+  /**
+   * copied from ecore_evas_extn_engine.h
+   */
+  enum BufferType
+  {
+    BUFFER_TYPE_SHM = 0,        ///< shared memory-based buffer backend
+    BUFFER_TYPE_DRI2_PIXMAP,    ///< dri2 pixmap-based buffer backend
+    BUFFER_TYPE_EVASGL_PIXMAP,  ///< pixmap backend for Evas GL only (DEPRECATED)
+    BUFFER_TYPE_GL_PIXMAP,      ///< double buffered GL pixmap backend
+  };
 
 protected:
   /**
@@ -184,6 +196,12 @@ public:  // Dali::Internal::Adaptor::IndicicatorInterface
    */
   virtual bool SendMessage( int messageDomain, int messageId, const void *data, int size );
 
+  /**
+   * Update native indicator image
+   * @param[in] source Native indicator image source
+   */
+  void UpdateIndicatorImage( Dali::Any source );
+
 private:
   /**
    * Initialize the indicator actors
@@ -196,13 +214,25 @@ private:
   Dali::Geometry CreateBackgroundGeometry();
 
   /**
+   * Set the texture to be rendered as indicator foreground
+   * @param[in] texture The foreground texture.
+   */
+  void SetForegroundImage( Dali::Texture texture );
+
+  /**
+   * Set the texture to be rendered as indicator foreground
+   * @param[in] image The foreground image.
+   */
+  void SetForegroundNativeImage( Dali::Image image );
+
+  /**
    * Touch event callback.
-   * It should pass the valid touch event to indicator server
+   * It should pass the valid touch data to indicator server
    *
    * @param[in] indicator  The indicator actor that was touched
-   * @param[in] touchEvent The touch event
+   * @param[in] touchData The touch data
    */
-  bool OnTouched(Dali::Actor indicator, const TouchEvent& touchEvent);
+  bool OnTouched(Dali::Actor indicator, const TouchData& touchData);
 
   /**
    * Pan gesture callback.
@@ -217,9 +247,9 @@ private:
    * Touch event callback on stage.
    * If stage is touched, hide showing indicator image
    *
-   * @param[in] touchEvent The touch event
+   * @param[in] touchEvent The touch data
    */
-  void OnStageTouched(const Dali::TouchEvent& touchEvent);
+  void OnStageTouched(const Dali::TouchData& touchData);
 
   /**
    * Connect to the indicator service
@@ -274,6 +304,22 @@ private:
   void LoadPixmapImage( Ecore_Ipc_Event_Server_Data *epcEvent );
 
   /**
+   * Update top margin of the stage as much as indicator height
+   */
+  void UpdateTopMargin();
+
+  /**
+   * Setup native indicator image
+   * @param[in] epcEvent The event containing the image data information
+   */
+  void SetupNativeIndicatorImage( Ecore_Ipc_Event_Server_Data *epcEvent );
+
+  /**
+   * Update the visibility and position of the actors
+   */
+  void UpdateVisibility();
+
+  /**
    * Inform dali that the indicator data has been updated.
    * @param[in] bufferNumber The shared file number
    */
@@ -330,6 +376,11 @@ private:
    */
   void OnAnimationFinished( Dali::Animation& animation );
 
+  /**
+   * Set up native indicator image
+   */
+  void SetupNativeIndicatorImage();
+
 private: // Implementation of ServerConnection::Observer
   /**
    * @copydoc Dali::Internal::Adaptor::ServerConnection::Observer::DataReceived()
@@ -380,15 +431,15 @@ private:
 
   Dali::Geometry                   mTranslucentGeometry; ///< Geometry used for rendering the translucent background
   Dali::Geometry                   mSolidGeometry;       ///< Geometry used for rendering the opaque background
-  Dali::Material                   mBackgroundMaterial;  ///< Material used for rendering the background
+  Dali::Shader                     mBackgroundShader;    ///< Shader used for rendering the background
 
   IndicatorBufferPtr               mIndicatorBuffer;     ///< class which handles indicator rendering
   PixmapId                         mPixmap;              ///< Pixmap including indicator content
-  Dali::Image                      mImage;               ///< Image created from mIndicatorBuffer
-  Dali::ImageActor                 mIndicatorImageActor; ///< Actor created from mImage
+  Dali::NativeImageSourcePtr       mNativeImageSource;
+  Dali::Renderer                   mForegroundRenderer;  ///< Renderer renders the indicator foreground
+  Dali::Renderer                   mBackgroundRenderer;  ///< Renderer renders the indicator background
 
-  Dali::Actor                      mIndicatorImageContainerActor; ///< Actor container for image and background
-  Dali::Actor                      mBackgroundActor;     ///< Actor for background
+  Dali::Actor                      mIndicatorContentActor; ///< Actor container for image and background
   Dali::Actor                      mIndicatorActor;      ///< Handle to topmost indicator actor
   Dali::Actor                      mEventActor;          ///< Handle to event
   Dali::PanGestureDetector         mPanDetector;         ///< Pan detector to find flick gesture for hidden indicator
@@ -418,6 +469,14 @@ private:
 
   int                              mCurrentSharedFile;   ///< Current shared file number
   SharedFileInfo                   mSharedFileInfo[SHARED_FILE_NUMBER];    ///< Table to store shared file info
+
+  BufferType                       mSharedBufferType;    ///< Shared buffer type which is used to render indicator
+
+  struct Impl; ///< Contains Ecore specific information
+  Impl* mImpl; ///< Created on construction and destroyed on destruction.
+
+  bool                             mBackgroundVisible;   ///< Indicate whether background is visible
+  int                              mTopMargin;   ///< Top margin of the stage for indicator
 };
 
 } // Adaptor