[dali_1.0.39] Merge branch 'tizen'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / bubble-effect / bubble-emitter.h
1 #ifndef __DALI_TOOLKIT_BUBBLE_EMMITER_H__
2 #define __DALI_TOOLKIT_BUBBLE_EMMITER_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32   /**
33    * @brief BubbleEmitter implementation class.
34    */
35   class BubbleEmitter;
36 }
37
38 /**
39  * @brief BubbleEmitter is used to display lots of moving bubbles on the stage.
40  *
41  * This is done by applying BubbleEffect to multiple specifically created meshActors.
42  */
43 class DALI_IMPORT_API BubbleEmitter : public Control
44 {
45 public:
46
47   /**
48    * @brief Create an empty BubbleEmitter handle.
49    */
50   BubbleEmitter();
51
52   /**
53    * @brief Virtual destructor.
54    */
55   ~BubbleEmitter();
56
57   /**
58    * @brief Create an initialized BubbleEmitter.
59    *
60    * @param[in] winSize The size of the bubble moving area, usually the same size as the background image actor.
61    * @param[in] shapeImage The alpha channnel of this texture defines the bubble shape.
62    * @param[in] maximumNumberOfBubble The maximum number of bubble needed.
63    * @param[in] bubbleSizeRange The size range of the bubbles; x component is the low bound, and y component is the up bound.
64    * @return The initialized BubbleEmitter object.
65    */
66   static BubbleEmitter New( const Vector2& winSize,
67                             Image shapeImage,
68                             unsigned int maximumNumberOfBubble,
69                             const Vector2& bubbleSizeRange );
70
71
72   /**
73    * @brief Copy constructor.
74    *
75    * Creates another handle that points to the same real object
76    * @param[in] handle The handle to copy
77    */
78   BubbleEmitter( const BubbleEmitter& handle );
79
80   /**
81    * @brief Assignment operator.
82    *
83    * Changes this handle to point to another real object
84    * @param[in] rhs The object to point at
85    * @return A reference to this
86    */
87   BubbleEmitter& operator=( const BubbleEmitter& rhs );
88
89   /**
90    * @brief Downcast an Object handle to SuperBlurView.
91    *
92    * If handle points to a BubbleEmitter, the downcast produces valid handle.
93    * If not, the returned handle is left uninitialized.
94    * @param[in] handle Handle to an object
95    * @return handle to a BubbleEmitter or an uninitialized handle
96    */
97   static BubbleEmitter DownCast( BaseHandle handle );
98
99   /**
100    * @brief Return the root actor of all bubbles, should then be added to stage.
101    *
102    * @return The bubble root actor.
103    */
104   Actor GetRootActor();
105
106   /**
107    * @brief Set Background image.
108    *
109    * The bubbles pick color from this image with HSV values adjusted.
110    * @param[in] bgImage The background image which provide color to bubbles.
111    * @param[in] hsvDelta The hsv channel difference used to adjust the background image color.
112    *            If set these vector as Vector3::Zero, original colors are used.
113    */
114   void SetBackground( Image bgImage, const Vector3& hsvDelta );
115
116   /**
117    * @brief Set bubble shape.
118    *
119    * The bubble mesh is a rectangular patch, but its displayed shape is decided by the alpha channel of the shape image.
120    * @param[in] shapeImage The image whose alpha channel defines the bubble shape.
121    */
122   void SetShapeImage( Image shapeImage );
123
124   /**
125    * @brief Set the scale factor applied to all the bubbles.
126    *
127    * @param [in] scale The scale factor applied on bubbles.
128    */
129   void SetBubbleScale( float scale );
130
131   /**
132    * @brief Set the density of the bubble.
133    *
134    * Ideally every bubble's moving track is controlled by different uniforms in BubbleEffect shaders.
135    * To increase the density, 'density' number of bubbles are sharing one group of uniforms, but with random offsets between these bubbles.
136    * The available density is one to nine. The default density is five.
137    * By set the density bigger than one, instead of emit one bubble each time, a 'density' number of bubbles are emitted.
138    * @param[in] density The density of the bubble.
139    */
140   void SetBubbleDensity( unsigned int density );
141
142   /**
143    * @brief Enable different blending mode for rendering.
144    *
145    * @param[in] enable If false, the default blending function for RenderableActor is used.
146    */
147   void SetBlendMode( bool enable );
148
149   /**
150    * @brief Add a bubble movement to the animation.
151    *
152    * @param[in] animation The animation reference.
153    * By passing the animation into BubbleEmitter, the animation's duration and how many bubbles contained within this animation are freely decided in App.
154    * @param[in] emitPosition The start position of the bubble movement.
155    * @param[in] direction The direction used to constrain the bubble to move in an adjacent direction around it.
156    * @param[in] displacement The displacement used to bound the moving distance of the bubble.
157    */
158   void EmitBubble( Animation& animation, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement );
159
160   /**
161    * @brief Start an animation to enlarge every activated bubble's size and moving speed.
162    *
163    * @param[in] duration The duration of the animation
164    * @param[in] multiple The bubble size and moving speed will be increased gradually to multiple speed during the animation.
165    */
166   void StartExplosion( float duration, float multiple );
167
168   /**
169    * @brief Reset all the parameters controlling the bubbles after animation.
170    */
171   void Restore();
172
173 public: // Not intended for developer use
174
175   /**
176    * @brief Creates a handle using the Toolkit::Internal implementation.
177    *
178    * @param[in]  implementation  The Control implementation.
179    */
180   DALI_INTERNAL BubbleEmitter(Internal::BubbleEmitter& implementation);
181
182   /**
183    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
184    *
185    * @param[in]  internal  A pointer to the internal CustomActor.
186    */
187   explicit DALI_INTERNAL BubbleEmitter(Dali::Internal::CustomActor* internal);
188 };
189
190 } // namespace Toolkit
191
192 } // namespace Dali
193
194 #endif /* __DALI_TOOLKIT_BUBBLE_EMMITER_H__ */