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 #include <dali/public-api/events/touch-event.h>
24 #include <dali/public-api/object/base-handle.h>
25 #include <dali/public-api/signals/dali-signal.h>
30 namespace Internal DALI_INTERNAL
34 class AccessibilityManager;
38 class AccessibilityActionHandler;
39 class AccessibilityGestureHandler;
43 * @brief The AccessibilityManager provides signals when accessibility & screen reader feature turned on in device.
45 class DALI_IMPORT_API AccessibilityManager : public BaseHandle
52 * @brief Accessibility Action Signal.
54 * Signal connected callback should return the result
56 typedef Signal< bool ( AccessibilityManager& ) > AccessibilityActionSignalType; ///< Generic signal type
57 typedef Signal< bool (AccessibilityManager&, const Dali::TouchEvent&)> AccessibilityActionScrollSignalType; ///< Scroll signal type
60 * @brief Create an uninitialized handle.
62 * This can be initialized by calling getting the manager from Dali::Adaptor.
64 AccessibilityManager();
67 * @brief Retrieve a handle to the AccessibilityManager.
69 * @return A handle to the AccessibilityManager.
71 static AccessibilityManager Get();
76 * This is non-virtual since derived Handle types must not contain data or virtual methods.
78 ~AccessibilityManager();
81 * @brief Returns the current position of the read action.
82 * @return The current event position.
84 Vector2 GetReadPosition() const;
87 * @brief Query whether the accessibility(screen-reader) is enabled.
89 * The accessibility will be enabled by system setting.
90 * @return True if the accessibility(screen-reader) is enabled.
92 bool IsEnabled() const;
95 * @brief Set the handler to handle accessibility actions.
97 * @param[in] handler The Accessibility action handler.
98 * @note Handlers should remove themselves when they are destroyed.
100 void SetActionHandler(AccessibilityActionHandler& handler);
103 * @brief Set the handler to handle accessibility gestures.
105 * @param[in] handler The Accessibility gesture handler.
106 * @note Handlers should remove themselves when they are destroyed.
108 void SetGestureHandler(AccessibilityGestureHandler& handler);
111 * @brief Handle the accessibility action to move focus to the next focusable actor
112 * (by one finger flick down).
114 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
115 * @return Whether the action is performed successfully or not.
117 bool HandleActionNextEvent(bool allowEndFeedback = true);
120 * @brief Handle the accessibility action to move focus to the previous focusable actor
121 * (by one finger flick up).
123 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
124 * @return Whether the action is performed successfully or not.
126 bool HandleActionPreviousEvent(bool allowEndFeedback = true);
129 * @brief Handle the accessibility action to activate the current focused actor (by one
132 * @return Whether the action is performed successfully or not.
134 bool HandleActionActivateEvent();
137 * @brief Handle the accessibility action to focus and read the actor (by one finger tap or move).
139 * @param x x position of event
140 * @param y y position of event
141 * @param allowReadAgain true if the action read again the same object (i.e. read action)
142 * false if the action just read when the focus object is changed (i.e. over action)
143 * @return Whether the action is performed successfully or not.
145 bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
148 * @brief Handle the accessibility action to move focus to the next focusable actor
149 * (by one finger flick right).
151 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
152 * @return Whether the action is performed successfully or not.
154 bool HandleActionReadNextEvent(bool allowEndFeedback = true);
157 * @brief Handle the accessibility action to move focus to the previous focusable actor
158 * (by one finger flick up).
160 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the front
161 * @return Whether the action is performed successfully or not.
163 bool HandleActionReadPreviousEvent(bool allowEndFeedback = true);
166 * @brief Handle the accessibility action to change the value when the current focused
167 * actor is a slider (by double finger down and move up and right).
169 * @return Whether the action is performed successfully or not.
171 bool HandleActionUpEvent();
174 * @brief Handle the accessibility action to change the value when the current focused
175 * actor is a slider (by double finger down and move down and left).
177 * @return Whether the action is performed successfully or not.
179 bool HandleActionDownEvent();
182 * @brief Handle the accessibility action to clear the focus from the current focused
183 * actor if any, so that no actor is focused in the focus chain.
185 * @return Whether the action is performed successfully or not.
187 bool HandleActionClearFocusEvent();
190 * @brief Handle the accessibility action to scroll when there is a scroller on the touched position
191 * (by 2 finger touch & move, 2 finger flick).
193 * @param[in] point The touch point information.
194 * @param[in] timeStamp The time the touch occurred.
195 * @return Whether the action is performed successfully or not.
197 bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
200 * @brief Handle the accessibility action to move for the current focused actor
201 * (by 1 finger tap & hold and move).
203 * @param[in] point The touch point information.
204 * @param[in] timeStamp The time the touch occurred.
205 * @return Whether the action is performed successfully or not.
207 bool HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp);
210 * @brief Handle the accessibility action to navigate back (by two fingers circle draw).
211 * @return Whether the action is performed successfully or not.
213 bool HandleActionBackEvent();
216 * @brief Handle the accessibility action to enable the feature.
218 void HandleActionEnableEvent();
221 * @brief Handle the accessibility action to disable the feature.
223 void HandleActionDisableEvent();
228 * @brief This is emitted when accessibility(screen-reader) feature turned on or off.
230 * A callback of the following type may be connected:
232 * bool YourCallback( AccessibilityManager& manager );
234 * @return The signal to connect to.
236 AccessibilityActionSignalType& StatusChangedSignal();
239 * @brief This is emitted when accessibility action is received to move focus to the next
240 * focusable actor (by one finger flick down).
242 * A callback of the following type may be connected:
244 * bool YourCallback( AccessibilityManager& manager );
246 * @return The signal to connect to.
248 AccessibilityActionSignalType& ActionNextSignal();
251 * @brief This is emitted when accessibility action is received to move focus to the previous
252 * focusable actor (by one finger flick up).
254 * A callback of the following type may be connected:
256 * bool YourCallback( AccessibilityManager& manager );
258 * @return The signal to connect to.
260 AccessibilityActionSignalType& ActionPreviousSignal();
263 * @brief This is emitted when accessibility action is received to activate the current focused
264 * actor (by one finger double tap).
266 * A callback of the following type may be connected:
268 * bool YourCallback( AccessibilityManager& manager );
270 * @return The signal to connect to.
272 AccessibilityActionSignalType& ActionActivateSignal();
275 * @brief This is emitted when accessibility action is received to focus and read the actor
276 * (by one finger tap).
278 * A callback of the following type may be connected:
280 * bool YourCallback( AccessibilityManager& manager );
282 * @return The signal to connect to.
284 AccessibilityActionSignalType& ActionReadSignal();
287 * @brief This is emitted when accessibility action is received to focus and read the actor
288 * (by one finger move).
290 * A callback of the following type may be connected:
292 * bool YourCallback( AccessibilityManager& manager );
294 * @return The signal to connect to.
296 AccessibilityActionSignalType& ActionOverSignal();
299 * @brief This is emitted when accessibility action is received to move focus to the next
300 * focusable actor (by one finger flick right).
302 * A callback of the following type may be connected:
304 * bool YourCallback( AccessibilityManager& manager );
306 * @return The signal to connect to.
308 AccessibilityActionSignalType& ActionReadNextSignal();
311 * @brief This is emitted when accessibility action is received to move focus to the previous
312 * focusable actor (by one finger flick left).
314 * A callback of the following type may be connected:
316 * bool YourCallback( AccessibilityManager& manager );
318 * @return The signal to connect to.
320 AccessibilityActionSignalType& ActionReadPreviousSignal();
323 * @brief This is emitted when accessibility action is received to change the value when the
324 * current focused actor is a slider (by double finger down and move up and right).
326 * A callback of the following type may be connected:
328 * bool YourCallback( AccessibilityManager& manager );
330 * @return The signal to connect to.
332 AccessibilityActionSignalType& ActionUpSignal();
335 * @brief This is emitted when accessibility action is received to change the value when the
336 * current focused actor is a slider (by double finger down and move down and left).
338 * A callback of the following type may be connected:
340 * bool YourCallback( AccessibilityManager& manager );
342 * @return The signal to connect to.
344 AccessibilityActionSignalType& ActionDownSignal();
347 * @brief This is emitted when accessibility action is received to clear the focus from the
348 * current focused actor if any, so that no actor is focused in the focus chain.
350 * A callback of the following type may be connected:
352 * bool YourCallback( AccessibilityManager& manager );
354 * @return The signal to connect to.
356 AccessibilityActionSignalType& ActionClearFocusSignal();
359 * @brief This is emitted when accessibility action is received to navigate back (by two
360 * fingers circle draw).
362 * A callback of the following type may be connected:
364 * bool YourCallback( AccessibilityManager& manager );
366 * @return The signal to connect to.
368 AccessibilityActionSignalType& ActionBackSignal();
371 * @brief This is emitted when accessibility action is received to handle scroll event (by two
374 * A callback of the following type may be connected:
376 * bool YourCallback( AccessibilityManager& manager, const TouchEvent& event );
378 * @return The signal to connect to.
380 AccessibilityActionScrollSignalType& ActionScrollSignal();
382 public: // Not intended for application developers
385 * @brief Creates a handle using the Adaptor::Internal implementation.
387 * @param[in] manager The AccessibilityManager implementation.
389 DALI_INTERNAL AccessibilityManager( Internal::Adaptor::AccessibilityManager& manager );
392 * @brief This constructor is used by AccessibilityManager::Get().
394 * @param[in] manager A pointer to the accessibility manager.
396 explicit DALI_INTERNAL AccessibilityManager( Internal::Adaptor::AccessibilityManager* manager );
401 #endif // __DALI_ACCESSIBILITY_MANAGER_H__