1 #ifndef __DALI_ACCESSIBILITY_MANAGER_H__
2 #define __DALI_ACCESSIBILITY_MANAGER_H__
5 * Copyright (c) 2014 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.
23 * @addtogroup CAPI_DALI_ADAPTOR_MODULE
28 #include <boost/function.hpp>
30 #include <dali/public-api/object/base-handle.h>
31 #include <dali/public-api/signals/dali-signal-v2.h>
32 #include <dali/public-api/events/touch-event.h>
34 namespace Dali DALI_IMPORT_API
37 namespace Internal DALI_INTERNAL
41 class AccessibilityManager;
45 class AccessibilityActionHandler;
46 class AccessibilityGestureHandler;
50 * @brief The AccessibilityManager provides signals when accessibility & screen reader feature turned on in device.
52 class AccessibilityManager : public BaseHandle
59 * @brief Accessibility Action Signal.
61 * Signal connected callback should return the result
63 typedef SignalV2< bool ( AccessibilityManager& ) > AccessibilityActionSignalV2; ///< Generic signal type
64 typedef SignalV2< bool (AccessibilityManager&, const Dali::TouchEvent&)> AccessibilityActionScrollSignalV2; ///< Scroll signal type
67 static const char* const SIGNAL_STATUS_CHANGED; ///< name "accessibility-status-changed"
68 static const char* const SIGNAL_ACTION_NEXT; ///< name "accessibility-action-next"
69 static const char* const SIGNAL_ACTION_PREVIOUS; ///< name "accessibility-action-previous"
70 static const char* const SIGNAL_ACTION_ACTIVATE; ///< name "accessibility-action-activatae"
71 static const char* const SIGNAL_ACTION_OVER; ///< name "accessibility-action-over"
72 static const char* const SIGNAL_ACTION_READ; ///< name "accessibility-action-read"
73 static const char* const SIGNAL_ACTION_READ_NEXT; ///< name "accessibility-action-read-next"
74 static const char* const SIGNAL_ACTION_READ_PREVIOUS; ///< name "accessibility-action-read-prev"
75 static const char* const SIGNAL_ACTION_UP; ///< name "accessibility-action-up"
76 static const char* const SIGNAL_ACTION_DOWN; ///< name "accessibility-action-down"
77 static const char* const SIGNAL_ACTION_CLEAR_FOCUS; ///< name "accessibility-action-clear-focus"
78 static const char* const SIGNAL_ACTION_BACK; ///< name "accessibility-action-back"
79 static const char* const SIGNAL_ACTION_SCROLL; ///< name "accessibility-action-scroll"
82 * @brief Create an uninitialized handle.
84 * This can be initialized by calling getting the manager from Dali::Adaptor.
86 AccessibilityManager();
89 * @brief Retrieve a handle to the AccessibilityManager.
91 * @return A handle to the AccessibilityManager.
93 static AccessibilityManager Get();
98 * This is non-virtual since derived Handle types must not contain data or virtual methods.
100 ~AccessibilityManager();
103 * @brief Returns the current position of the read action.
104 * @return The current event position.
106 Vector2 GetReadPosition() const;
109 * @brief Query whether the accessibility(screen-reader) is enabled.
111 * The accessibility will be enabled by system setting.
112 * @return True if the accessibility(screen-reader) is enabled.
114 bool IsEnabled() const;
117 * @brief Set the handler to handle accessibility actions.
119 * @param[in] handler The Accessibility action handler.
120 * @note Handlers should remove themselves when they are destroyed.
122 void SetActionHandler(AccessibilityActionHandler& handler);
125 * @brief Set the handler to handle accessibility gestures.
127 * @param[in] handler The Accessibility gesture handler.
128 * @note Handlers should remove themselves when they are destroyed.
130 void SetGestureHandler(AccessibilityGestureHandler& handler);
133 * @brief Handle the accessibility action to move focus to the next focusable actor
134 * (by one finger flick down).
136 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
137 * @return Whether the action is performed successfully or not.
139 bool HandleActionNextEvent(bool allowEndFeedback = true);
142 * @brief Handle the accessibility action to move focus to the previous focusable actor
143 * (by one finger flick up).
145 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
146 * @return Whether the action is performed successfully or not.
148 bool HandleActionPreviousEvent(bool allowEndFeedback = true);
151 * @brief Handle the accessibility action to activate the current focused actor (by one
154 * @return Whether the action is performed successfully or not.
156 bool HandleActionActivateEvent();
159 * @brief Handle the accessibility action to focus and read the actor (by one finger tap or move).
161 * @param x x position of event
162 * @param y y position of event
163 * @param allowReadAgain true if the action read again the same object (i.e. read action)
164 * false if the action just read when the focus object is changed (i.e. over action)
165 * @return Whether the action is performed successfully or not.
167 bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
170 * @brief Handle the accessibility action to move focus to the next focusable actor
171 * (by one finger flick right).
173 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
174 * @return Whether the action is performed successfully or not.
176 bool HandleActionReadNextEvent(bool allowEndFeedback = true);
179 * @brief Handle the accessibility action to move focus to the previous focusable actor
180 * (by one finger flick up).
182 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the front
183 * @return Whether the action is performed successfully or not.
185 bool HandleActionReadPreviousEvent(bool allowEndFeedback = true);
188 * @brief Handle the accessibility action to change the value when the current focused
189 * actor is a slider (by double finger down and move up and right).
191 * @return Whether the action is performed successfully or not.
193 bool HandleActionUpEvent();
196 * @brief Handle the accessibility action to change the value when the current focused
197 * actor is a slider (by double finger down and move down and left).
199 * @return Whether the action is performed successfully or not.
201 bool HandleActionDownEvent();
204 * @brief Handle the accessibility action to clear the focus from the current focused
205 * actor if any, so that no actor is focused in the focus chain.
207 * @return Whether the action is performed successfully or not.
209 bool HandleActionClearFocusEvent();
212 * @brief Handle the accessibility action to scroll when there is a scroller on the touched position
213 * (by 2 finger touch & move, 2 finger flick).
215 * @param[in] point The touch point information.
216 * @param[in] timeStamp The time the touch occurred.
217 * @return Whether the action is performed successfully or not.
219 bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
222 * @brief Handle the accessibility action to move for the current focused actor
223 * (by 1 finger tap & hold and move).
225 * @param[in] point The touch point information.
226 * @param[in] timeStamp The time the touch occurred.
227 * @return Whether the action is performed successfully or not.
229 bool HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp);
232 * @brief Handle the accessibility action to navigate back (by two fingers circle draw).
233 * @return Whether the action is performed successfully or not.
235 bool HandleActionBackEvent();
238 * @brief Handle the accessibility action to enable the feature.
240 void HandleActionEnableEvent();
243 * @brief Handle the accessibility action to disable the feature.
245 void HandleActionDisableEvent();
250 * @brief This is emitted when accessibility(screen-reader) feature turned on or off.
252 * A callback of the following type may be connected:
254 * bool YourCallback( AccessibilityManager& manager );
256 * @return The signal to connect to.
258 AccessibilityActionSignalV2& StatusChangedSignal();
261 * @brief This is emitted when accessibility action is received to move focus to the next
262 * focusable actor (by one finger flick down).
264 * A callback of the following type may be connected:
266 * bool YourCallback( AccessibilityManager& manager );
268 * @return The signal to connect to.
270 AccessibilityActionSignalV2& ActionNextSignal();
273 * @brief This is emitted when accessibility action is received to move focus to the previous
274 * focusable actor (by one finger flick up).
276 * A callback of the following type may be connected:
278 * bool YourCallback( AccessibilityManager& manager );
280 * @return The signal to connect to.
282 AccessibilityActionSignalV2& ActionPreviousSignal();
285 * @brief This is emitted when accessibility action is received to activate the current focused
286 * actor (by one finger double tap).
288 * A callback of the following type may be connected:
290 * bool YourCallback( AccessibilityManager& manager );
292 * @return The signal to connect to.
294 AccessibilityActionSignalV2& ActionActivateSignal();
297 * @brief This is emitted when accessibility action is received to focus and read the actor
298 * (by one finger tap).
300 * A callback of the following type may be connected:
302 * bool YourCallback( AccessibilityManager& manager );
304 * @return The signal to connect to.
306 AccessibilityActionSignalV2& ActionReadSignal();
309 * @brief This is emitted when accessibility action is received to focus and read the actor
310 * (by one finger move).
312 * A callback of the following type may be connected:
314 * bool YourCallback( AccessibilityManager& manager );
316 * @return The signal to connect to.
318 AccessibilityActionSignalV2& ActionOverSignal();
321 * @brief This is emitted when accessibility action is received to move focus to the next
322 * focusable actor (by one finger flick right).
324 * A callback of the following type may be connected:
326 * bool YourCallback( AccessibilityManager& manager );
328 * @return The signal to connect to.
330 AccessibilityActionSignalV2& ActionReadNextSignal();
333 * @brief This is emitted when accessibility action is received to move focus to the previous
334 * focusable actor (by one finger flick left).
336 * A callback of the following type may be connected:
338 * bool YourCallback( AccessibilityManager& manager );
340 * @return The signal to connect to.
342 AccessibilityActionSignalV2& ActionReadPreviousSignal();
345 * @brief This is emitted when accessibility action is received to change the value when the
346 * current focused actor is a slider (by double finger down and move up and right).
348 * A callback of the following type may be connected:
350 * bool YourCallback( AccessibilityManager& manager );
352 * @return The signal to connect to.
354 AccessibilityActionSignalV2& ActionUpSignal();
357 * @brief This is emitted when accessibility action is received to change the value when the
358 * current focused actor is a slider (by double finger down and move down and left).
360 * A callback of the following type may be connected:
362 * bool YourCallback( AccessibilityManager& manager );
364 * @return The signal to connect to.
366 AccessibilityActionSignalV2& ActionDownSignal();
369 * @brief This is emitted when accessibility action is received to clear the focus from the
370 * current focused actor if any, so that no actor is focused in the focus chain.
372 * A callback of the following type may be connected:
374 * bool YourCallback( AccessibilityManager& manager );
376 * @return The signal to connect to.
378 AccessibilityActionSignalV2& ActionClearFocusSignal();
381 * @brief This is emitted when accessibility action is received to navigate back (by two
382 * fingers circle draw).
384 * A callback of the following type may be connected:
386 * bool YourCallback( AccessibilityManager& manager );
388 * @return The signal to connect to.
390 AccessibilityActionSignalV2& ActionBackSignal();
393 * @brief This is emitted when accessibility action is received to handle scroll event (by two
396 * A callback of the following type may be connected:
398 * bool YourCallback( AccessibilityManager& manager, const TouchEvent& event );
400 * @return The signal to connect to.
402 AccessibilityActionScrollSignalV2& ActionScrollSignal();
404 public: // Not intended for application developers
407 * @brief Creates a handle using the Adaptor::Internal implementation.
409 * @param[in] manager The AccessibilityManager implementation.
411 AccessibilityManager( Internal::Adaptor::AccessibilityManager& manager );
414 * @brief This constructor is used by AccessibilityManager::Get().
416 * @param[in] manager A pointer to the accessibility manager.
418 AccessibilityManager( Internal::Adaptor::AccessibilityManager* manager );
426 #endif // __DALI_ACCESSIBILITY_MANAGER_H__