[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / effects-view / effects-view.h
1 #ifndef DALI_TOOLKIT_EFFECTS_VIEW_H
2 #define DALI_TOOLKIT_EFFECTS_VIEW_H
3
4 /*
5  * Copyright (c) 2022 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 #include <dali/public-api/images/pixel.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/controls/control.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Internal DALI_INTERNAL
32 {
33 class EffectsView;
34
35 } // namespace DALI_INTERNAL
36
37 /**
38  * EffectsView: Applies an effect to a tree of actors
39  *
40  * Example usage: Applying an emboss effect
41  * ...
42  * EffectsView effectsView = EffectsView::New( Toolkit::EffectsView::EMBOSS );
43  *
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 );
48  *
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 );
53  *
54  * // Render once
55  * effectsView.SetRefreshOnDemand( true );
56  *
57  * // optionally set a clear color
58  * effectsView.SetBackgroundColor( Vector4( 0.0f, 0.0f, 0.0f, 0.0f ) );
59  */
60 class DALI_TOOLKIT_API EffectsView : public Control
61 {
62 public:
63   enum EffectType
64   {
65     DROP_SHADOW,
66     EMBOSS,
67     INVALID_TYPE
68   };
69
70   /**
71    * @brief The start and end property ranges for this control.
72    */
73   enum PropertyRange
74   {
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
77
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
80   };
81
82   /**
83    * @brief An enumeration of properties belonging to the EffectsView class.
84    */
85   struct Property
86   {
87     enum
88     {
89       // Event side properties
90       EFFECT_SIZE = PROPERTY_START_INDEX, ///< name "effectSize", type INTEGER
91
92       // Animatable properties
93       EFFECT_OFFSET = ANIMATABLE_PROPERTY_START_INDEX, ///< name "effectOffset", type VECTOR3
94       EFFECT_COLOR,                                    ///< name "effectColor", type VECTOR4
95     };
96   };
97
98 public:
99   /**
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.
103    */
104   static EffectsView New(EffectType type);
105
106   /**
107    * Create an uninitialized EffectsView. Only derived versions can be instantiated.
108    * Calling member functions with an uninitialized Dali::Object is not allowed.
109    */
110   EffectsView();
111
112   /**
113    * Copy constructor.
114    * @param[in] handle to copy from
115    */
116   EffectsView(const EffectsView& handle);
117
118   /**
119    * Assignment operator.
120    * @param[in] handle to copy from
121    * @return reference to this
122    */
123   EffectsView& operator=(const EffectsView& handle);
124
125   /**
126    * Move constructor.
127    * @param[in] rhs to move from
128    */
129   EffectsView(EffectsView&& rhs);
130
131   /**
132    * Move assignment operator.
133    * @param[in] rhs to move from
134    * @return reference to this
135    */
136   EffectsView& operator=(EffectsView&& rhs);
137
138   /**
139    * Downcast an Object handle to EffectsView. If handle points to a EffectsView the
140    * downcast produces a valid handle. If not the returned handle is left uninitialized.
141    * @param[in] handle Handle to an object
142    * @return handle to a EffectsView or an uninitialized handle
143    */
144   static EffectsView DownCast(BaseHandle handle);
145
146   /**
147    * @brief Destructor
148    *
149    * This is non-virtual since derived Handle types must not contain data or virtual methods.
150    */
151   ~EffectsView();
152
153 public:
154   /**
155    * Get the effect type
156    * @return The type of effect performed by the EffectView. A member of the EffectType enumeration.
157    */
158   EffectType GetType() const;
159
160   /**
161    * Refresh/Redraw the effect
162    */
163   void Refresh();
164
165   /**
166    * Set refresh mode
167    * @param[in] onDemand Set true to enable on demand rendering, call Refresh() whenever a render is required.
168    *                     Set false to render each frame. (EffectsView refresh mode is set to continuous by default).
169    */
170   void SetRefreshOnDemand(bool onDemand);
171
172   /**
173     * Set the pixel format for the output
174     * @param[in] pixelFormat The pixel format for the output
175     */
176   void SetPixelFormat(Pixel::Format pixelFormat);
177
178   /**
179     * Set background color for the view. The background will be filled with this color.
180     * @param[in] color The background color.
181     */
182   void SetBackgroundColor(const Vector4& color);
183
184   /**
185     * Get the background color.
186     * @return The background color.
187     */
188   Vector4 GetBackgroundColor() const;
189
190 public: // Not intended for application developers
191   /**
192    * Creates a handle using the Toolkit::Internal implementation.
193    * @param[in]  implementation  The Control implementation.
194    */
195   DALI_INTERNAL EffectsView(Internal::EffectsView& implementation);
196
197   /**
198    * Allows the creation of this Control from an Internal::CustomActor pointer.
199    * @param[in]  internal  A pointer to the internal CustomActor.
200    */
201   explicit DALI_INTERNAL EffectsView(Dali::Internal::CustomActor* internal);
202
203 }; // class EffectsView
204
205 } // namespace Toolkit
206
207 } // namespace Dali
208
209 #endif // DALI_TOOLKIT_EFFECTS_VIEW_H