1 #ifndef DALI_TOOLKIT_SUPER_BLUR_VIEW_H
2 #define DALI_TOOLKIT_SUPER_BLUR_VIEW_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/rendering/texture.h>
25 #include <dali-toolkit/public-api/controls/control.h>
31 namespace Internal DALI_INTERNAL
37 * @brief SuperBlurView accepts an image as input, and displays/animates it with various blur strength.
41 * SuperBlurView blurView = SuperBlurView::New( blurLevels );\n
42 * blurView.SetProperty( Actor::Property::SIZE, size ); // it is important to set the display size before set the input image!!
43 * Stage::GetCurrent().Add(blurView);\n
45 * // Set the input image
46 * blurView.SetProperty( SuperBlurView::Property::IMAGE_URL, url );\n
48 * // animate the strength of the blur - this can fade between no blur and full blur. .\n
49 * Animation blurAnimation = Animation::New( ... );\n
50 * blurAnimation.AnimateTo( Property( blurView, blurView.GetBlurStrengthPropertyIndex() ), ... );\n
51 * blurAnimation.Play();\n
53 class DALI_TOOLKIT_API SuperBlurView : public Control
57 * @brief The start and end property ranges for this control.
61 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
62 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
66 * @brief An enumeration of properties belonging to the SuperBlurView class.
72 IMAGE_URL = PROPERTY_START_INDEX, ///< name "imageUrl", @see SetTexture, type String
77 * @brief Signal type for notifications.
79 typedef Signal<void(SuperBlurView source)> SuperBlurViewSignal;
82 * @brief Creates an empty SuperBlurView handle.
87 * @brief Create an initialized SuperBlurView.
89 * @param[in] blurLevels The final blur strength level. It decides how many filtering passes are used to create the group of blurred textures.
90 * @return A handle to a newly allocated Dali resource
92 static SuperBlurView New(unsigned int blurLevels);
95 * @brief Copy constructor.
97 * Creates another handle that points to the same real object.
98 * @param[in] handle the handle to copy from
100 SuperBlurView(const SuperBlurView& handle);
103 * @brief Assignment operator.
105 * Changes this handle to point to another real object.
106 * @param[in] rhs the handle to copy from
107 * @return a reference to this
109 SuperBlurView& operator=(const SuperBlurView& rhs);
114 * This is non-virtual since derived Handle types must not contain data or virtual methods.
119 * @brief Downcast an Object handle to SuperBlurView.
121 * If handle points to a SuperBlurView, the downcast produces valid handle.
122 * If not, the returned handle is left uninitialized.
123 * @param[in] handle Handle to an object
124 * @return handle to a SuperBlurView or an uninitialized handle
126 static SuperBlurView DownCast(BaseHandle handle);
129 * @brief Sets a custom texture to be blurred.
131 * @param[in] texture The texture that the user wishes to blur
133 void SetTexture(Texture texture);
136 * @brief Get the index of the property that can be used to fade the blur in / out.
138 * This is the overall strength of the blur.
139 * 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.
140 * @return Index of the property that can be used to fade the blur in / out
142 Dali::Property::Index GetBlurStrengthPropertyIndex() const;
145 * @brief Set the blur strength to display the texture.
147 * @param[in] blurStrength The blur strength used to display the texture.
149 void SetBlurStrength(float blurStrength);
152 * @brief Get the current blur strength.
154 * @return The current blur strength
156 float GetCurrentBlurStrength() const;
159 * @brief Connect to this signal to be notified when the all the blurs have completed.
161 * @return The BlurFinished signal
163 SuperBlurViewSignal& BlurFinishedSignal();
166 * @brief Get the blurred texture.
168 * Should wait for the BlurFinishedSignal before calling this method.
169 * @param[in] level Indicate which blurred texture to get, must be a value between 1 and blurLevels
170 * @return The level-th blurred texture
172 Texture GetBlurredTexture(unsigned int level);
174 public: // Not intended for application developers
176 * @brief Creates a handle using the Toolkit::Internal implementation.
178 * @param[in] implementation The Control implementation.
180 DALI_INTERNAL SuperBlurView(Internal::SuperBlurView& implementation);
183 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
185 * @param[in] internal A pointer to the internal CustomActor.
187 explicit DALI_INTERNAL SuperBlurView(Dali::Internal::CustomActor* internal);
190 } // namespace Toolkit
194 #endif /* DALI_TOOLKIT_SUPER_BLUR_VIEW_H */