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-bridge.h>
22 #include <dali/devel-api/adaptor-framework/input-method-context.h>
23 #include <dali/public-api/animation/alpha-function.h>
24 #include <dali/public-api/animation/time-period.h>
27 #include <dali-toolkit/devel-api/controls/control-accessible.h>
28 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
29 #include <dali-toolkit/public-api/controls/control.h>
42 namespace DevelControl
44 /// @brief AccessibilityActivate signal type.
45 typedef Signal<void()> AccessibilityActivateSignalType;
47 /// @brief AccessibilityReadingSkipped signal type.
48 typedef Signal<void()> AccessibilityReadingSkippedSignalType;
50 /// @brief AccessibilityReadingPaused signal type.
51 typedef Signal<void()> AccessibilityReadingPausedSignalType;
53 /// @brief AccessibilityReadingResumed signal type.
54 typedef Signal<void()> AccessibilityReadingResumedSignalType;
56 /// @brief AccessibilityReadingCancelled signal type.
57 typedef Signal<void()> AccessibilityReadingCancelledSignalType;
59 /// @brief AccessibilityReadingStopped signal type.
60 typedef Signal<void()> AccessibilityReadingStoppedSignalType;
62 /// @brief AccessibilityGetName signal type.
63 typedef Signal<void(std::string&)> AccessibilityGetNameSignalType;
65 /// @brief AccessibilityGetDescription signal type.
66 typedef Signal<void(std::string&)> AccessibilityGetDescriptionSignalType;
68 /// @brief AccessibilityDoGesture signal type.
69 typedef Signal<void(std::pair<Dali::Accessibility::GestureInfo, bool>&)> AccessibilityDoGestureSignalType;
82 STYLE_NAME = Control::Property::STYLE_NAME,
83 KEY_INPUT_FOCUS = Control::Property::KEY_INPUT_FOCUS,
84 BACKGROUND = Control::Property::BACKGROUND,
85 MARGIN = Control::Property::MARGIN,
86 PADDING = Control::Property::PADDING,
89 * @brief Displays a tooltip when the control is hovered over.
90 * @details Name "tooltip", type Property::STRING, Property::ARRAY or Property::MAP.
91 * If Property::STRING, then the style specified in the stylesheet is used.
92 * If Property::ARRAY of Visuals then all are displayed in one row.
93 * If Property::MAP, then it should be a map of Tooltip properties.
94 * @note The tooltip is only activated if display content is received, i.e. a string (text) or visual to show.
95 * The rest is used to just build up the style of the tooltip (i.e. background, text color/point-size etc.)
96 * @note When retrieved, a Property::MAP is returned.
97 * @see Toolkit::Tooltip
99 TOOLTIP = PADDING + 1,
102 * @brief The current state of the control.
103 * @details Name "state", type DevelControl::State ( Property::INTEGER ) or Property::STRING
105 * @see DevelControl::State
110 * @brief The current sub state of the control.
111 * @details Name "subState", type Property::INTEGER or Property::STRING. The enumeration used is dependent on the derived control.
113 * @see DevelControl::State
115 SUB_STATE = PADDING + 3,
118 * @brief The actor ID of the left focusable control.
119 * @details Name "leftFocusableActorId", type Property::INTEGER.
122 LEFT_FOCUSABLE_ACTOR_ID = PADDING + 4,
125 * @brief The actor ID of the right focusable control.
126 * @details Name "rightFocusableActorId", type Property::INTEGER.
129 RIGHT_FOCUSABLE_ACTOR_ID = PADDING + 5,
132 * @brief The actor ID of the up focusable control.
133 * @details Name "upFocusableActorId", type Property::INTEGER.
136 UP_FOCUSABLE_ACTOR_ID = PADDING + 6,
139 * @brief The actor ID of the down focusable control.
140 * @details Name "downFocusableActorId", type Property::INTEGER.
143 DOWN_FOCUSABLE_ACTOR_ID = PADDING + 7,
146 * @brief The shadow of the control.
147 * @details Name "shadow", type Property::MAP.
149 SHADOW = PADDING + 8,
152 * @brief The name of object visible in accessibility tree.
153 * @details Name "accessibilityName", type Property::STRING.
158 * @brief The description of object visible in accessibility tree.
159 * @details Name "accessibilityDescription", type Property::STRING.
161 ACCESSIBILITY_DESCRIPTION,
164 * @brief Current translation domain for accessibility clients.
165 * @details Name "accessibilityTranslationDomain", type Property::STRING.
167 ACCESSIBILITY_TRANSLATION_DOMAIN,
170 * @brief Role being performed in accessibility hierarchy.
171 * @details Name "accessibilityRole", type Property::INTEGER.
172 * @note Property is stored as INTEGER, however its interpretaton
173 * depend on enumeration Dali::Accessibility::Role and should be read and written
174 * with usage of enumerated values.
175 * @see Dali::Accessibility::Role
180 * @brief Mark of able to highlight object.
181 * @details Name "accessibilityHighlightable", type Property::BOOLEAN.
183 ACCESSIBILITY_HIGHLIGHTABLE,
186 * @brief Set of accessibility attributes describing object in accessibility hierarchy
187 * @details Name "accessibilityAttributes", type Property::MAP
189 ACCESSIBILITY_ATTRIBUTES,
192 * @brief Whether a Control and its descendants can emit key signals.
193 * @details Name "dispatchKeyEvents", type Property::BOOLEAN
194 * @note If a control's dispatchKeyEvents is set to false, then it's children will not emit a key event signal either.
199 * @brief Marks the object as invisible to AT-SPI clients.
200 * @details Name "accessibilityHidden", type Property::BOOLEAN.
201 * @note The representative Accessible object will not appear in the AT-SPI tree.
203 ACCESSIBILITY_HIDDEN,
206 } // namespace Property
209 * @brief Register a visual by Property Index.
211 * @param[in] control The control
212 * @param[in] index The Property index of the visual, used to reference visual
213 * @param[in] visual The visual to register
215 * @note Derived class should not call visual.SetOnScene(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
216 * Use below API with enabled set to false if derived class wishes to control when visual is staged.
217 * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
218 * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
220 DALI_TOOLKIT_API void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual);
223 * @brief Register a visual by Property Index with a depth index.
225 * @param[in] control The control
226 * @param[in] index The Property index of the visual, used to reference visual
227 * @param[in] visual The visual to register
228 * @param[in] depthIndex The visual's depth-index is set to this
230 * @note Derived class should not call visual.SetOnScene(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
231 * Use below API with enabled set to false if derived class wishes to control when visual is staged.
233 * @see Visual::Base::GetDepthIndex()
234 * @see Visual::Base::SetDepthIndex()
236 DALI_TOOLKIT_API void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, int depthIndex);
239 * @brief Register a visual by Property Index with the option of enabling/disabling it.
241 * @param[in] control The control
242 * @param[in] index The Property index of the visual, used to reference visual
243 * @param[in] visual The visual to register
244 * @param[in] enabled false if derived class wants to control when visual is set on stage.
246 * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
247 * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
249 * @see EnableVisual()
251 DALI_TOOLKIT_API void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled);
254 * @brief Register a visual by Property Index with a depth index with the option of enabling/disabling it.
256 * @param[in] control The control
257 * @param[in] index The Property index of the visual, used to reference visual
258 * @param[in] visual The visual to register
259 * @param[in] enabled false if derived class wants to control when visual is set on stage.
260 * @param[in] depthIndex The visual's depth-index is set to this
262 * @see EnableVisual()
263 * @see Visual::Base::GetDepthIndex()
264 * @see Visual::Base::SetDepthIndex()
266 DALI_TOOLKIT_API void RegisterVisual(Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex);
269 * @brief Erase the entry matching the given index from the list of registered visuals
271 * @param[in] control The control
272 * @param[in] index The Property index of the visual, used to reference visual
274 DALI_TOOLKIT_API void UnregisterVisual(Internal::Control& control, Dali::Property::Index index);
277 * @brief Retrieve the visual associated with the given property index.
279 * @param[in] control The control
280 * @param[in] index The Property index of the visual.
281 * @return The registered visual if exist, otherwise empty handle.
282 * @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
284 DALI_TOOLKIT_API Toolkit::Visual::Base GetVisual(const Internal::Control& control, Dali::Property::Index index);
287 * @brief Sets the given visual to be displayed or not when parent staged.
289 * @param[in] control The control
290 * @param[in] index The Property index of the visual
291 * @param[in] enable flag to set enabled or disabled.
293 DALI_TOOLKIT_API void EnableVisual(Internal::Control& control, Dali::Property::Index index, bool enable);
296 * @brief Queries if the given visual is to be displayed when parent staged.
298 * @param[in] control The control
299 * @param[in] index The Property index of the visual
300 * @return bool whether visual is enabled or not
302 DALI_TOOLKIT_API bool IsVisualEnabled(const Internal::Control& control, Dali::Property::Index index);
305 * @brief Add a transition effect on the control to the given animation
307 * Only generates an animator if the properties described in the transition
308 * data are staged (e.g. the visual is Enabled and the control is on stage).
309 * Otherwise the target values are stored, and will get set onto the properties
310 * when the visual is next staged.
312 * @param[in] control The control
313 * @param[in] animation The Animation to add valid transitions to
314 * @param[in] transitionData The transition data describing the effect to create
316 DALI_TOOLKIT_API void AddTransitions(Internal::Control& control,
317 Dali::Animation animation,
318 const Toolkit::TransitionData& transitionData);
321 * @brief Create a transition effect on the control.
323 * Only generates an animation if the properties described in the transition
324 * data are staged (e.g. the visual is Enabled and the control is on stage).
325 * Otherwise the target values are stored, and will get set onto the properties
326 * when the visual is next staged.
328 * @param[in] control The control
329 * @param[in] transitionData The transition data describing the effect to create
330 * @return A handle to an animation defined with the given effect, or an empty
331 * handle if no properties match.
333 DALI_TOOLKIT_API Dali::Animation CreateTransition(Internal::Control& control,
334 const Toolkit::TransitionData& transitionData);
337 * @brief Perform an action on a visual registered to this control.
339 * Visuals will have actions, this API is used to perform one of these actions with the given attributes.
341 * @param[in] control The control.
342 * @param[in] visualIndex The Property index of the visual.
343 * @param[in] actionId The action to perform. See Visual to find supported actions.
344 * @param[in] attributes Optional attributes for the action.
346 DALI_TOOLKIT_API void DoAction(Control& control, Dali::Property::Index visualIndex, Dali::Property::Index actionId, const Dali::Property::Value attributes);
349 * @brief Set input method context.
351 * @param[in] control The control.
352 * @param[in] inputMethodContext The input method context.
354 DALI_TOOLKIT_API void SetInputMethodContext(Internal::Control& control, InputMethodContext& inputMethodContext);
357 * @brief Visual Event signal type
359 using VisualEventSignalType = Signal<void(Control, Dali::Property::Index, Dali::Property::Index)>;
362 * @brief This signal is emitted when a visual has an event to notify.
364 * A callback of the following type may be connected:
366 * void YourCallbackName( Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId );
368 * @return The signal to connect to
370 DALI_TOOLKIT_API VisualEventSignalType& VisualEventSignal(Control control);
373 * @brief Retrieve the property object associated with the given property index and the visual property key.
375 * @param[in] control The control
376 * @param[in] index The Property index of the visual.
377 * @param[in] visualPropertyKey The key of the visual's property.
378 * @return The Property object
380 DALI_TOOLKIT_API Dali::Property GetVisualProperty(Control control, Dali::Property::Index index, Dali::Property::Key visualPropertyKey);
383 * @brief The signal is emmited as a succession of "activate" signal send by accessibility client.
384 * @return The signal to connect to
386 DALI_TOOLKIT_API AccessibilityActivateSignalType& AccessibilityActivateSignal(Toolkit::Control control);
389 * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say
390 * was placed in TTS queue but other text with higher priority prevented it from being read.
392 * @return The signal to connect to
394 DALI_TOOLKIT_API AccessibilityReadingSkippedSignalType& AccessibilityReadingSkippedSignal(Toolkit::Control control);
399 * @return The signal to connect to
401 DALI_TOOLKIT_API AccessibilityReadingPausedSignalType& AccessibilityReadingPausedSignal(Toolkit::Control control);
406 * @return The signal to connect to
408 DALI_TOOLKIT_API AccessibilityReadingResumedSignalType& AccessibilityReadingResumedSignal(Toolkit::Control control);
411 * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say
412 * was placed in TTS queue and reading was started but other text with higher priority cancelled it.
414 * @return The signal to connect to
416 DALI_TOOLKIT_API AccessibilityReadingCancelledSignalType& AccessibilityReadingCancelledSignal(Toolkit::Control control);
419 * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say
420 * was fully read by TTS module.
422 * @return The signal to connect to
424 DALI_TOOLKIT_API AccessibilityReadingStoppedSignalType& AccessibilityReadingStoppedSignal(Toolkit::Control control);
427 * @brief The signal is emmited when accessibility client asks for object's name.
429 * Connected callback should assign name to std::string call parameter.
430 * Accessibility name can be stored in two ways:
432 * ACCESSIBILITY_NAME property,
433 * Priority is as above. If none is used, default implementation is provided.
434 * @return [description]
436 DALI_TOOLKIT_API AccessibilityGetNameSignalType& AccessibilityGetNameSignal(Toolkit::Control control);
439 * @brief The signal is emmited when accessibility client asks for object's description.
441 * Connected callback should assign description to std::string call parameter.
442 * Accessibility description can be stored in two ways:
444 * ACCESSIBILITY_DESCRIPTION property,
445 * Priority is as above. If none is used, default implementation is provided.
446 * @return signal handler
448 DALI_TOOLKIT_API AccessibilityGetDescriptionSignalType& AccessibilityGetDescriptionSignal(Toolkit::Control control);
451 * @brief The signal is emitted when accessibility client call "DoGesture" method via IPC mechanism.
453 * This signal allows developers to serve incoming gesture in specific way.
454 * @return signal handler
456 DALI_TOOLKIT_API AccessibilityDoGestureSignalType& AccessibilityDoGestureSignal(Toolkit::Control control);
459 * @brief The method allows connection with other actor with usage of concrete accessibility relation type.
461 * @param control object to append attribute to
462 * @param destination Actor object
463 * @param relation enumerated value describing relation
465 DALI_TOOLKIT_API void AppendAccessibilityRelation(Dali::Actor control, Actor destination, Dali::Accessibility::RelationType relation);
468 * @brief The method allows removing relation
470 * @param control object to append attribute to
471 * @param destination Actor object
472 * @param relation enumerated value describing relation
474 DALI_TOOLKIT_API void RemoveAccessibilityRelation(Dali::Actor control, Actor destination, Dali::Accessibility::RelationType relation);
477 * @brief The method returns collection accessibility addresses representing objects connected with current object
479 * @param control object to append attribute to
480 * @return std::vector, where index is casted value of Accessibility::RelationType and value is std::vector of type Accessibility::Address
482 DALI_TOOLKIT_API std::vector<std::vector<Accessibility::Address>> GetAccessibilityRelations(Dali::Actor control);
485 * @brief The method removes all previously appended relations
487 * @param control object to append attribute to
489 DALI_TOOLKIT_API void ClearAccessibilityRelations(Dali::Actor control);
492 * @brief The method allows to add or modify value matched with given key.
493 * Modification take place if key was previously set.
495 * @param control object to append attribute to
496 * @param key std::string value
497 * @param value std::string value
499 DALI_TOOLKIT_API void AppendAccessibilityAttribute(Dali::Actor control, const std::string& key, const std::string value);
502 * @brief The method erases key with its value from accessibility attributes
503 * @param control object to append attribute to
504 * @param key std::string value
506 DALI_TOOLKIT_API void RemoveAccessibilityAttribute(Dali::Actor control, const std::string& key);
509 * @brief The method clears accessibility attributes
511 * @param control object to append attribute to
513 DALI_TOOLKIT_API void ClearAccessibilityAttributes(Dali::Actor control);
516 * @brief The method inserts reading information of an accessible object into attributes
518 * @param control object to append attribute to
519 * @param types Reading information types
521 DALI_TOOLKIT_API void SetAccessibilityReadingInfoType(Dali::Actor control, const Dali::Accessibility::ReadingInfoTypes types);
524 * @brief The method returns reading information of an accessible object
526 * @param control object to append attribute to
527 * @return Reading information types
529 DALI_TOOLKIT_API Dali::Accessibility::ReadingInfoTypes GetAccessibilityReadingInfoType(Dali::Actor control);
532 * @brief The method erases highlight.
534 * @param control object to append attribute to
535 * @return bool value, false when it is not possible or something went wrong, at the other way true.
537 DALI_TOOLKIT_API bool ClearAccessibilityHighlight(Dali::Actor control);
540 * @brief The method grabs highlight.
542 * @param control object to append attribute to
543 * @return bool value, false when it is not possible or something went wrong, at the other way true.
545 DALI_TOOLKIT_API bool GrabAccessibilityHighlight(Dali::Actor control);
548 * @brief The metod presents bitset of control's states.
550 * @param control object to append attribute to
551 * @return Dali::Accessibility::States is vector of enumerated State.
553 DALI_TOOLKIT_API Dali::Accessibility::States GetAccessibilityStates(Dali::Actor control);
556 * @brief The method force sending notifications about current states to accessibility clients
558 * @param control object to append attribute to
559 * @param states mask with states expected to broadcast
560 * @param isRecursive flag pointing if notifications of children's state would be sent
562 DALI_TOOLKIT_API void NotifyAccessibilityStateChange(Dali::Actor control, Dali::Accessibility::States states, bool isRecursive);
565 * The method allows to set specific constructor for creating accessibility structure
567 * Thank to this method hierarchy of accessibility objects can be based on internal hierarchy of Actors.
568 * It prevents from necessity of keeping two trees synchronized.
569 * The method should be called inside OnInitialize method of all classes inheriting from Control.
571 * Possible usage can be as follows:
573 * SetAccessibilityConstructor( []( Dali::Actor actor ) {
574 return std::unique_ptr< Dali::Accessibility::Accessible >(
575 new ControlAccessible( actor, Dali::Accessibility::Role::DIALOG, true ) );
579 * param constructor callback creating Accessible object
581 DALI_TOOLKIT_API void SetAccessibilityConstructor(Dali::Actor control, std::function<std::unique_ptr<Dali::Accessibility::Accessible>(Dali::Actor)> constructor);
584 * Returns accessibility object bound to actor, if any
586 * This method won't bound new accessibility object. Use Dali::Accessibility::Accessible::Get in that case.
588 DALI_TOOLKIT_API Dali::Accessibility::Accessible* GetBoundAccessibilityObject(Dali::Actor control);
590 } // namespace DevelControl
592 } // namespace Toolkit
596 #endif // DALI_TOOLKIT_CONTROL_DEVEL_H