(SuperBlurView) Ensure the image can be set as a property
[platform/core/uifw/dali-toolkit.git] / capi / dali-toolkit / public-api / controls / super-blur-view / super-blur-view.h
1 #ifndef __DALI_TOOLKIT_SUPER_BLUR_VIEW_H__
2 #define __DALI_TOOLKIT_SUPER_BLUR_VIEW_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
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
10 //
11 //     http://floralicense.org/license/
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  * @addtogroup CAPI_DALI_TOOLKIT_SUPER_BLUR_VIEW_MODULE
22  * @{
23  */
24
25 // EXTERNAL INCLUDES
26
27 // INTERNAL INCLUDES
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 class SuperBlurView;
39 }
40
41 /**
42  * @brief SuperBlurView accepts an image as input, and displays/animates it with various blur strength.
43  * Usage example:-
44  *
45  *  // initialise\n
46  *  SuperBlurView blurView = SuperBlurView::New( blurLevels );\n
47  *  blurView.SetSize();  // it is important to set the display size before set the input image!!
48  *  Stage::GetCurrent().Add(blurView);\n
49  *
50  *  // Set the input image
51  *  Image image = Image::New(...);\n
52  *  blurView.SetImage(image);\n
53  *
54  *  // animate the strength of the blur - this can fade between no blur and full blur. .\n
55  *  Animation blurAnimation = Animation::New( ... );\n
56  *  blurAnimation.AnimateTo( Property( blurView, blurView.GetBlurStrengthPropertyIndex() ), ... );\n
57  *  blurAnimation.Play();\n
58  */
59 class SuperBlurView : public Control
60 {
61 public:
62
63   // Properties
64   static const Property::Index PROPERTY_IMAGE;     ///< name "image",    @see SetImage,    type MAP
65
66   /**
67    * @brief Signal type for notifications.
68    */
69   typedef SignalV2< void (SuperBlurView source) > SuperBlurViewSignal;
70
71   /**
72    * @brief Creates an empty SuperBlurView handle.
73    */
74   SuperBlurView();
75
76   /**
77    * @brief Create an initialized SuperBlurView.
78    *
79    * @param[in] blurLevels The final blur strength level. It decides how many filtering passes are used to create the group of blurred images.
80    * @return A handle to a newly allocated Dali resource
81    */
82   static SuperBlurView New( unsigned int blurLevels );
83
84   /**
85    * @brief Copy constructor.
86    *
87    * Creates another handle that points to the same real object.
88    * @param[in] handle the handle to copy from
89    */
90   SuperBlurView( const SuperBlurView& handle );
91
92   /**
93    * @brief Assignment operator.
94    *
95    * Changes this handle to point to another real object.
96    * @param[in] rhs the handle to copy from
97    * @return a reference to this
98    */
99   SuperBlurView& operator=( const SuperBlurView& rhs );
100
101   /**
102    * @brief Virtual destructor.
103    */
104   virtual ~SuperBlurView();
105
106   /**
107    * @brief Downcast an Object handle to SuperBlurView.
108    *
109    * If handle points to a SuperBlurView, the downcast produces valid handle.
110    * If not, the returned handle is left uninitialized.
111    * @param[in] handle Handle to an object
112    * @return handle to a SuperBlurView or an uninitialized handle
113    */
114   static SuperBlurView DownCast( BaseHandle handle );
115
116   /**
117    * @brief Sets a custom image to be blurred.
118    *
119    * @param[in] inputImage The image that the user wishes to blur
120    */
121   void SetImage(Image inputImage);
122
123   /**
124    * @brief Get the index of the property that can be used to fade the blur in / out.
125    *
126    * This is the overall strength of the blur.
127    * User can use this to animate the blur. A value of 0.0 is zero blur and 1.0 is full blur. Default is 0.0.
128    * @return Index of the property that can be used to fade the blur in / out
129    */
130   Property::Index GetBlurStrengthPropertyIndex() const;
131
132   /**
133    * @brief Set the blur strength to display the image.
134    *
135    * @param[in] blurStrength The blur strength used to display the image.
136    */
137   void SetBlurStrength( float blurStrength );
138
139   /**
140    * @brief Get the current blur strength.
141    *
142    * @return The current blur strength
143    */
144   float GetCurrentBlurStrength() const;
145
146   /**
147    * @brief Connect to this signal to be notified when the all the blurs have completed.
148    *
149    * @return The BlurFinished signal
150    */
151   SuperBlurViewSignal& BlurFinishedSignal();
152
153   /**
154    * @brief Get the blurred image.
155    *
156    * Should wait for the BlurFinishedSignal before calling this method.
157    * @param[in] level Indicate which blurred image to get, must be a value between 1 and  blurLevels
158    * @return The level-th blurred image
159    */
160   Image GetBlurredImage( unsigned int level );
161
162 public: // Not intended for application developers
163
164   /**
165    * @brief Creates a handle using the Toolkit::Internal implementation.
166    *
167    * @param[in]  implementation  The Control implementation.
168    */
169   DALI_INTERNAL SuperBlurView(Internal::SuperBlurView& implementation);
170
171   /**
172    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
173    *
174    * @param[in]  internal  A pointer to the internal CustomActor.
175    */
176   DALI_INTERNAL SuperBlurView(Dali::Internal::CustomActor* internal);
177
178 };
179
180 } // namespace Toolkit
181
182 } // namespace Dali
183
184
185 /**
186  * @}
187  */
188 #endif /* __DALI_TOOLKIT_SUPER_BLUR_VIEW_H__ */