1 #ifndef DALI_TOOLKIT_CONTROL_DEVEL_H
2 #define DALI_TOOLKIT_CONTROL_DEVEL_H
5 * Copyright (c) 2021 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.
21 #include <dali/devel-api/adaptor-framework/accessibility-impl.h>
22 #include <dali/devel-api/adaptor-framework/input-method-context.h>
25 #include <dali-toolkit/devel-api/controls/accessible-impl.h>
26 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
27 #include <dali-toolkit/public-api/controls/control.h>
40 namespace DevelControl
42 /// @brief AccessibilityActivate signal type.
43 typedef Signal<void()> AccessibilityActivateSignalType;
45 /// @brief AccessibilityReadingSkipped signal type.
46 typedef Signal<void()> AccessibilityReadingSkippedSignalType;
48 /// @brief AccessibilityReadingPaused signal type.
49 typedef Signal<void()> AccessibilityReadingPausedSignalType;
51 /// @brief AccessibilityReadingResumed signal type.
52 typedef Signal<void()> AccessibilityReadingResumedSignalType;
54 /// @brief AccessibilityReadingCancelled signal type.
55 typedef Signal<void()> AccessibilityReadingCancelledSignalType;
57 /// @brief AccessibilityReadingStopped signal type.
58 typedef Signal<void()> AccessibilityReadingStoppedSignalType;
60 /// @brief AccessibilityGetName signal type.
61 typedef Signal<void(std::string&)> AccessibilityGetNameSignalType;
63 /// @brief AccessibilityGetDescription signal type.
64 typedef Signal<void(std::string&)> AccessibilityGetDescriptionSignalType;
66 /// @brief AccessibilityDoGesture signal type.
67 typedef Signal<void(std::pair<Dali::Accessibility::GestureInfo, bool>&)> AccessibilityDoGestureSignalType;
80 STYLE_NAME = Control::Property::STYLE_NAME,
81 KEY_INPUT_FOCUS = Control::Property::KEY_INPUT_FOCUS,
82 BACKGROUND = Control::Property::BACKGROUND,
83 MARGIN = Control::Property::MARGIN,
84 PADDING = Control::Property::PADDING,
87 * @brief Displays a tooltip when the control is hovered over.
88 * @details Name "tooltip", type Property::STRING, Property::ARRAY or Property::MAP.
89 * If Property::STRING, then the style specified in the stylesheet is used.
90 * If Property::ARRAY of Visuals then all are displayed in one row.
91 * If Property::MAP, then it should be a map of Tooltip properties.
92 * @note The tooltip is only activated if display content is received, i.e. a string (text) or visual to show.
93 * The rest is used to just build up the style of the tooltip (i.e. background, text color/point-size etc.)
94 * @note When retrieved, a Property::MAP is returned.
95 * @see Toolkit::Tooltip
97 TOOLTIP = PADDING + 1,
100 * @brief The current state of the control.
101 * @details Name "state", type DevelControl::State ( Property::INTEGER ) or Property::STRING
103 * @see DevelControl::State
108 * @brief The current sub state of the control.
109 * @details Name "subState", type Property::INTEGER or Property::STRING. The enumeration used is dependent on the derived control.
111 * @see DevelControl::State
113 SUB_STATE = PADDING + 3,
116 * @brief The actor ID of the left focusable control.
117 * @details Name "leftFocusableActorId", type Property::INTEGER.
120 LEFT_FOCUSABLE_ACTOR_ID = PADDING + 4,
123 * @brief The actor ID of the right focusable control.
124 * @details Name "rightFocusableActorId", type Property::INTEGER.
127 RIGHT_FOCUSABLE_ACTOR_ID = PADDING + 5,
130 * @brief The actor ID of the up focusable control.
131 * @details Name "upFocusableActorId", type Property::INTEGER.
134 UP_FOCUSABLE_ACTOR_ID = PADDING + 6,
137 * @brief The actor ID of the down focusable control.
138 * @details Name "downFocusableActorId", type Property::INTEGER.
141 DOWN_FOCUSABLE_ACTOR_ID = PADDING + 7,
144 * @brief The shadow of the control.
145 * @details Name "shadow", type Property::MAP.
147 SHADOW = PADDING + 8,
150 * @brief The name of object visible in accessibility tree.
151 * @details Name "accessibilityName", type Property::STRING.
156 * @brief The description of object visible in accessibility tree.
157 * @details Name "accessibilityDescription", type Property::STRING.
159 ACCESSIBILITY_DESCRIPTION,
162 * @brief Current translation domain for accessibility clients.
163 * @details Name "accessibilityTranslationDomain", type Property::STRING.
165 ACCESSIBILITY_TRANSLATION_DOMAIN,
168 * @brief Role being performed in accessibility hierarchy.
169 * @details Name "accessibilityRole", type Property::INTEGER.
170 * @note Property is stored as INTEGER, however its interpretaton
171 * depend on enumeration Dali::Accessibility::Role and should be read and written
172 * with usage of enumerated values.
173 * @see Dali::Accessibility::Role
177 * @brief Mark of able to highlight object.
178 * @details Name "accessibilityHighlightable", type Property::BOOLEAN.
180 ACCESSIBILITY_HIGHLIGHTABLE,
182 * @brief Set of accessibility attributes describing object in accessibility hierarchy
183 * @details Name "accessibilityAttributes", type Property::MAP
185 ACCESSIBILITY_ATTRIBUTES,
188 * @brief Boolean flag describing object as animated
189 * @details Name "accessibilityAnimated", type Property::BOOLEAN
190 * @note Flag set to true will prevent BoundChanged accessibility signal from emiting
192 ACCESSIBILITY_ANIMATED
195 } // namespace Property
198 * @brief Register a visual by Property Index.
200 * @param[in] control The control
201 * @param[in] index The Property index of the visual, used to reference visual
202 * @param[in] visual The visual to register
204 * @note Derived class should not call visual.SetOnScene(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
205 * Use below API with enabled set to false if derived class wishes to control when visual is staged.
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.
209 DALI_TOOLKIT_API void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual);
212 * @brief Register a visual by Property Index with a depth index.
214 * @param[in] control The control
215 * @param[in] index The Property index of the visual, used to reference visual
216 * @param[in] visual The visual to register
217 * @param[in] depthIndex The visual's depth-index is set to this
219 * @note Derived class should not call visual.SetOnScene(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
220 * Use below API with enabled set to false if derived class wishes to control when visual is staged.
222 * @see Visual::Base::GetDepthIndex()
223 * @see Visual::Base::SetDepthIndex()
225 DALI_TOOLKIT_API void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, int depthIndex);
228 * @brief Register a visual by Property Index with the option of enabling/disabling it.
230 * @param[in] control The control
231 * @param[in] index The Property index of the visual, used to reference visual
232 * @param[in] visual The visual to register
233 * @param[in] enabled false if derived class wants to control when visual is set on stage.
235 * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
236 * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
238 * @see EnableVisual()
240 DALI_TOOLKIT_API void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled);
243 * @brief Register a visual by Property Index with a depth index with the option of enabling/disabling it.
245 * @param[in] control The control
246 * @param[in] index The Property index of the visual, used to reference visual
247 * @param[in] visual The visual to register
248 * @param[in] enabled false if derived class wants to control when visual is set on stage.
249 * @param[in] depthIndex The visual's depth-index is set to this
251 * @see EnableVisual()
252 * @see Visual::Base::GetDepthIndex()
253 * @see Visual::Base::SetDepthIndex()
255 DALI_TOOLKIT_API void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex);
258 * @brief Erase the entry matching the given index from the list of registered visuals
260 * @param[in] control The control
261 * @param[in] index The Property index of the visual, used to reference visual
263 DALI_TOOLKIT_API void UnregisterVisual(Internal::Control& control, Dali::Property::Index index);
266 * @brief Retrieve the visual associated with the given property index.
268 * @param[in] control The control
269 * @param[in] index The Property index of the visual.
270 * @return The registered visual if exist, otherwise empty handle.
271 * @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
273 DALI_TOOLKIT_API Toolkit::Visual::Base GetVisual(const Internal::Control& control, Dali::Property::Index index);
276 * @brief Sets the given visual to be displayed or not when parent staged.
278 * @param[in] control The control
279 * @param[in] index The Property index of the visual
280 * @param[in] enable flag to set enabled or disabled.
282 DALI_TOOLKIT_API void EnableVisual(Internal::Control& control, Dali::Property::Index index, bool enable);
285 * @brief Queries if the given visual is to be displayed when parent staged.
287 * @param[in] control The control
288 * @param[in] index The Property index of the visual
289 * @return bool whether visual is enabled or not
291 DALI_TOOLKIT_API bool IsVisualEnabled(const Internal::Control& control, Dali::Property::Index index);
294 * @brief Add a transition effect on the control to the given animation
296 * Only generates an animator if the properties described in the transition
297 * data are staged (e.g. the visual is Enabled and the control is on stage).
298 * Otherwise the target values are stored, and will get set onto the properties
299 * when the visual is next staged.
301 * @param[in] control The control
302 * @param[in] animation The Animation to add valid transitions to
303 * @param[in] transitionData The transition data describing the effect to create
305 DALI_TOOLKIT_API void AddTransitions(Internal::Control& control,
306 Dali::Animation animation,
307 const Toolkit::TransitionData& transitionData);
310 * @brief Create a transition effect on the control.
312 * Only generates an animation if the properties described in the transition
313 * data are staged (e.g. the visual is Enabled and the control is on stage).
314 * Otherwise the target values are stored, and will get set onto the properties
315 * when the visual is next staged.
317 * @param[in] control The control
318 * @param[in] transitionData The transition data describing the effect to create
319 * @return A handle to an animation defined with the given effect, or an empty
320 * handle if no properties match.
322 DALI_TOOLKIT_API Dali::Animation CreateTransition(Internal::Control& control,
323 const Toolkit::TransitionData& transitionData);
326 * @brief Perform an action on a visual registered to this control.
328 * Visuals will have actions, this API is used to perform one of these actions with the given attributes.
330 * @param[in] control The control.
331 * @param[in] visualIndex The Property index of the visual.
332 * @param[in] actionId The action to perform. See Visual to find supported actions.
333 * @param[in] attributes Optional attributes for the action.
335 DALI_TOOLKIT_API void DoAction(Control& control, Dali::Property::Index visualIndex, Dali::Property::Index actionId, const Dali::Property::Value attributes);
338 * @brief Set input method context.
340 * @param[in] control The control.
341 * @param[in] inputMethodContext The input method context.
343 DALI_TOOLKIT_API void SetInputMethodContext(Internal::Control& control, InputMethodContext& inputMethodContext);
346 * @brief Visual Event signal type
348 using VisualEventSignalType = Signal<void(Control, Dali::Property::Index, Dali::Property::Index)>;
351 * @brief This signal is emitted when a visual has an event to notify.
353 * A callback of the following type may be connected:
355 * void YourCallbackName( Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId );
357 * @return The signal to connect to
359 DALI_TOOLKIT_API VisualEventSignalType& VisualEventSignal(Control control);
362 * @brief Retrieve the property object associated with the given property index and the visual property key.
364 * @param[in] control The control
365 * @param[in] index The Property index of the visual.
366 * @param[in] visualPropertyKey The key of the visual's property.
367 * @return The Property object
369 DALI_TOOLKIT_API Dali::Property GetVisualProperty(Control control, Dali::Property::Index index, Dali::Property::Key visualPropertyKey);
372 * @brief The signal is emmited as a succession of "activate" signal send by accessibility client.
373 * @return The signal to connect to
375 DALI_TOOLKIT_API AccessibilityActivateSignalType& AccessibilityActivateSignal(Toolkit::Control control);
378 * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say
379 * was placed in TTS queue but other text with higher priority prevented it from being read.
381 * @return The signal to connect to
383 DALI_TOOLKIT_API AccessibilityReadingSkippedSignalType& AccessibilityReadingSkippedSignal(Toolkit::Control control);
388 * @return The signal to connect to
390 DALI_TOOLKIT_API AccessibilityReadingPausedSignalType& AccessibilityReadingPausedSignal(Toolkit::Control control);
395 * @return The signal to connect to
397 DALI_TOOLKIT_API AccessibilityReadingResumedSignalType& AccessibilityReadingResumedSignal(Toolkit::Control control);
400 * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say
401 * was placed in TTS queue and reading was started but other text with higher priority cancelled it.
403 * @return The signal to connect to
405 DALI_TOOLKIT_API AccessibilityReadingCancelledSignalType& AccessibilityReadingCancelledSignal(Toolkit::Control control);
408 * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say
409 * was fully read by TTS module.
411 * @return The signal to connect to
413 DALI_TOOLKIT_API AccessibilityReadingStoppedSignalType& AccessibilityReadingStoppedSignal(Toolkit::Control control);
416 * @brief The signal is emmited when accessibility client asks for object's name.
418 * Connected callback should assign name to std::string call parameter.
419 * Accessibility name can be stored in two ways:
421 * ACCESSIBILITY_NAME property,
422 * Priority is as above. If none is used, default implementation is provided.
423 * @return [description]
425 DALI_TOOLKIT_API AccessibilityGetNameSignalType& AccessibilityGetNameSignal(Toolkit::Control control);
428 * @brief The signal is emmited when accessibility client asks for object's description.
430 * Connected callback should assign description to std::string call parameter.
431 * Accessibility description can be stored in two ways:
433 * ACCESSIBILITY_DESCRIPTION property,
434 * Priority is as above. If none is used, default implementation is provided.
435 * @return signal handler
437 DALI_TOOLKIT_API AccessibilityGetDescriptionSignalType& AccessibilityGetDescriptionSignal(Toolkit::Control control);
440 * @brief The signal is emitted when accessibility client call "DoGesture" method via IPC mechanism.
442 * This signal allows developers to serve incoming gesture in specific way.
443 * @return signal handler
445 DALI_TOOLKIT_API AccessibilityDoGestureSignalType& AccessibilityDoGestureSignal(Toolkit::Control control);
448 * @brief The method allows connection with other actor with usage of concrete accessibility relation type.
450 * @param control object to append attribute to
451 * @param destination Actor object
452 * @param relation enumerated value describing relation
454 DALI_TOOLKIT_API void AppendAccessibilityRelation(Dali::Actor control, Actor destination, Dali::Accessibility::RelationType relation);
457 * @brief The method allows removing relation
459 * @param control object to append attribute to
460 * @param destination Actor object
461 * @param relation enumerated value describing relation
463 DALI_TOOLKIT_API void RemoveAccessibilityRelation(Dali::Actor control, Actor destination, Dali::Accessibility::RelationType relation);
466 * @brief The method returns collection accessibility addresses representing objects connected with current object
468 * @param control object to append attribute to
469 * @return std::vector, where index is casted value of Accessibility::RelationType and value is std::vector of type Accessibility::Address
471 DALI_TOOLKIT_API std::vector<std::vector<Accessibility::Address>> GetAccessibilityRelations(Dali::Actor control);
474 * @brief The method removes all previously appended relations
476 * @param control object to append attribute to
478 DALI_TOOLKIT_API void ClearAccessibilityRelations(Dali::Actor control);
481 * @brief The method allows to add or modify value matched with given key.
482 * Modification take place if key was previously set.
484 * @param control object to append attribute to
485 * @param key std::string value
486 * @param value std::string value
488 DALI_TOOLKIT_API void AppendAccessibilityAttribute(Dali::Actor control, const std::string& key, const std::string value);
491 * @brief The method erases key with its value from accessibility attributes
492 * @param control object to append attribute to
493 * @param key std::string value
495 DALI_TOOLKIT_API void RemoveAccessibilityAttribute(Dali::Actor control, const std::string& key);
498 * @brief The method clears accessibility attributes
500 * @param control object to append attribute to
502 DALI_TOOLKIT_API void ClearAccessibilityAttributes(Dali::Actor control);
505 * @brief The method inserts reading information of an accessible object into attributes
507 * @param control object to append attribute to
508 * @param types Reading information types
510 DALI_TOOLKIT_API void SetAccessibilityReadingInfoType(Dali::Actor control, const Dali::Accessibility::ReadingInfoTypes types);
513 * @brief The method returns reading information of an accessible object
515 * @param control object to append attribute to
516 * @return Reading information types
518 DALI_TOOLKIT_API Dali::Accessibility::ReadingInfoTypes GetAccessibilityReadingInfoType(Dali::Actor control);
521 * @brief The method erases highlight.
523 * @param control object to append attribute to
524 * @return bool value, false when it is not possible or something went wrong, at the other way true.
526 DALI_TOOLKIT_API bool ClearAccessibilityHighlight(Dali::Actor control);
529 * @brief The method grabs highlight.
531 * @param control object to append attribute to
532 * @return bool value, false when it is not possible or something went wrong, at the other way true.
534 DALI_TOOLKIT_API bool GrabAccessibilityHighlight(Dali::Actor control);
537 * @brief The metod presents bitset of control's states.
539 * @param control object to append attribute to
540 * @return Dali::Accessibility::States is vector of enumerated State.
542 DALI_TOOLKIT_API Dali::Accessibility::States GetAccessibilityStates(Dali::Actor control);
545 * @brief The method force sending notifications about current states to accessibility clients
547 * @param control object to append attribute to
548 * @param states mask with states expected to broadcast
549 * @param doRecursive flag pointing if notifications of children's state would be sent
551 DALI_TOOLKIT_API void NotifyAccessibilityStateChange(Dali::Actor control, Dali::Accessibility::States states, bool doRecursive);
554 * The method allows to set specific constructor for creating accessibility structure
556 * Thank to this method hierarchy of accessibility objects can be based on internal hierarchy of Actors.
557 * It prevents from necessity of keeping two trees synchronized.
558 * The method should be called inside OnInitialize method of all classes inheriting from Control.
560 * Possible usage can be as follows:
562 * SetAccessibilityConstructor( []( Dali::Actor actor ) {
563 return std::unique_ptr< Dali::Accessibility::Accessible >(
564 new AccessibleImpl( actor, Dali::Accessibility::Role::DIALOG, true ) );
568 * param constructor callback creating Accessible object
570 DALI_TOOLKIT_API void SetAccessibilityConstructor(Dali::Actor control, std::function<std::unique_ptr<Dali::Accessibility::Accessible>(Dali::Actor)> constructor);
573 * Returns accessibility object bound to actor, if any
575 * This method won't bound new accessibility object. Use Dali::Accessibility::Accessible::Get in that case.
577 DALI_TOOLKIT_API Dali::Accessibility::Accessible* GetBoundAccessibilityObject(Dali::Actor control);
579 } // namespace DevelControl
581 } // namespace Toolkit
585 #endif // DALI_TOOLKIT_CONTROL_DEVEL_H