1 #ifndef __DALI_TOOLKIT_ACCESSIBILITY_MANAGER_H__
2 #define __DALI_TOOLKIT_ACCESSIBILITY_MANAGER_H__
5 * Copyright (c) 2015 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.
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/actors/image-actor.h>
31 namespace Internal DALI_INTERNAL
33 class AccessibilityManager;
37 * @brief Manages registration of actors in a accessibility focus chain and changing the
38 * focused actor within that chain.
40 * This class provides the functionality of registering the focus order and description
41 * of actors and maintaining the focus chain.
43 * It provides functionality of setting the
44 * focus and moving the focus forward and backward. It also draws a highlight for the
45 * focused actor and emits a signal when the focus is changed.
48 * | %Signal Name | Method |
49 * |-------------------------|------------------------------------|
50 * | focus-changed | @ref FocusChangedSignal() |
51 * | focus-overshot | @ref FocusOvershotSignal() |
52 * | focused-actor-activated | @ref FocusedActorActivatedSignal() |
54 class DALI_IMPORT_API AccessibilityManager : public BaseHandle
61 * @brief Accessibility Action Signal.
63 * The connected signal callback should return true if handled.
65 typedef Signal< bool ( AccessibilityManager& ) > AccessibilityActionSignalType; ///< Generic signal type
66 typedef Signal< bool ( AccessibilityManager&, const Dali::TouchEvent& )> AccessibilityActionScrollSignalType; ///< Scroll signal type
69 * @brief Accessibility needs four information which will be read by screen-reader.
71 * Reading order : Label -> Trait -> Optional (Value and Hint)
73 enum AccessibilityAttribute
75 ACCESSIBILITY_LABEL = 0, ///< Simple text which contained in ui-control
76 ACCESSIBILITY_TRAIT, ///< Description of ui-control trait
77 ACCESSIBILITY_VALUE, ///< Current value of ui-control (Optional)
78 ACCESSIBILITY_HINT, ///< Hint for action (Optional)
79 ACCESSIBILITY_ATTRIBUTE_NUM ///< Number of attributes
83 * @brief Overshoot direction.
85 enum FocusOvershotDirection
87 OVERSHOT_PREVIOUS = -1, ///< Try to move previous of the first actor
88 OVERSHOT_NEXT = 1, ///< Try to move next of the last actor
93 /// @brief Focus changed signal
94 typedef Signal< void ( Actor, Actor ) > FocusChangedSignalType;
96 /// @brief Focus overshooted signal
97 typedef Signal< void ( Actor, FocusOvershotDirection ) > FocusOvershotSignalType;
99 /// @brief Focused actor activated signal
100 typedef Signal< void ( Actor ) > FocusedActorActivatedSignalType;
103 * @brief Create a AccessibilityManager handle; this can be initialised with AccessibilityManager::New().
105 * Calling member functions with an uninitialised handle is not allowed.
107 AccessibilityManager();
112 * This is non-virtual since derived Handle types must not contain data or virtual methods.
114 ~AccessibilityManager();
117 * @brief Get the singleton of AccessibilityManager object.
119 * @return A handle to the AccessibilityManager control.
121 static AccessibilityManager Get();
124 * @brief Set the information of the specified actor's accessibility attribute.
126 * @pre The AccessibilityManager has been initialized.
127 * @pre The Actor has been initialized.
128 * @param actor The actor the text to be set with
129 * @param type The attribute type the text to be set with
130 * @param text The text for the actor's accessibility information
132 void SetAccessibilityAttribute(Actor actor, AccessibilityAttribute type, const std::string& text);
135 * @brief Get the text of the specified actor's accessibility attribute.
137 * @pre The AccessibilityManager has been initialized.
138 * @pre The Actor has been initialized.
139 * @param actor The actor to be queried
140 * @param type The attribute type to be queried
141 * @return The text of the actor's accessibility information
143 std::string GetAccessibilityAttribute(Actor actor, AccessibilityAttribute type) const;
146 * @brief Set the focus order of the actor.
148 * The focus order of each actor in the focus chain is unique. If
149 * there is another actor assigned with the same focus order
150 * already, the new actor will be inserted to the focus chain with
151 * that focus order, and the focus order of the original actor and
152 * all the actors followed in the focus chain will be increased
153 * accordingly. If the focus order assigned to the actor is 0, it
154 * means that actor's focus order is undefined (e.g. the actor has a
155 * description but with no focus order being set yet) and therefore
156 * that actor is not focusable.
158 * @pre The AccessibilityManager has been initialized.
159 * @pre The Actor has been initialized.
160 * @param actor The actor the focus order to be set with
161 * @param order The focus order of the actor
163 void SetFocusOrder(Actor actor, const unsigned int order);
166 * @brief Get the focus order of the actor.
168 * When the focus order is 0, it means the focus order of the actor
171 * @pre The AccessibilityManager has been initialized.
172 * @pre The Actor has been initialized.
173 * @param actor The actor to be queried
174 * @return The focus order of the actor
176 unsigned int GetFocusOrder(Actor actor) const;
179 * @brief Generates a new focus order number which can be used to
180 * assign to actors which need to be appended to the end of the
181 * current focus order chain.
183 * The new number will be an increment over the very last focus
184 * order number in the focus chain. If the focus chain is empty then
185 * the function returns 1, else the number returned will be FOLast +
186 * 1 where FOLast is the focus order of the very last control in the
189 * @pre The AccessibilityManager has been initialized.
190 * @return The focus order of the actor
192 unsigned int GenerateNewFocusOrder() const;
195 * @brief Get the actor that has the specified focus order.
197 * It will return an empty handle if the actor is not in the stage
198 * or has a focus order of 0.
200 * @pre The AccessibilityManager has been initialized.
201 * @param order The focus order of the actor
203 * @return The actor that has the specified focus order or an empty
204 * handle if no actor in the stage has the specified focus order.
206 Actor GetActorByFocusOrder(const unsigned int order);
209 * @brief Move the focus to the specified actor.
211 * Only one actor can be focused at the same time. The actor must
212 * have a defined focus order and must be focusable, visible and in
215 * @pre The AccessibilityManager has been initialized.
216 * @pre The Actor has been initialized.
217 * @param actor The actor to be focused
218 * @return Whether the focus is successful or not
220 bool SetCurrentFocusActor(Actor actor);
223 * @brief Get the current focused actor.
225 * @pre The AccessibilityManager has been initialized.
226 * @return A handle to the current focused actor or an empty handle if no actor is focused.
228 Actor GetCurrentFocusActor();
231 * @brief Get the focus group of current focused actor.
233 * @pre The AccessibilityManager has been initialized.
235 * @return A handle to the immediate parent of the current focused
236 * actor which is also a focus group, or an empty handle if no actor
239 Actor GetCurrentFocusGroup();
242 * @brief Get the focus order of currently focused actor.
243 * @pre The AccessibilityManager has been initialized.
245 * @return The focus order of the currently focused actor or 0 if no
248 unsigned int GetCurrentFocusOrder();
251 * @brief Move the focus to the next focusable actor in the focus
252 * chain (according to the focus traversal order).
254 * When the focus movement is wrapped around, the focus will be moved
255 * to the first focusable actor when it reaches the end of the focus chain.
257 * @pre The AccessibilityManager has been initialized.
258 * @return true if the moving was successful
260 bool MoveFocusForward();
263 * @brief Move the focus to the previous focusable actor in the
264 * focus chain (according to the focus traversal order).
266 * When the focus movement is wrapped around, the focus will be
267 * moved to the last focusable actor when it reaches the beginning
268 * of the focus chain.
270 * @pre The AccessibilityManager has been initialized.
271 * @return true if the moving was successful
273 bool MoveFocusBackward();
276 * @brief Clear the focus from the current focused actor if any, so
277 * that no actor is focused in the focus chain.
279 * It will emit focus changed signal without current focused actor
280 * @pre The AccessibilityManager has been initialized.
285 * @brief Clear the every registered focusable actor from focus-manager.
286 * @pre The AccessibilityManager has been initialized.
291 * @brief Set whether an actor is a focus group that can limit the
292 * scope of focus movement to its child actors in the focus chain.
294 * @pre The AccessibilityManager has been initialized.
295 * @pre The Actor has been initialized.
296 * @param actor The actor to be set as a focus group.
297 * @param isFocusGroup Whether to set the actor to be a focus group or not.
299 void SetFocusGroup(Actor actor, bool isFocusGroup);
302 * @brief Check whether the actor is set as a focus group or not.
304 * @pre The AccessibilityManager has been initialized.
305 * @pre The Actor has been initialized.
306 * @param actor The actor to be checked.
307 * @return Whether the actor is set as a focus group.
309 bool IsFocusGroup(Actor actor) const;
312 * @brief Set whether the group mode is enabled or not.
314 * When the group mode is enabled, the focus movement will be limited to the child actors
315 * of the current focus group including the current focus group itself. The current focus
316 * group is the closest ancestor of the current focused actor that set as a focus group.
317 * @pre The AccessibilityManager has been initialized.
318 * @param enabled Whether the group mode is enabled or not
320 void SetGroupMode(bool enabled);
323 * @brief Get whether the group mode is enabled or not.
325 * @pre The AccessibilityManager has been initialized.
326 * @return Whether the group mode is enabled or not.
328 bool GetGroupMode() const;
331 * @brief Set whether focus will be moved to the beginning of the
332 * focus chain when it reaches the end or vice versa.
334 * When both the wrap mode and the group mode are enabled, focus will be
335 * wrapped within the current focus group. Focus will not be wrapped in default.
336 * @pre The AccessibilityManager has been initialized.
337 * @param wrapped Whether the focus movement is wrapped around or not
339 void SetWrapMode(bool wrapped);
342 * @brief Get whether the wrap mode is enabled or not.
344 * @pre The AccessibilityManager has been initialized.
345 * @return Whether the wrap mode is enabled or not.
347 bool GetWrapMode() const;
350 * @brief Set the focus indicator actor.
352 * This will replace the default focus indicator actor in
353 * AccessibilityManager and will be added to the focused actor as a
356 * @pre The AccessibilityManager has been initialized.
357 * @pre The indicator actor has been initialized.
358 * @param indicator The indicator actor to be added
360 void SetFocusIndicatorActor(Actor indicator);
363 * @brief Get the focus indicator actor.
365 * @pre The AccessibilityManager has been initialized.
366 * @return A handle to the focus indicator actor
368 Actor GetFocusIndicatorActor();
371 * @brief Returns the closest ancestor of the given actor that is a focus group.
373 * @param actor The actor to be checked for its focus group
374 * @return The focus group the given actor belongs to or an empty handle if the given actor doesn't belong to any focus group
376 Actor GetFocusGroup(Actor actor);
381 * @brief This signal is emitted when the current focused actor is changed.
383 * A callback of the following type may be connected:
385 * void YourCallbackName(Actor originalFocusedActor, Actor currentFocusedActor);
387 * @pre The Object has been initialized.
388 * @return The signal to connect to.
390 FocusChangedSignalType& FocusChangedSignal();
393 * @brief This signal is emitted when there is no way to move focus further.
395 * A callback of the following type may be connected:
397 * void YourCallbackName(Actor currentFocusedActor, FocusOvershotDirection direction);
399 * @pre The Object has been initialized.
400 * @return The signal to connect to.
402 FocusOvershotSignalType& FocusOvershotSignal();
405 * @brief This signal is emitted when the current focused actor is activated.
407 * A callback of the following type may be connected:
409 * void YourCallbackName(Actor activatedActor);
411 * @pre The Object has been initialized.
412 * @return The signal to connect to.
414 FocusedActorActivatedSignalType& FocusedActorActivatedSignal();
416 public: // Accessibility action signals.
419 * @brief This is emitted when accessibility(screen-reader) feature turned on or off.
421 * A callback of the following type may be connected:
423 * bool YourCallback( AccessibilityManager& manager );
425 * @return The signal to connect to.
427 AccessibilityActionSignalType& StatusChangedSignal();
430 * @brief This is emitted when accessibility action is received to move focus to the next
431 * focusable actor (by one finger flick down).
433 * A callback of the following type may be connected:
435 * bool YourCallback( AccessibilityManager& manager );
437 * @return The signal to connect to.
439 AccessibilityActionSignalType& ActionNextSignal();
442 * @brief This is emitted when accessibility action is received to move focus to the previous
443 * focusable actor (by one finger flick up).
445 * A callback of the following type may be connected:
447 * bool YourCallback( AccessibilityManager& manager );
449 * @return The signal to connect to.
451 AccessibilityActionSignalType& ActionPreviousSignal();
454 * @brief This is emitted when accessibility action is received to activate the current focused
455 * actor (by one finger double tap).
457 * A callback of the following type may be connected:
459 * bool YourCallback( AccessibilityManager& manager );
461 * @return The signal to connect to.
463 AccessibilityActionSignalType& ActionActivateSignal();
466 * @brief This is emitted when accessibility action is received to focus and read the actor
467 * (by one finger tap).
469 * A callback of the following type may be connected:
471 * bool YourCallback( AccessibilityManager& manager );
473 * @return The signal to connect to.
475 AccessibilityActionSignalType& ActionReadSignal();
478 * @brief This is emitted when accessibility action is received to focus and read the actor
479 * (by one finger move).
481 * A callback of the following type may be connected:
483 * bool YourCallback( AccessibilityManager& manager );
485 * @return The signal to connect to.
487 AccessibilityActionSignalType& ActionOverSignal();
490 * @brief This is emitted when accessibility action is received to move focus to the next
491 * focusable actor (by one finger flick right).
493 * A callback of the following type may be connected:
495 * bool YourCallback( AccessibilityManager& manager );
497 * @return The signal to connect to.
499 AccessibilityActionSignalType& ActionReadNextSignal();
502 * @brief This is emitted when accessibility action is received to move focus to the previous
503 * focusable actor (by one finger flick left).
505 * A callback of the following type may be connected:
507 * bool YourCallback( AccessibilityManager& manager );
509 * @return The signal to connect to.
511 AccessibilityActionSignalType& ActionReadPreviousSignal();
514 * @brief This is emitted when accessibility action is received to change the value when the
515 * current focused actor is a slider (by double finger down and move up and right).
517 * A callback of the following type may be connected:
519 * bool YourCallback( AccessibilityManager& manager );
521 * @return The signal to connect to.
523 AccessibilityActionSignalType& ActionUpSignal();
526 * @brief This is emitted when accessibility action is received to change the value when the
527 * current focused actor is a slider (by double finger down and move down and left).
529 * A callback of the following type may be connected:
531 * bool YourCallback( AccessibilityManager& manager );
533 * @return The signal to connect to.
535 AccessibilityActionSignalType& ActionDownSignal();
538 * @brief This is emitted when accessibility action is received to clear the focus from the
539 * current focused actor if any, so that no actor is focused in the focus chain.
541 * A callback of the following type may be connected:
543 * bool YourCallback( AccessibilityManager& manager );
545 * @return The signal to connect to.
547 AccessibilityActionSignalType& ActionClearFocusSignal();
550 * @brief This is emitted when accessibility action is received to navigate back (by two
551 * fingers circle draw).
553 * A callback of the following type may be connected:
555 * bool YourCallback( AccessibilityManager& manager );
557 * @return The signal to connect to.
559 AccessibilityActionSignalType& ActionBackSignal();
562 * @brief This is emitted when accessibility action is received to scroll up the list
563 * (by two finger swipe up).
565 * A callback of the following type may be connected:
567 * bool YourCallback( AccessibilityManager& manager );
569 * @return The signal to connect to.
571 AccessibilityActionSignalType& ActionScrollUpSignal();
574 * @brief This is emitted when accessibility action is received to scroll down the list
575 * (by two finger swipe down).
577 * A callback of the following type may be connected:
579 * bool YourCallback( AccessibilityManager& manager );
581 * @return The signal to connect to.
583 AccessibilityActionSignalType& ActionScrollDownSignal();
586 * @brief This is emitted when accessibility action is received to scroll left to the
587 * previous page (by two finger swipe left)
589 * A callback of the following type may be connected:
591 * bool YourCallback( AccessibilityManager& manager );
593 * @return The signal to connect to.
595 AccessibilityActionSignalType& ActionPageLeftSignal();
598 * @brief This is emitted when accessibility action is received to scroll right to the
599 * next page (by two finger swipe right)
601 * A callback of the following type may be connected:
603 * bool YourCallback( AccessibilityManager& manager );
605 * @return The signal to connect to.
607 AccessibilityActionSignalType& ActionPageRightSignal();
610 * @brief This is emitted when accessibility action is received to scroll up to the
611 * previous page (by one finger swipe left and right)
613 * A callback of the following type may be connected:
615 * bool YourCallback( AccessibilityManager& manager );
617 * @return The signal to connect to.
619 AccessibilityActionSignalType& ActionPageUpSignal();
622 * @brief This is emitted when accessibility action is received to scroll down to the
623 * next page (by one finger swipe right and left)
625 * A callback of the following type may be connected:
627 * bool YourCallback( AccessibilityManager& manager );
629 * @return The signal to connect to.
631 AccessibilityActionSignalType& ActionPageDownSignal();
634 * @brief This is emitted when accessibility action is received to move the focus to
635 * the first item on the screen (by one finger swipe up and down)
637 * A callback of the following type may be connected:
639 * bool YourCallback( AccessibilityManager& manager );
641 * @return The signal to connect to.
643 AccessibilityActionSignalType& ActionMoveToFirstSignal();
646 * @brief This is emitted when accessibility action is received to move the focus to
647 * the last item on the screen (by one finger swipe down and up)
649 * A callback of the following type may be connected:
651 * bool YourCallback( AccessibilityManager& manager );
653 * @return The signal to connect to.
655 AccessibilityActionSignalType& ActionMoveToLastSignal();
658 * @brief This is emitted when accessibility action is received to focus and read from the
659 * first item on the top continously (by three fingers single tap)
661 * A callback of the following type may be connected:
663 * bool YourCallback( AccessibilityManager& manager );
665 * @return The signal to connect to.
667 AccessibilityActionSignalType& ActionReadFromTopSignal();
670 * @brief This is emitted when accessibility action is received to move the focus to and
671 * read from the next item continously (by three fingers double tap)
673 * A callback of the following type may be connected:
675 * bool YourCallback( AccessibilityManager& manager );
677 * @return The signal to connect to.
679 AccessibilityActionSignalType& ActionReadFromNextSignal();
682 * @brief This is emitted when accessibility action is received to zoom (by one finger
685 * A callback of the following type may be connected:
687 * bool YourCallback( AccessibilityManager& manager );
689 * @return The signal to connect to.
691 AccessibilityActionSignalType& ActionZoomSignal();
694 * @brief This is emitted when accessibility action is received to read the information
695 * in the indicator (by two fingers triple tap).
697 * A callback of the following type may be connected:
699 * bool YourCallback( AccessibilityManager& manager );
701 * @return The signal to connect to.
703 AccessibilityActionSignalType& ActionReadIndicatorInformationSignal();
706 * @brief This is emitted when accessibility action is received to pause/resume the
707 * current speech (by two fingers single tap).
709 * A callback of the following type may be connected:
711 * bool YourCallback( AccessibilityManager& manager );
713 * @return The signal to connect to.
715 AccessibilityActionSignalType& ActionReadPauseResumeSignal();
718 * @brief This is emitted when accessibility action is received to start/stop the
719 * current action (by two fingers double tap).
721 * A callback of the following type may be connected:
723 * bool YourCallback( AccessibilityManager& manager );
725 * @return The signal to connect to.
727 AccessibilityActionSignalType& ActionStartStopSignal();
730 * @brief This is emitted when accessibility action is received to handle scroll event (by two
733 * A callback of the following type may be connected:
735 * bool YourCallback( AccessibilityManager& manager, const TouchEvent& event );
737 * @return The signal to connect to.
739 AccessibilityActionScrollSignalType& ActionScrollSignal();
743 explicit DALI_INTERNAL AccessibilityManager( Internal::AccessibilityManager *impl );
745 }; // class AccessibilityManager
747 } // namespace Toolkit
751 #endif // __DALI_TOOLKIT_ACCESSIBILITY_MANAGER_H__