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 <boost/function.hpp>
25 #include <dali/public-api/object/base-handle.h>
26 #include <dali/public-api/signals/dali-signal.h>
27 #include <dali/public-api/events/touch-event.h>
32 namespace Internal DALI_INTERNAL
36 class AccessibilityManager;
40 class AccessibilityActionHandler;
41 class AccessibilityGestureHandler;
45 * @brief The AccessibilityManager provides signals when accessibility & screen reader feature turned on in device.
47 class DALI_IMPORT_API AccessibilityManager : public BaseHandle
54 * @brief Accessibility Action Signal.
56 * Signal connected callback should return the result
58 typedef Signal< bool ( AccessibilityManager& ) > AccessibilityActionSignalType; ///< Generic signal type
59 typedef Signal< bool (AccessibilityManager&, const Dali::TouchEvent&)> AccessibilityActionScrollSignalType; ///< Scroll signal type
62 * @brief Create an uninitialized handle.
64 * This can be initialized by calling getting the manager from Dali::Adaptor.
66 AccessibilityManager();
69 * @brief Retrieve a handle to the AccessibilityManager.
71 * @return A handle to the AccessibilityManager.
73 static AccessibilityManager Get();
78 * This is non-virtual since derived Handle types must not contain data or virtual methods.
80 ~AccessibilityManager();
83 * @brief Returns the current position of the read action.
84 * @return The current event position.
86 Vector2 GetReadPosition() const;
89 * @brief Query whether the accessibility(screen-reader) is enabled.
91 * The accessibility will be enabled by system setting.
92 * @return True if the accessibility(screen-reader) is enabled.
94 bool IsEnabled() const;
97 * @brief Set the handler to handle accessibility actions.
99 * @param[in] handler The Accessibility action handler.
100 * @note Handlers should remove themselves when they are destroyed.
102 void SetActionHandler(AccessibilityActionHandler& handler);
105 * @brief Set the handler to handle accessibility gestures.
107 * @param[in] handler The Accessibility gesture handler.
108 * @note Handlers should remove themselves when they are destroyed.
110 void SetGestureHandler(AccessibilityGestureHandler& handler);
113 * @brief Handle the accessibility action to move focus to the next focusable actor
114 * (by one finger flick down).
116 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
117 * @return Whether the action is performed successfully or not.
119 bool HandleActionNextEvent(bool allowEndFeedback = true);
122 * @brief Handle the accessibility action to move focus to the previous focusable actor
123 * (by one finger flick up).
125 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
126 * @return Whether the action is performed successfully or not.
128 bool HandleActionPreviousEvent(bool allowEndFeedback = true);
131 * @brief Handle the accessibility action to activate the current focused actor (by one
134 * @return Whether the action is performed successfully or not.
136 bool HandleActionActivateEvent();
139 * @brief Handle the accessibility action to focus and read the actor (by one finger tap or move).
141 * @param x x position of event
142 * @param y y position of event
143 * @param allowReadAgain true if the action read again the same object (i.e. read action)
144 * false if the action just read when the focus object is changed (i.e. over action)
145 * @return Whether the action is performed successfully or not.
147 bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
150 * @brief Handle the accessibility action to move focus to the next focusable actor
151 * (by one finger flick right).
153 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
154 * @return Whether the action is performed successfully or not.
156 bool HandleActionReadNextEvent(bool allowEndFeedback = true);
159 * @brief Handle the accessibility action to move focus to the previous focusable actor
160 * (by one finger flick up).
162 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the front
163 * @return Whether the action is performed successfully or not.
165 bool HandleActionReadPreviousEvent(bool allowEndFeedback = true);
168 * @brief Handle the accessibility action to change the value when the current focused
169 * actor is a slider (by double finger down and move up and right).
171 * @return Whether the action is performed successfully or not.
173 bool HandleActionUpEvent();
176 * @brief Handle the accessibility action to change the value when the current focused
177 * actor is a slider (by double finger down and move down and left).
179 * @return Whether the action is performed successfully or not.
181 bool HandleActionDownEvent();
184 * @brief Handle the accessibility action to clear the focus from the current focused
185 * actor if any, so that no actor is focused in the focus chain.
187 * @return Whether the action is performed successfully or not.
189 bool HandleActionClearFocusEvent();
192 * @brief Handle the accessibility action to scroll when there is a scroller on the touched position
193 * (by 2 finger touch & move, 2 finger flick).
195 * @param[in] point The touch point information.
196 * @param[in] timeStamp The time the touch occurred.
197 * @return Whether the action is performed successfully or not.
199 bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
202 * @brief Handle the accessibility action to move for the current focused actor
203 * (by 1 finger tap & hold and move).
205 * @param[in] point The touch point information.
206 * @param[in] timeStamp The time the touch occurred.
207 * @return Whether the action is performed successfully or not.
209 bool HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp);
212 * @brief Handle the accessibility action to navigate back (by two fingers circle draw).
213 * @return Whether the action is performed successfully or not.
215 bool HandleActionBackEvent();
218 * @brief Handle the accessibility action to enable the feature.
220 void HandleActionEnableEvent();
223 * @brief Handle the accessibility action to disable the feature.
225 void HandleActionDisableEvent();
230 * @brief This is emitted when accessibility(screen-reader) feature turned on or off.
232 * A callback of the following type may be connected:
234 * bool YourCallback( AccessibilityManager& manager );
236 * @return The signal to connect to.
238 AccessibilityActionSignalType& StatusChangedSignal();
241 * @brief This is emitted when accessibility action is received to move focus to the next
242 * focusable actor (by one finger flick down).
244 * A callback of the following type may be connected:
246 * bool YourCallback( AccessibilityManager& manager );
248 * @return The signal to connect to.
250 AccessibilityActionSignalType& ActionNextSignal();
253 * @brief This is emitted when accessibility action is received to move focus to the previous
254 * focusable actor (by one finger flick up).
256 * A callback of the following type may be connected:
258 * bool YourCallback( AccessibilityManager& manager );
260 * @return The signal to connect to.
262 AccessibilityActionSignalType& ActionPreviousSignal();
265 * @brief This is emitted when accessibility action is received to activate the current focused
266 * actor (by one finger double tap).
268 * A callback of the following type may be connected:
270 * bool YourCallback( AccessibilityManager& manager );
272 * @return The signal to connect to.
274 AccessibilityActionSignalType& ActionActivateSignal();
277 * @brief This is emitted when accessibility action is received to focus and read the actor
278 * (by one finger tap).
280 * A callback of the following type may be connected:
282 * bool YourCallback( AccessibilityManager& manager );
284 * @return The signal to connect to.
286 AccessibilityActionSignalType& ActionReadSignal();
289 * @brief This is emitted when accessibility action is received to focus and read the actor
290 * (by one finger move).
292 * A callback of the following type may be connected:
294 * bool YourCallback( AccessibilityManager& manager );
296 * @return The signal to connect to.
298 AccessibilityActionSignalType& ActionOverSignal();
301 * @brief This is emitted when accessibility action is received to move focus to the next
302 * focusable actor (by one finger flick right).
304 * A callback of the following type may be connected:
306 * bool YourCallback( AccessibilityManager& manager );
308 * @return The signal to connect to.
310 AccessibilityActionSignalType& ActionReadNextSignal();
313 * @brief This is emitted when accessibility action is received to move focus to the previous
314 * focusable actor (by one finger flick left).
316 * A callback of the following type may be connected:
318 * bool YourCallback( AccessibilityManager& manager );
320 * @return The signal to connect to.
322 AccessibilityActionSignalType& ActionReadPreviousSignal();
325 * @brief This is emitted when accessibility action is received to change the value when the
326 * current focused actor is a slider (by double finger down and move up and right).
328 * A callback of the following type may be connected:
330 * bool YourCallback( AccessibilityManager& manager );
332 * @return The signal to connect to.
334 AccessibilityActionSignalType& ActionUpSignal();
337 * @brief This is emitted when accessibility action is received to change the value when the
338 * current focused actor is a slider (by double finger down and move down and left).
340 * A callback of the following type may be connected:
342 * bool YourCallback( AccessibilityManager& manager );
344 * @return The signal to connect to.
346 AccessibilityActionSignalType& ActionDownSignal();
349 * @brief This is emitted when accessibility action is received to clear the focus from the
350 * current focused actor if any, so that no actor is focused in the focus chain.
352 * A callback of the following type may be connected:
354 * bool YourCallback( AccessibilityManager& manager );
356 * @return The signal to connect to.
358 AccessibilityActionSignalType& ActionClearFocusSignal();
361 * @brief This is emitted when accessibility action is received to navigate back (by two
362 * fingers circle draw).
364 * A callback of the following type may be connected:
366 * bool YourCallback( AccessibilityManager& manager );
368 * @return The signal to connect to.
370 AccessibilityActionSignalType& ActionBackSignal();
373 * @brief This is emitted when accessibility action is received to handle scroll event (by two
376 * A callback of the following type may be connected:
378 * bool YourCallback( AccessibilityManager& manager, const TouchEvent& event );
380 * @return The signal to connect to.
382 AccessibilityActionScrollSignalType& ActionScrollSignal();
384 public: // Not intended for application developers
387 * @brief Creates a handle using the Adaptor::Internal implementation.
389 * @param[in] manager The AccessibilityManager implementation.
391 DALI_INTERNAL AccessibilityManager( Internal::Adaptor::AccessibilityManager& manager );
394 * @brief This constructor is used by AccessibilityManager::Get().
396 * @param[in] manager A pointer to the accessibility manager.
398 explicit DALI_INTERNAL AccessibilityManager( Internal::Adaptor::AccessibilityManager* manager );
403 #endif // __DALI_ACCESSIBILITY_MANAGER_H__