1 #ifndef __DALI_TOOLKIT_BUBBLE_EMMITER_H__
2 #define __DALI_TOOLKIT_BUBBLE_EMMITER_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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
11 // http://floralicense.org/license/
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.
21 * @addtogroup CAPI_DALI_FRAMEWORK
26 #include <dali/dali.h>
27 #include <dali-toolkit/public-api/controls/control.h>
29 namespace Dali DALI_IMPORT_API
35 namespace Internal DALI_INTERNAL
38 * BubbleEmitter implementation class
44 * BubbleEmitter is used to display lots of moving bubbles on the stage.
46 * This is done by applying BubbleEffect to multiple specifically created meshActors.
48 class BubbleEmitter : public Control
53 * Create an empty BubbleEmitter handle
63 * Create an initialized BubbleEmitter
64 * @param[in] winSize The size of the bubble moving area, usually the same size as the background image actor.
65 * @param[in] shapeImage The alpha channnel of this texture defines the bubble shape.
66 * @param[in] maximumNumberOfBubble The maximum number of bubble needed.
67 * @param[in] bubbleSizeRange The size range of the bubbles; x component is the low bound, and y component is the up bound.
68 * @return The initialized BubbleEmitter object.
70 static BubbleEmitter New( const Vector2& winSize,
72 unsigned int maximumNumberOfBubble,
73 const Vector2& bubbleSizeRange );
77 * Copy constructor. Creates another handle that points to the same real object
79 BubbleEmitter( const BubbleEmitter& handle );
82 * Assignment operator. Changes this handle to point to another real object
84 BubbleEmitter& operator=( const BubbleEmitter& rhs );
87 * Downcast an Object handle to SuperBlurView.
88 * If handle points to a BubbleEmitter, the downcast produces valid handle.
89 * If not, the returned handle is left uninitialized.
90 * @param[in] handle Handle to an object
91 * @return handle to a BubbleEmitter or an uninitialized handle
93 static BubbleEmitter DownCast( BaseHandle handle );
96 * Return the root actor of all bubbles, should then be added to stage.
97 * @return The bubble root actor.
102 * Set Background image.
103 * The bubbles pick color from this image with HSV values adjusted.
104 * @param[in] bgImage The background image which provide color to bubbles.
105 * @param[in] hsvDelta The hsv channel difference used to adjust the background image color.
106 * If set these vector as Vector3::Zero, original colors are used.
108 void SetBackground( Image bgImage, const Vector3& hsvDelta );
112 * The bubble mesh is a rectangular patch, but its displayed shape is decided by the alpha channel of the shape image.
113 * @param[in] shapeImage The image whose alpha channel defines the bubble shape.
115 void SetShapeImage( Image shapeImage );
118 * Set the scale factor applied to all the bubbles.
119 * @param [in] scale The scale factor applied on bubbles.
121 void SetBubbleScale( float scale );
124 * Set the density of the bubble.
125 * Ideally every bubble's moving track is controlled by different uniforms in BubbleEffect shaders.
126 * To increase the density, 'density' number of bubbles are sharing one group of uniforms, but with random offsets between these bubbles.
127 * The available density is one to nine. The default density is five.
128 * By set the density bigger than one, instead of emit one bubble each time, a 'density' number of bubbles are emitted.
129 * @param[in] density The density of the bubble.
131 void SetBubbleDensity( unsigned int density );
134 * Enable different blending mode for rendering
135 * @param[in] enable If false, the default blending function for RenderableActor is used.
137 void SetBlendMode( bool enable );
140 * Add a bubble movement to the animation.
141 * @param[in] animation The animation reference.
142 * By passing the animation into BubbleEmitter, the animation's duration and how many bubbles contained within this animation are freely decided in App.
143 * @param[in] emitPosition The start position of the bubble movement.
144 * @param[in] direction The direction used to constrain the bubble to move in an adjacent direction around it.
145 * @param[in] displacement The displacement used to bound the moving distance of the bubble.
147 void EmitBubble( Animation& animation, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement );
150 * Start an animation to enlarge every activated bubble's size and moving speed.
151 * @param[in] duration The duration of the animation
152 * @param[in] multiple The bubble size and moving speed will be increased gradually to multiple speed during the animation.
154 void StartExplosion( float duration, float multiple );
157 * Reset all the parameters controlling the bubbles after animation.
161 public: // Not intended for developer use
164 * Creates a handle using the Toolkit::Internal implementation.
165 * @param[in] implementation The Control implementation.
167 DALI_INTERNAL BubbleEmitter(Internal::BubbleEmitter& implementation);
170 * Allows the creation of this Control from an Internal::CustomActor pointer.
171 * @param[in] internal A pointer to the internal CustomActor.
173 DALI_INTERNAL BubbleEmitter(Dali::Internal::CustomActor* internal);
176 } // namespace Toolkit
182 #endif /* __DALI_TOOLKIT_BUBBLE_EMMITER_H__ */