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