homescreen benchmark can use buttons
[platform/core/uifw/dali-demo.git] / demo / dali-table-view.h
index c712a5b..c91f2fc 100644 (file)
@@ -32,7 +32,6 @@ typedef std::vector<Dali::Animation> AnimationList;
 typedef AnimationList::iterator AnimationListIter;
 typedef AnimationList::const_iterator AnimationListConstIter;
 
-
 /**
  * Example information
  *
@@ -97,6 +96,17 @@ public:
 
 private: // Application callbacks & implementation
 
+  static const unsigned int FOCUS_ANIMATION_ACTOR_NUMBER = 2; ///< The number of elements used to form the custom focus effect
+
+  /**
+   * Shape enum for create function
+   */
+  enum ShapeType
+  {
+    CIRCLE,
+    BUBBLE
+  };
+
   /**
    * Initialize application.
    *
@@ -126,16 +136,16 @@ private: // Application callbacks & implementation
   void Rotate( unsigned int degrees );
 
   /**
-   * Creates a tile for the main menu and toolbar.
+   * Creates a tile for the main menu.
    *
    * @param[in] name The unique name for this Tile
    * @param[in] title The text caption that appears on the Tile
    * @param[in] parentSize Tile's parent size.
-   * @param[in] color The color (including alpha) of the tiles contents.
+   * @param[in] position The tiles relative position within a page
    *
    * @return The Actor for the created tile.
    */
-  Dali::Actor CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, const Dali::Vector4& color );
+  Dali::Actor CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, Dali::Vector2& position );
 
   // Signal handlers
 
@@ -241,6 +251,50 @@ private: // Application callbacks & implementation
   void OnKeyEvent( const Dali::KeyEvent& event );
 
   /**
+   * Create a depth field background
+   *
+   * @param[in] bubbleLayer Add the graphics to this layer
+   */
+  void SetupBackground( Dali::Actor bubbleLayer );
+
+  /**
+   * Create background actors for the given layer
+   *
+   * @param[in] layer The layer to add the actors to
+   * @param[in] count The number of actors to generate
+   * @param[in] distanceField A array (pointer) to 2 distance field types to use
+   */
+  void AddBackgroundActors( Dali::Actor layer, int count, Dali::BufferImage* distanceField );
+
+  /**
+   * Create a bitmap with the specified shape and also output a distance field
+   *
+   * @param[in] shapeType The shape to generate
+   * @param[in] size The size of the bitmap to create
+   * @param[out] distanceFieldOut The return depth field alpha map
+   */
+  void CreateShapeImage( ShapeType shapeType, const Dali::Size& size, Dali::BufferImage& distanceFieldOut );
+
+  /**
+   * Generate a square bit pattern and depth field
+   *
+   * @param[in] size The size of the bitmap to create
+   * @param[out] imageOut The return bitmap
+   * @param[out] distanceFieldOut The return depth field alpha map
+   */
+  void GenerateSquare( const Dali::Size& size, std::vector<unsigned char>& distanceFieldOut );
+
+  /**
+   * Generate a circle bit pattern and depth field
+   *
+   * @param[in] size The size of the bitmap to create
+   * @param[out] imageOut The return bitmap
+   * @param[out] distanceFieldOut The return depth field alpha map
+   * @param[in] hollow Optional - Set to true for a thick circle outline without fill
+   */
+  void GenerateCircle( const Dali::Size& size, std::vector<unsigned char>& distanceFieldOut, bool hollow = false );
+
+  /**
    * Creates the logo.
    *
    * @param[in] imagePath The path to the image file to load
@@ -250,6 +304,28 @@ private: // Application callbacks & implementation
   Dali::Toolkit::ImageView CreateLogo( std::string imagePath );
 
   /**
+   * Timer handler for ending background animation
+   *
+   * @return Return value for timer handler
+   */
+  bool PauseBackgroundAnimation();
+
+  /**
+   * Pause all animations
+   */
+  void PauseAnimation();
+
+  /**
+   * Resume all animations
+   */
+  void PlayAnimation();
+
+  /**
+   * @brief Creates and sets up the custom effect used for the keyboard (and mouse) focus.
+   */
+  void CreateFocusEffect();
+
+  /**
    * Callback when the keyboard focus is going to be changed.
    *
    * @param[in] current The current focused actor
@@ -286,29 +362,54 @@ private: // Application callbacks & implementation
   */
  void OnButtonsPageRelayout( const Dali::Actor& actor );
 
+ /**
+  * @brief The is connected to the keyboard focus highlight actor, and called when it is placed on stage.
+  * @param[in] actor The actor that has been placed on stage.
+  */
+ void OnStageConnect( Dali::Actor actor );
+
+ /**
+  * @brief Callback called to set up background actors
+  *
+  * @param[in] actor The actor raising the callback
+  */
+ void InitialiseBackgroundActors( Dali::Actor actor );
+
 private:
 
   Dali::Application&              mApplication;              ///< Application instance.
-  Dali::Layer                     mBackgroundLayer;          ///< Background resides on a separate layer.
-  Dali::Toolkit::TableView        mRootActor;                ///< All content (excluding background is anchored to this Actor)
+  Dali::Toolkit::Control          mRootActor;                ///< All content (excluding background is anchored to this Actor)
   Dali::Animation                 mRotateAnimation;          ///< Animation to rotate and resize mRootActor.
   Dali::Animation                 mPressedAnimation;         ///< Button press scaling animation.
-  Dali::Layer                     mScrollViewLayer;          ///< ScrollView resides on a separate layer.
   Dali::Toolkit::ScrollView       mScrollView;               ///< ScrollView container (for all Examples)
   Dali::Toolkit::ScrollViewEffect mScrollViewEffect;         ///< Effect to be applied to the scroll view
   Dali::Toolkit::RulerPtr         mScrollRulerX;             ///< ScrollView X (horizontal) ruler
   Dali::Toolkit::RulerPtr         mScrollRulerY;             ///< ScrollView Y (vertical) ruler
   Dali::Actor                     mPressedActor;             ///< The currently pressed actor.
+  Dali::Timer                     mAnimationTimer;           ///< Timer used to turn off animation after a specific time period
   Dali::TapGestureDetector        mLogoTapDetector;          ///< To detect taps on the logo
   Dali::Toolkit::Popup            mVersionPopup;             ///< Displays DALi library version information
 
+  /**
+   * This struct encapsulates all data relevant to each of the elements used within the custom keyboard focus effect.
+   */
+  struct FocusEffect
+  {
+    Dali::Toolkit::ImageView        actor;                   ///< The parent keyboard focus highlight actor
+    Dali::Animation                 animation;               ///< The animation for the parent keyboard focus highlight actor
+  };
+  FocusEffect mFocusEffect[FOCUS_ANIMATION_ACTOR_NUMBER];    ///< The elements used to create the custom focus effect
+
   std::vector< Dali::Actor >      mPages;                    ///< List of pages.
+  AnimationList                   mBackgroundAnimations;     ///< List of background bubble animations
   ExampleList                     mExampleList;              ///< List of examples.
 
+  float                           mPageWidth;                ///< The width of a page within the scroll-view, used to calculate the domain
   int                             mTotalPages;               ///< Total pages within scrollview.
 
   bool                            mScrolling:1;              ///< Flag indicating whether view is currently being scrolled
   bool                            mSortAlphabetically:1;     ///< Sort examples alphabetically.
+  bool                            mBackgroundAnimsPlaying:1; ///< Are background animations playing
 
 };