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