1 #ifndef DALI_TOOLKIT_EFFECTS_VIEW_H
2 #define DALI_TOOLKIT_EFFECTS_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/images/pixel.h>
25 #include <dali-toolkit/public-api/controls/control.h>
31 namespace Internal DALI_INTERNAL
35 } // namespace DALI_INTERNAL
38 * EffectsView: Applies an effect to a tree of actors
40 * Example usage: Applying an emboss effect
42 * EffectsView effectsView = EffectsView::New( Toolkit::EffectsView::EMBOSS );
44 * // set position and format
45 * effectsView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
46 * effectsView.SetProperty( Actor::Property::SIZE, Vector2( width, height) );
47 * effectsView.SetPixelFormat( Pixel::RGBA8888 );
49 * // set effect type and properties
50 * effectsView.SetProperty( effectsView.GetEffectSizePropertyIndex(), static_cast< float >( shadowSize ) );
51 * effectsView.SetProperty( effectsView.GetEffectOffsetPropertyIndex(), Vector3( shadowDistance.x, shadowDistance.y, 0.0f ) );
52 * effectsView.SetProperty( effectsView.GetEffectColorPropertyIndex(), shadowColor );
55 * effectsView.SetRefreshOnDemand( true );
57 * // optionally set a clear color
58 * effectsView.SetBackgroundColor( Vector4( 0.0f, 0.0f, 0.0f, 0.0f ) );
60 class DALI_TOOLKIT_API EffectsView : public Control
71 * @brief The start and end property ranges for this control.
75 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
76 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices @SINCE_1_0.0
78 ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX, ///< @SINCE_1_1.18
79 ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices, @SINCE_1_1.18
83 * @brief An enumeration of properties belonging to the EffectsView class.
89 // Event side properties
90 EFFECT_SIZE = PROPERTY_START_INDEX, ///< name "effectSize", type INTEGER
92 // Animatable properties
93 EFFECT_OFFSET = ANIMATABLE_PROPERTY_START_INDEX, ///< name "effectOffset", type VECTOR3
94 EFFECT_COLOR, ///< name "effectColor", type VECTOR4
100 * Create an EffectsView object with default configuration
101 * @param[in] type The type of effect to be performed by the EffectView.
102 * A member of the EffectType enumeration.
104 static EffectsView New(EffectType type);
107 * Create an uninitialized EffectsView. Only derived versions can be instantiated.
108 * Calling member functions with an uninitialized Dali::Object is not allowed.
115 EffectsView(const EffectsView& handle);
118 * Assignment operator.
120 EffectsView& operator=(const EffectsView& rhs);
123 * Downcast an Object handle to EffectsView. If handle points to a EffectsView the
124 * downcast produces a valid handle. If not the returned handle is left uninitialized.
125 * @param[in] handle Handle to an object
126 * @return handle to a EffectsView or an uninitialized handle
128 static EffectsView DownCast(BaseHandle handle);
133 * This is non-virtual since derived Handle types must not contain data or virtual methods.
139 * Get the effect type
140 * @return The type of effect performed by the EffectView. A member of the EffectType enumeration.
142 EffectType GetType() const;
145 * Refresh/Redraw the effect
151 * @param[in] onDemand Set true to enable on demand rendering, call Refresh() whenever a render is required.
152 * Set false to render each frame. (EffectsView refresh mode is set to continuous by default).
154 void SetRefreshOnDemand(bool onDemand);
157 * Set the pixel format for the output
158 * @param[in] pixelFormat The pixel format for the output
160 void SetPixelFormat(Pixel::Format pixelFormat);
163 * Set background color for the view. The background will be filled with this color.
164 * @param[in] color The background color.
166 void SetBackgroundColor(const Vector4& color);
169 * Get the background color.
170 * @return The background color.
172 Vector4 GetBackgroundColor() const;
174 public: // Not intended for application developers
176 * Creates a handle using the Toolkit::Internal implementation.
177 * @param[in] implementation The Control implementation.
179 DALI_INTERNAL EffectsView(Internal::EffectsView& implementation);
182 * Allows the creation of this Control from an Internal::CustomActor pointer.
183 * @param[in] internal A pointer to the internal CustomActor.
185 explicit DALI_INTERNAL EffectsView(Dali::Internal::CustomActor* internal);
187 }; // class EffectsView
189 } // namespace Toolkit
193 #endif // DALI_TOOLKIT_EFFECTS_VIEW_H