[dali_2.1.20] 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) 2021 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 <dali/public-api/actors/actor.h>\r
23 #include <dali/public-api/adaptor-framework/timer.h>\r
24 #include <dali/public-api/animation/animation.h>\r
25 #include <dali/public-api/object/weak-handle.h>\r
26 #include <dali/public-api/signals/connection-tracker.h>\r
27 #include <vector>\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    * @brief Initilizes the bubble background\r
37    *\r
38    * @param parent The actor to add all the bubbles to\r
39    * @param scrollView If provided, does a parallax effect when scrolling using this scroll-view (optional)\r
40    */\r
41   void Initialize(Dali::Actor parent, Dali::Actor scrollView = Dali::Actor());\r
42 \r
43   /**\r
44    * @brief Plays the bubble animation\r
45    */\r
46   void PlayAnimation();\r
47 \r
48 private:\r
49   /**\r
50    * @brief Used by the timer to pause the animation\r
51    *\r
52    * @return Returns false to cancel the timer\r
53    */\r
54   bool PauseAnimation();\r
55 \r
56   /**\r
57    * @brief Initializes the background actors\r
58    *\r
59    * @param actor Actor which contains all the children\r
60    */\r
61   void InitializeBackgroundActors(Dali::Actor actor);\r
62 \r
63   /**\r
64    * Create background actors for the given layer\r
65    *\r
66    * @param[in] layer The layer to add the actors to\r
67    * @param[in] count The number of actors to generate\r
68    */\r
69   void AddBackgroundActors(Dali::Actor layer, int count);\r
70 \r
71 private:\r
72   using AnimationList = std::vector<Dali::Animation>;\r
73 \r
74   Dali::WeakHandle<Dali::Actor> mScrollView;                    ///< Weak handle to the scroll view used to apply a parallax effect when scrolling.\r
75   AnimationList                 mBackgroundAnimations;          ///< List of background bubble animations.\r
76   Dali::Timer                   mAnimationTimer;                ///< Timer used to turn off animation after a specific time period.\r
77   bool                          mBackgroundAnimsPlaying{false}; ///< Are background animations playing.\r
78 };\r
79 \r
80 #endif // DALI_DEMO_BUBBLE_ANIMATOR_H\r