[dali_2.0.3] Merge branch 'devel/master'
[platform/core/uifw/dali-demo.git] / shared / bubble-animator.h
1 #ifndef DALI_DEMO_BUBBLE_ANIMATOR_H\r
2 #define DALI_DEMO_BUBBLE_ANIMATOR_H\r
3 \r
4 /*\r
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
6  *\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  *\r
11  * http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  *\r
19  */\r
20 \r
21 // EXTERNAL INCLUDES\r
22 #include <vector>\r
23 #include <dali/public-api/actors/actor.h>\r
24 #include <dali/public-api/adaptor-framework/timer.h>\r
25 #include <dali/public-api/animation/animation.h>\r
26 #include <dali/public-api/object/weak-handle.h>\r
27 #include <dali/public-api/signals/connection-tracker.h>\r
28 \r
29 /**\r
30  * Creates and animates random sized bubbles\r
31  */\r
32 class BubbleAnimator : public Dali::ConnectionTracker\r
33 {\r
34 public:\r
35 \r
36   /**\r
37    * @brief Initilizes the bubble background\r
38    *\r
39    * @param parent The actor to add all the bubbles to\r
40    * @param scrollView If provided, does a parallax effect when scrolling using this scroll-view (optional)\r
41    */\r
42   void Initialize(Dali::Actor parent, Dali::Actor scrollView = Dali::Actor());\r
43 \r
44   /**\r
45    * @brief Plays the bubble animation\r
46    */\r
47   void PlayAnimation();\r
48 \r
49 private:\r
50 \r
51   /**\r
52    * @brief Used by the timer to pause the animation\r
53    *\r
54    * @return Returns false to cancel the timer\r
55    */\r
56   bool PauseAnimation();\r
57 \r
58   /**\r
59    * @brief Initializes the background actors\r
60    *\r
61    * @param actor Actor which contains all the children\r
62    */\r
63   void InitializeBackgroundActors(Dali::Actor actor);\r
64 \r
65   /**\r
66    * Create background actors for the given layer\r
67    *\r
68    * @param[in] layer The layer to add the actors to\r
69    * @param[in] count The number of actors to generate\r
70    */\r
71   void AddBackgroundActors(Dali::Actor layer, int count);\r
72 \r
73 private:\r
74 \r
75   using AnimationList = std::vector<Dali::Animation>;\r
76 \r
77   Dali::WeakHandle<Dali::Actor> mScrollView; ///< Weak handle to the scroll view used to apply a parallax effect when scrolling.\r
78   AnimationList mBackgroundAnimations; ///< List of background bubble animations.\r
79   Dali::Timer mAnimationTimer;   ///< Timer used to turn off animation after a specific time period.\r
80   bool mBackgroundAnimsPlaying{false}; ///< Are background animations playing.\r
81 };\r
82 \r
83 #endif // DALI_DEMO_BUBBLE_ANIMATOR_H\r