[dali_1.3.41] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / control-devel.h
1 #ifndef DALI_TOOLKIT_CONTROL_DEVEL_H
2 #define DALI_TOOLKIT_CONTROL_DEVEL_H
3
4 /*
5  * Copyright (c) 2018 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 // EXTERNAL INCLUDES
21 #include <dali/devel-api/adaptor-framework/input-method-context.h>
22
23 // INTERNAL INCLUDES
24 #include <dali-toolkit/public-api/controls/control.h>
25 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
26 #include <dali-toolkit/devel-api/layouting/layout-item.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 class TransitionData;
35
36 namespace Visual
37 {
38 class Base;
39 }
40
41 namespace DevelControl
42 {
43
44 enum State
45 {
46   NORMAL,
47   FOCUSED,
48   DISABLED
49 };
50
51 namespace Property
52 {
53
54 enum
55 {
56   STYLE_NAME        = Control::Property::STYLE_NAME,
57   BACKGROUND_COLOR  = Control::Property::BACKGROUND_COLOR,
58   BACKGROUND_IMAGE  = Control::Property::BACKGROUND_IMAGE,
59   KEY_INPUT_FOCUS   = Control::Property::KEY_INPUT_FOCUS,
60   BACKGROUND        = Control::Property::BACKGROUND,
61   MARGIN            = Control::Property::MARGIN,
62   PADDING           = Control::Property::PADDING,
63
64   /**
65    * @brief Displays a tooltip when the control is hovered over.
66    * @details Name "tooltip", type Property::STRING, Property::ARRAY or Property::MAP.
67    *          If Property::STRING, then the style specified in the stylesheet is used.
68    *          If Property::ARRAY of Visuals then all are displayed in one row.
69    *          If Property::MAP, then it should be a map of Tooltip properties.
70    * @note The tooltip is only activated if display content is received, i.e. a string (text) or visual to show.
71    *       The rest is used to just build up the style of the tooltip (i.e. background, text color/point-size etc.)
72    * @note When retrieved, a Property::MAP is returned.
73    * @see Toolkit::Tooltip
74    */
75   TOOLTIP = PADDING + 1,
76
77   /**
78    * @brief The current state of the control.
79    * @details Name "state", type DevelControl::State ( Property::INTEGER ) or Property::STRING
80    *
81    * @see DevelControl::State
82    */
83   STATE = PADDING + 2,
84
85   /**
86    * @brief The current sub state of the control.
87    * @details Name "subState", type Property::INTEGER or Property::STRING. The enumeration used is dependent on the derived control.
88    *
89    * @see DevelControl::State
90    */
91   SUB_STATE = PADDING + 3,
92
93   /**
94    * @brief The actor ID of the left focusable control.
95    * @details Name "leftFocusableActorId", type Property::INTEGER.
96    *
97    */
98   LEFT_FOCUSABLE_ACTOR_ID = PADDING + 4,
99
100   /**
101    * @brief The actor ID of the right focusable control.
102    * @details Name "rightFocusableActorId", type Property::INTEGER.
103    *
104    */
105   RIGHT_FOCUSABLE_ACTOR_ID = PADDING + 5,
106
107   /**
108    * @brief The actor ID of the up focusable control.
109    * @details Name "upFocusableActorId", type Property::INTEGER.
110    *
111    */
112   UP_FOCUSABLE_ACTOR_ID = PADDING + 6,
113
114   /**
115    * @brief The actor ID of the down focusable control.
116    * @details Name "downFocusableActorId", type Property::INTEGER.
117    *
118    */
119   DOWN_FOCUSABLE_ACTOR_ID = PADDING + 7
120 };
121
122 } // namespace Property
123
124 /**
125  * @brief Register a visual by Property Index.
126  *
127  * @param[in] control The control
128  * @param[in] index The Property index of the visual, used to reference visual
129  * @param[in] visual The visual to register
130  *
131  * @note Derived class should not call visual.SetOnStage(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
132  *       Use below API with enabled set to false if derived class wishes to control when visual is staged.
133  * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
134  * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
135  */
136 DALI_TOOLKIT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual );
137
138 /**
139  * @brief Register a visual by Property Index with a depth index.
140  *
141  * @param[in] control The control
142  * @param[in] index The Property index of the visual, used to reference visual
143  * @param[in] visual The visual to register
144  * @param[in] depthIndex The visual's depth-index is set to this
145  *
146  * @note Derived class should not call visual.SetOnStage(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
147  *       Use below API with enabled set to false if derived class wishes to control when visual is staged.
148  *
149  * @see Visual::Base::GetDepthIndex()
150  * @see Visual::Base::SetDepthIndex()
151  */
152 DALI_TOOLKIT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, int depthIndex );
153
154 /**
155  * @brief Register a visual by Property Index with the option of enabling/disabling it.
156  *
157  * @param[in] control The control
158  * @param[in] index The Property index of the visual, used to reference visual
159  * @param[in] visual The visual to register
160  * @param[in] enabled false if derived class wants to control when visual is set on stage.
161  *
162  * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
163  * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
164  *
165  * @see EnableVisual()
166  */
167 DALI_TOOLKIT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
168
169 /**
170  * @brief Register a visual by Property Index with a depth index with the option of enabling/disabling it.
171  *
172  * @param[in] control The control
173  * @param[in] index The Property index of the visual, used to reference visual
174  * @param[in] visual The visual to register
175  * @param[in] enabled false if derived class wants to control when visual is set on stage.
176  * @param[in] depthIndex The visual's depth-index is set to this
177  *
178  * @see EnableVisual()
179  * @see Visual::Base::GetDepthIndex()
180  * @see Visual::Base::SetDepthIndex()
181  */
182 DALI_TOOLKIT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex );
183
184 /**
185  * @brief Erase the entry matching the given index from the list of registered visuals
186  *
187  * @param[in] control The control
188  * @param[in] index The Property index of the visual, used to reference visual
189  */
190 DALI_TOOLKIT_API void UnregisterVisual( Internal::Control& control, Dali::Property::Index index );
191
192 /**
193  * @brief Retrieve the visual associated with the given property index.
194  *
195  * @param[in] control The control
196  * @param[in] index The Property index of the visual.
197  * @return The registered visual if exist, otherwise empty handle.
198  * @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
199  */
200 DALI_TOOLKIT_API Toolkit::Visual::Base GetVisual( const Internal::Control& control, Dali::Property::Index index );
201
202 /**
203  * @brief Sets the given visual to be displayed or not when parent staged.
204  *
205  * @param[in] control The control
206  * @param[in] index The Property index of the visual
207  * @param[in] enable flag to set enabled or disabled.
208  */
209 DALI_TOOLKIT_API void EnableVisual( Internal::Control& control, Dali::Property::Index index, bool enable );
210
211 /**
212  * @brief Queries if the given visual is to be displayed when parent staged.
213  *
214  * @param[in] control The control
215  * @param[in] index The Property index of the visual
216  * @return bool whether visual is enabled or not
217  */
218 DALI_TOOLKIT_API bool IsVisualEnabled( const Internal::Control& control, Dali::Property::Index index );
219
220
221 /**
222  * @brief Add a transition effect on the control to the given animation
223  *
224  * Only generates an animator if the properties described in the transition
225  * data are staged (e.g. the visual is Enabled and the control is on stage).
226  * Otherwise the target values are stored, and will get set onto the properties
227  * when the visual is next staged.
228  *
229  * @param[in] control The control
230  * @param[in] animation The Animation to add valid transitions to
231  * @param[in] transitionData The transition data describing the effect to create
232  */
233 DALI_TOOLKIT_API void AddTransitions( Internal::Control& control,
234                                       Dali::Animation animation,
235                                       const Toolkit::TransitionData& transitionData );
236
237 /**
238  * @brief Create a transition effect on the control.
239  *
240  * Only generates an animation if the properties described in the transition
241  * data are staged (e.g. the visual is Enabled and the control is on stage).
242  * Otherwise the target values are stored, and will get set onto the properties
243  * when the visual is next staged.
244  *
245  * @param[in] control The control
246  * @param[in] transitionData The transition data describing the effect to create
247  * @return A handle to an animation defined with the given effect, or an empty
248  * handle if no properties match.
249  */
250 DALI_TOOLKIT_API Dali::Animation CreateTransition( Internal::Control& control,
251                                                    const Toolkit::TransitionData& transitionData );
252
253 /**
254  * @brief Perform an action on a visual registered to this control.
255  *
256  * Visuals will have actions, this API is used to perform one of these actions with the given attributes.
257  *
258  * @param[in] control The control.
259  * @param[in] visualIndex The Property index of the visual.
260  * @param[in] actionId The action to perform.  See Visual to find supported actions.
261  * @param[in] attributes Optional attributes for the action.
262  */
263 DALI_TOOLKIT_API void DoAction( Control& control, Dali::Property::Index visualIndex, Dali::Property::Index actionId, const Dali::Property::Value attributes );
264
265 /**
266  * @brief Set input method context.
267  *
268  * @param[in] control The control.
269  * @param[in] inputMethodContext The input method context.
270  */
271 DALI_TOOLKIT_API void SetInputMethodContext( Internal::Control& control, InputMethodContext& inputMethodContext );
272
273 /*
274  * @brief Get the layout associated with this control, if any.
275  *
276  * @return A handle to the layout, or empty.
277  */
278 DALI_TOOLKIT_API Toolkit::LayoutItem GetLayout( Internal::Control& control );
279
280 /*
281  * @brief Get the layout associated with a control, if any.
282  *
283  * @return A handle to the layout, or empty.
284  */
285 DALI_TOOLKIT_API Toolkit::LayoutItem GetLayout( Control control );
286
287 /**
288  * @brief Set the layout on this control.
289  *
290  * @param[in] control The internal Control to set the layout on
291  * @param[in] layout Pointer to the layout
292  */
293 DALI_TOOLKIT_API void SetLayout( Internal::Control& control, Toolkit::LayoutItem layout );
294
295 /**
296  * @brief Set the layout on a control.
297  *
298  * @param[in] control The Control to set the layout on
299  * @param[in] layout Pointer to the layout
300  */
301 DALI_TOOLKIT_API void SetLayout( Control control, Toolkit::LayoutItem layout );
302
303 /**
304  * @brief Request the control layout.
305  *
306  * @param[in] control The internal Control to request the layout of
307  */
308 DALI_TOOLKIT_API void RequestLayout( Internal::Control& control );
309
310 /**
311  * @brief Set whether the control should have a layout
312  * @param[in] control The Control to set the behaviour on
313  * @param[in] layoutingRequired true if the control should have a layout
314  */
315 DALI_TOOLKIT_API void SetLayoutingRequired( Control control, bool layoutingRequired );
316
317 /**
318  * @brief Check if the control has been set to require layouting
319  * @param[in] control The Control to query
320  * @return true if the control needs layouting
321  */
322 DALI_TOOLKIT_API bool IsLayoutingRequired( Control control );
323
324 } // namespace DevelControl
325
326 } // namespace Toolkit
327
328 } // namespace Dali
329
330 #endif // DALI_TOOLKIT_CONTROL_DEVEL_H