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