[Tizen](ATSPI) squashed implementation
[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) 2019 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
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 class TransitionData;
34
35 namespace Visual
36 {
37 class Base;
38 }
39
40 namespace DevelControl
41 {
42
43 enum State
44 {
45   NORMAL,
46   FOCUSED,
47   DISABLED
48 };
49
50 namespace Property
51 {
52
53 enum
54 {
55   STYLE_NAME            = Control::Property::STYLE_NAME,
56   RESERVED_PROPERTY_01  = Control::Property::RESERVED_PROPERTY_01,
57   RESERVED_PROPERTY_02  = Control::Property::RESERVED_PROPERTY_02,
58   KEY_INPUT_FOCUS       = Control::Property::KEY_INPUT_FOCUS,
59   BACKGROUND            = Control::Property::BACKGROUND,
60   MARGIN                = Control::Property::MARGIN,
61   PADDING               = Control::Property::PADDING,
62
63   /**
64    * @brief Displays a tooltip when the control is hovered over.
65    * @details Name "tooltip", type Property::STRING, Property::ARRAY or Property::MAP.
66    *         If Property::STRING, then the style specified in the stylesheet is used.
67    *         If Property::ARRAY of Visuals then all are displayed in one row.
68    *         If Property::MAP, then it should be a map of Tooltip properties.
69    * @note The tooltip is only activated if display content is received, i.e. a string (text) or visual to show.
70    *         The rest is used to just build up the style of the tooltip (i.e. background, text color/point-size etc.)
71    * @note When retrieved, a Property::MAP is returned.
72    * @see Toolkit::Tooltip
73    */
74   TOOLTIP = PADDING + 1,
75
76   /**
77    * @brief The current state of the control.
78    * @details Name "state", type DevelControl::State ( Property::INTEGER ) or Property::STRING
79    *
80    * @see DevelControl::State
81    */
82   STATE = PADDING + 2,
83
84   /**
85    * @brief The current sub state of the control.
86    * @details Name "subState", type Property::INTEGER or Property::STRING. The numeration used is dependent on the derived control.
87    *
88    * @see DevelControl::State
89    */
90   SUB_STATE = PADDING + 3,
91
92   /**
93    * @brief The actor ID of the left focusable control.
94    * @details Name "leftFocusableActorId", type Property::INTEGER.
95    *
96    */
97   LEFT_FOCUSABLE_ACTOR_ID = PADDING + 4,
98
99   /**
100    * @brief The actor ID of the right focusable control.
101    * @details Name "rightFocusableActorId", type Property::INTEGER.
102    *
103    */
104   RIGHT_FOCUSABLE_ACTOR_ID = PADDING + 5,
105
106   /**
107    * @brief The actor ID of the up focusable control.
108    * @details Name "upFocusableActorId", type Property::INTEGER.
109    *
110    */
111   UP_FOCUSABLE_ACTOR_ID = PADDING + 6,
112
113   /**
114    * @brief The actor ID of the down focusable control.
115    * @details Name "downFocusableActorId", type Property::INTEGER.
116    *
117    */
118   DOWN_FOCUSABLE_ACTOR_ID = PADDING + 7,
119
120   /**
121    * @brief The name of object visible in accessibility tree.
122    * @details Name "accessibilityName", type Property::STRING.
123    */
124   ACCESSIBILITY_NAME,
125
126   /**
127    * @brief The description of object visible in accessibility tree.
128    * @details Name "accessibilityDescription", type Property::STRING.
129    */
130   ACCESSIBILITY_DESCRIPTON,
131
132   /**
133    * @brief Current translation domain for accessibility clients.
134    * @details Name "accessibilityTranslationDomain", type Property::STRING.
135    */
136   ACCESSIBILITY_TRANSLATION_DOMAIN,
137
138   /**
139    * @brief Role being performed in accessibility hierarchy.
140    * @details Name "accessibilityRole", type Property::INTEGER.
141    * @note Property is stored as INTEGER, however its interpretaton
142    * depend on enumeration Dali::Accessibility::Role and should be read and written
143    * with usage of enumerated values.
144    * @see Dali::Accessibility::Role
145    */
146   ACCESSIBILITY_ROLE,
147   /**
148    * @brief Mark of able to highlight object.
149    * @details Name "accessibilityHighlightable", type Property::BOOLEAN.
150    */
151   ACCESSIBILITY_HIGHLIGHTABLE,
152   /**
153    * @brief Set of accessibility attributes describing object in accessibility hierarchy
154    * @details Name "accessibilityAttributes", type Property::MAP
155    */
156   ACCESSIBILITY_ATTRIBUTES,
157
158   /**
159    * @brief Boolean flag describing object as animated
160    * @details Name "accessibilityAnimated", type Property::BOOLEAN
161    * @note Flag set to true will prevent BoundChanged accessibility signal from emiting
162    */
163   ACCESSIBILITY_ANIMATED
164 };
165
166 } // namespace Property
167
168 /**
169  * @brief Register a visual by Property Index.
170  *
171  * @param[in] control The control
172  * @param[in] index The Property index of the visual, used to reference visual
173  * @param[in] visual The visual to register
174  *
175  * @note Derived class should not call visual.SetOnStage(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
176  *       Use below API with enabled set to false if derived class wishes to control when visual is staged.
177  * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
178  * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
179  */
180 DALI_TOOLKIT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual );
181
182 /**
183  * @brief Register a visual by Property Index with a depth index.
184  *
185  * @param[in] control The control
186  * @param[in] index The Property index of the visual, used to reference visual
187  * @param[in] visual The visual to register
188  * @param[in] depthIndex The visual's depth-index is set to this
189  *
190  * @note Derived class should not call visual.SetOnStage(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
191  *       Use below API with enabled set to false if derived class wishes to control when visual is staged.
192  *
193  * @see Visual::Base::GetDepthIndex()
194  * @see Visual::Base::SetDepthIndex()
195  */
196 DALI_TOOLKIT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, int depthIndex );
197
198 /**
199  * @brief Register a visual by Property Index with the option of enabling/disabling it.
200  *
201  * @param[in] control The control
202  * @param[in] index The Property index of the visual, used to reference visual
203  * @param[in] visual The visual to register
204  * @param[in] enabled false if derived class wants to control when visual is set on stage.
205  *
206  * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
207  * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
208  *
209  * @see EnableVisual()
210  */
211 DALI_TOOLKIT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
212
213 /**
214  * @brief Register a visual by Property Index with a depth index with the option of enabling/disabling it.
215  *
216  * @param[in] control The control
217  * @param[in] index The Property index of the visual, used to reference visual
218  * @param[in] visual The visual to register
219  * @param[in] enabled false if derived class wants to control when visual is set on stage.
220  * @param[in] depthIndex The visual's depth-index is set to this
221  *
222  * @see EnableVisual()
223  * @see Visual::Base::GetDepthIndex()
224  * @see Visual::Base::SetDepthIndex()
225  */
226 DALI_TOOLKIT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex );
227
228 /**
229  * @brief Erase the entry matching the given index from the list of registered visuals
230  *
231  * @param[in] control The control
232  * @param[in] index The Property index of the visual, used to reference visual
233  */
234 DALI_TOOLKIT_API void UnregisterVisual( Internal::Control& control, Dali::Property::Index index );
235
236 /**
237  * @brief Retrieve the visual associated with the given property index.
238  *
239  * @param[in] control The control
240  * @param[in] index The Property index of the visual.
241  * @return The registered visual if exist, otherwise empty handle.
242  * @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
243  */
244 DALI_TOOLKIT_API Toolkit::Visual::Base GetVisual( const Internal::Control& control, Dali::Property::Index index );
245
246 /**
247  * @brief Sets the given visual to be displayed or not when parent staged.
248  *
249  * @param[in] control The control
250  * @param[in] index The Property index of the visual
251  * @param[in] enable flag to set enabled or disabled.
252  */
253 DALI_TOOLKIT_API void EnableVisual( Internal::Control& control, Dali::Property::Index index, bool enable );
254
255 /**
256  * @brief Queries if the given visual is to be displayed when parent staged.
257  *
258  * @param[in] control The control
259  * @param[in] index The Property index of the visual
260  * @return bool whether visual is enabled or not
261  */
262 DALI_TOOLKIT_API bool IsVisualEnabled( const Internal::Control& control, Dali::Property::Index index );
263
264
265 /**
266  * @brief Add a transition effect on the control to the given animation
267  *
268  * Only generates an animator if the properties described in the transition
269  * data are staged (e.g. the visual is Enabled and the control is on stage).
270  * Otherwise the target values are stored, and will get set onto the properties
271  * when the visual is next staged.
272  *
273  * @param[in] control The control
274  * @param[in] animation The Animation to add valid transitions to
275  * @param[in] transitionData The transition data describing the effect to create
276  */
277 DALI_TOOLKIT_API void AddTransitions( Internal::Control& control,
278                                       Dali::Animation animation,
279                                       const Toolkit::TransitionData& transitionData );
280
281 /**
282  * @brief Create a transition effect on the control.
283  *
284  * Only generates an animation if the properties described in the transition
285  * data are staged (e.g. the visual is Enabled and the control is on stage).
286  * Otherwise the target values are stored, and will get set onto the properties
287  * when the visual is next staged.
288  *
289  * @param[in] control The control
290  * @param[in] transitionData The transition data describing the effect to create
291  * @return A handle to an animation defined with the given effect, or an empty
292  * handle if no properties match.
293  */
294 DALI_TOOLKIT_API Dali::Animation CreateTransition( Internal::Control& control,
295                                                    const Toolkit::TransitionData& transitionData );
296
297 /**
298  * @brief Perform an action on a visual registered to this control.
299  *
300  * Visuals will have actions, this API is used to perform one of these actions with the given attributes.
301  *
302  * @param[in] control The control.
303  * @param[in] visualIndex The Property index of the visual.
304  * @param[in] actionId The action to perform.  See Visual to find supported actions.
305  * @param[in] attributes Optional attributes for the action.
306  */
307 DALI_TOOLKIT_API void DoAction( Control& control, Dali::Property::Index visualIndex, Dali::Property::Index actionId, const Dali::Property::Value attributes );
308
309 /**
310  * @brief Set input method context.
311  *
312  * @param[in] control The control.
313  * @param[in] inputMethodContext The input method context.
314  */
315 DALI_TOOLKIT_API void SetInputMethodContext( Internal::Control& control, InputMethodContext& inputMethodContext );
316
317 /**
318  * @brief Visual Event signal type
319  */
320 using VisualEventSignalType = Signal< void ( Control, Dali::Property::Index, Dali::Property::Index ) >;
321
322 /**
323  * @brief This signal is emitted when a visual has an event to notify.
324  *
325  * A callback of the following type may be connected:
326  * @code
327  *   void YourCallbackName( Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId );
328  * @endcode
329  * @return The signal to connect to
330  */
331 DALI_TOOLKIT_API VisualEventSignalType& VisualEventSignal( Control control );
332
333 /**
334  * @brief The signal is emmited as a succession of "activate" signal send by accessibility client.
335  * @return The signal to connect to
336  */
337 DALI_TOOLKIT_API Toolkit::Control::AccessibilityActivateSignalType &AccessibilityActivateSignal( Toolkit::Control control );
338
339 /**
340  * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say
341  * was placed in TTS queue but other text with higher priority prevented it from being read.
342  *
343  * @return The signal to connect to
344  */
345 DALI_TOOLKIT_API Toolkit::Control::AccessibilityReadingSkippedSignalType &AccessibilityReadingSkippedSignal( Toolkit::Control control );
346
347 /**
348  * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say
349  * was placed in TTS queue and reading was started but other text with higher priority cancelled it.
350  *
351  * @return The signal to connect to
352  */
353 DALI_TOOLKIT_API Toolkit::Control::AccessibilityReadingCancelledSignalType &AccessibilityReadingCancelledSignal( Toolkit::Control control );
354
355 /**
356  * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say
357  * was fully read by TTS module.
358  *
359  * @return The signal to connect to
360  */
361 DALI_TOOLKIT_API Toolkit::Control::AccessibilityReadingStoppedSignalType &AccessibilityReadingStoppedSignal( Toolkit::Control control );
362
363 /**
364  * @brief The signal is emmited when accessibility client asks for object's name.
365  *
366  * Connected callback should assign name to std::string call parameter.
367  * Accessibility name can be stored in two ways:
368  *     this signal,
369  *     ACCESSIBILITY_NAME property,
370  * Priority is as above. If none is used, default implementation is provided.
371  * @return [description]
372  */
373 DALI_TOOLKIT_API Toolkit::Control::AccessibilityGetNameSignalType &AccessibilityGetNameSignal( Toolkit::Control control );
374
375 /**
376  * @brief The signal is emmited when accessibility client asks for object's description.
377  *
378  * Connected callback should assign description to std::string call parameter.
379  * Accessibility description can be stored in two ways:
380  *     this signal,
381  *     ACCESSIBILITY_DESCRIPTON property,
382  * Priority is as above. If none is used, default implementation is provided.
383  * @return signal handler
384  */
385 DALI_TOOLKIT_API Toolkit::Control::AccessibilityGetDescriptionSignalType &AccessibilityGetDescriptionSignal( Toolkit::Control control );
386
387 /**
388  * @brief The signal is emitted when accessibility client call "DoGesture" method via IPC mechanism.
389  *
390  * This signal allows developers to serve incoming gesture in specific way.
391  * @return signal handler
392  */
393 DALI_TOOLKIT_API Toolkit::Control::AccessibilityDoGestureSignalType &AccessibilityDoGestureSignal( Toolkit::Control control );
394
395 /**
396  * @brief The method allows connection with other actor with usage of concrete accessibility relation type.
397  *
398  * @param control object to append attribute to
399  * @param destination Actor object
400  * @param relation    enumerated value describing relation
401  */
402 DALI_TOOLKIT_API void AppendAccessibilityRelation( Dali::Actor control, Actor destination, Dali::Accessibility::RelationType relation );
403
404 /**
405  * @brief The method allows removing relation
406  *
407  * @param control object to append attribute to
408  * @param destination Actor object
409  * @param relation    enumerated value describing relation
410  */
411 DALI_TOOLKIT_API void RemoveAccessibilityRelation( Dali::Actor control, Actor destination, Dali::Accessibility::RelationType relation );
412
413 /**
414  * @brief The method returns collection accessibility addresses representing objects connected with current object
415  *
416  * @param control object to append attribute to
417  * @return std::vector, where index is casted value of Accessibility::RelationType and value is std::vector of type Accessibility::Address
418  */
419 DALI_TOOLKIT_API std::vector<std::vector<Accessibility::Address>> GetAccessibilityRelations( Dali::Actor control );
420
421 /**
422  * @brief The method removes all previously appended relations
423  *
424  * @param control object to append attribute to
425  */
426 DALI_TOOLKIT_API void ClearAccessibilityRelations( Dali::Actor control );
427
428 /**
429  * @brief The method allows to add or modify value matched with given key.
430  * Modification take place if key was previously set.
431  *
432  * @param control object to append attribute to
433  * @param key   std::string value
434  * @param value std::string value
435  */
436 DALI_TOOLKIT_API void AppendAccessibilityAttribute( Dali::Actor control, const std::string& key, const std::string value );
437
438 /**
439  * @brief The method erases key with its value from accessibility attributes
440  * @param control object to append attribute to
441  * @param key std::string value
442  */
443 DALI_TOOLKIT_API void RemoveAccessibilityAttribute( Dali::Actor control, const std::string& key );
444
445 /**
446  * @brief The method clears accessibility attributes
447  *
448  * @param control object to append attribute to
449  */
450 DALI_TOOLKIT_API void ClearAccessibilityAttributes( Dali::Actor control );
451
452 /**
453  * @brief The method inserts reading information of an accessible object into attributes
454  *
455  * @param control object to append attribute to
456  * @param types Reading information types
457  */
458 DALI_TOOLKIT_API void SetAccessibilityReadingInfoType( Dali::Actor control, const Dali::Accessibility::ReadingInfoTypes types );
459
460 /**
461  * @brief The method returns reading information of an accessible object
462  *
463  * @param control object to append attribute to
464  * @return Reading information types
465  */
466 DALI_TOOLKIT_API Dali::Accessibility::ReadingInfoTypes GetAccessibilityReadingInfoType( Dali::Actor control );
467
468 /**
469  * @brief The method erases highlight.
470  *
471  * @param control object to append attribute to
472  * @return bool value, false when it is not possible or something went wrong, at the other way true.
473  */
474 DALI_TOOLKIT_API bool ClearAccessibilityHighlight( Dali::Actor control );
475
476 /**
477  * @brief The method grabs highlight.
478  *
479  * @param control object to append attribute to
480  * @return bool value, false when it is not possible or something went wrong, at the other way true.
481  */
482 DALI_TOOLKIT_API bool GrabAccessibilityHighlight( Dali::Actor control );
483
484 /**
485  * @brief The metod presents bitset of control's states.
486  *
487  * @param control object to append attribute to
488  * @return Dali::Accessibility::States is vector of enumerated State.
489  */
490 DALI_TOOLKIT_API Dali::Accessibility::States GetAccessibilityStates( Dali::Actor control );
491
492 /**
493  * @brief The method force sending notifications about current states to accessibility clients
494  *
495  * @param control object to append attribute to
496  * @param states      mask with states expected to broadcast
497  * @param doRecursive flag pointing if notifications of children's state would be sent
498  */
499 DALI_TOOLKIT_API void NotifyAccessibilityStateChange( Dali::Actor control, Dali::Accessibility::States states, bool doRecursive );
500
501 /**
502  * The method allows to set specific constructor for creating accessibility structure
503  *
504  * Thank to this method hierarchy of accessibility objects can be based on internal hierarchy of Actors.
505  * It prevents from necessity of keeping two trees synchronized.
506  * The method should be called inside constructors of all classes inheriting from Control.
507  *
508  * Possible usage can be as follows:
509  * @code
510  *   SetAccessibilityConstructor( []( Dali::Actor actor ) {
511        return std::unique_ptr< Dali::Accessibility::Accessible >(
512        new AccessibleImpl( actor, Dali::Accessibility::Role::DIALOG, true ) );
513       } );
514   * @endcode
515   *
516   * param constructor callback creating Accessible object
517   */
518 DALI_TOOLKIT_API void SetAccessibilityConstructor( Dali::Actor control, std::function<std::unique_ptr<Dali::Accessibility::Accessible>(Dali::Actor)> constructor);
519
520 /**
521  * Returns accessibility object bound to actor, if any
522  *
523  * This method won't bound new accessibility object. Use Dali::Accessibility::Accessible::Get in that case.
524  */
525 DALI_TOOLKIT_API Dali::Accessibility::Accessible *GetBoundAccessibilityObject( Dali::Actor control );
526
527 } // namespace DevelControl
528
529 } // namespace Toolkit
530
531 } // namespace Dali
532
533 #endif // DALI_TOOLKIT_CONTROL_DEVEL_H