1 #ifndef DALI_ACCESSIBILITY_ADAPTOR_H
2 #define DALI_ACCESSIBILITY_ADAPTOR_H
5 * Copyright (c) 2019 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-point.h>
24 #include <dali/public-api/object/base-handle.h>
25 #include <dali/public-api/dali-adaptor-common.h>
30 namespace Internal DALI_INTERNAL
34 class AccessibilityAdaptor;
38 class AccessibilityActionHandler;
39 class AccessibilityGestureHandler;
43 * @brief The AccessibilityAdaptor provides communication to the accessibility manager interface (implemented in toolkit).
46 class DALI_ADAPTOR_API AccessibilityAdaptor : public BaseHandle
51 * @brief Create an uninitialized handle.
53 * This can be initialized by calling getting the adaptor from Dali::Adaptor.
55 AccessibilityAdaptor();
58 * @brief Retrieve a handle to the AccessibilityAdaptor.
60 * @return A handle to the AccessibilityAdaptor.
62 static AccessibilityAdaptor Get();
67 * This is non-virtual since derived Handle types must not contain data or virtual methods.
69 ~AccessibilityAdaptor();
72 * @brief Returns the current position of the read action.
73 * @return The current event position.
75 Vector2 GetReadPosition() const;
78 * @brief Query whether the accessibility(screen-reader) is enabled.
80 * The accessibility will be enabled by system setting.
81 * @return True if the accessibility(screen-reader) is enabled.
83 bool IsEnabled() const;
86 * @brief Set the handler to handle accessibility actions.
88 * @param[in] handler The Accessibility action handler.
89 * @note Handlers should remove themselves when they are destroyed.
91 void SetActionHandler(AccessibilityActionHandler& handler);
94 * @brief Set the handler to handle accessibility gestures.
96 * @param[in] handler The Accessibility gesture handler.
97 * @note Handlers should remove themselves when they are destroyed.
99 void SetGestureHandler(AccessibilityGestureHandler& handler);
102 * @brief Handle the accessibility action to move focus to the next focusable actor
103 * (by one finger flick down).
105 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
106 * @return Whether the action is performed successfully or not.
108 bool HandleActionNextEvent(bool allowEndFeedback = true);
111 * @brief Handle the accessibility action to move focus to the previous focusable actor
112 * (by one finger flick up).
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 HandleActionPreviousEvent(bool allowEndFeedback = true);
120 * @brief Handle the accessibility action to activate the current focused actor (by one
123 * @return Whether the action is performed successfully or not.
125 bool HandleActionActivateEvent();
128 * @brief Handle the accessibility action to focus and read the actor (by one finger tap or move).
130 * @param x x position of event
131 * @param y y position of event
132 * @param allowReadAgain true if the action read again the same object (i.e. read action)
133 * false if the action just read when the focus object is changed (i.e. over action)
134 * @return Whether the action is performed successfully or not.
136 bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
139 * @brief Handle the accessibility action to move focus to the next focusable actor
140 * (by one finger flick right).
142 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
143 * @return Whether the action is performed successfully or not.
145 bool HandleActionReadNextEvent(bool allowEndFeedback = true);
148 * @brief Handle the accessibility action to move focus to the previous focusable actor
149 * (by one finger flick up).
151 * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the front
152 * @return Whether the action is performed successfully or not.
154 bool HandleActionReadPreviousEvent(bool allowEndFeedback = true);
157 * @brief Handle the accessibility action to change the value when the current focused
158 * actor is a slider (by double finger down and move up and right).
160 * @return Whether the action is performed successfully or not.
162 bool HandleActionUpEvent();
165 * @brief Handle the accessibility action to change the value when the current focused
166 * actor is a slider (by double finger down and move down and left).
168 * @return Whether the action is performed successfully or not.
170 bool HandleActionDownEvent();
173 * @brief Handle the accessibility action to clear the focus from the current focused
174 * actor if any, so that no actor is focused in the focus chain.
176 * @return Whether the action is performed successfully or not.
178 bool HandleActionClearFocusEvent();
181 * @brief Handle the accessibility action to scroll when there is a scroller on the touched position
182 * (by 2 finger touch & move, 2 finger flick).
184 * @param[in] point The touch point information.
185 * @param[in] timeStamp The time the touch occurred.
186 * @return Whether the action is performed successfully or not.
188 bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
191 * @brief Handle the accessibility action to navigate back (by two fingers circle draw).
192 * @return Whether the action is performed successfully or not.
194 bool HandleActionBackEvent();
197 * @brief Handle the accessibility action to enable the feature.
199 void HandleActionEnableEvent();
202 * @brief Handle the accessibility action to disable the feature.
204 void HandleActionDisableEvent();
207 * @brief Handle the accessibility action to scroll up the list and focus on
208 * the first item on the list after the scrolling and read the item
209 * (by two finger swipe up).
211 * @return Whether the action is performed successfully or not.
213 bool HandleActionScrollUpEvent();
216 * @brief Handle the accessibility action to scroll down the list and focus on
217 * the first item on the list after the scrolling and read the item
218 * (by two finger swipe down).
220 * @return Whether the action is performed successfully or not.
222 bool HandleActionScrollDownEvent();
225 * @brief Handle the accessibility action to scroll left to the previous page
226 * (by two finger swipe left).
228 * @return Whether the action is performed successfully or not.
230 bool HandleActionPageLeftEvent();
233 * @brief Handle the accessibility action to scroll right to the next page
234 * (by two finger swipe right).
236 * @return Whether the action is performed successfully or not.
238 bool HandleActionPageRightEvent();
241 * @brief Handle the accessibility action to scroll up to the previous page
242 * (by one finger swipe left and right).
244 * @return Whether the action is performed successfully or not.
246 bool HandleActionPageUpEvent();
249 * @brief Handle the accessibility action to scroll down to the next page
250 * (by one finger swipe right and left).
252 * @return Whether the action is performed successfully or not.
254 bool HandleActionPageDownEvent();
257 * @brief Handle the accessibility action to move the focus to the first item on the screen
258 * (by one finger swipe up and down).
260 * @return Whether the action is performed successfully or not.
262 bool HandleActionMoveToFirstEvent();
265 * @brief Handle the accessibility action to move the focus to the last item on the screen
266 * (by one finger swipe down and up).
268 * @return Whether the action is performed successfully or not.
270 bool HandleActionMoveToLastEvent();
273 * @brief Handle the accessibility action to move the focus to the first item on the top
274 * and read from the top item continuously (by three fingers single tap).
276 * @return Whether the action is performed successfully or not.
278 bool HandleActionReadFromTopEvent();
281 * @brief Handle the accessibility action to move focus to and read from the next focusable
282 * actor continuously (by three fingers double tap).
284 * @return Whether the action is performed successfully or not.
286 bool HandleActionReadFromNextEvent();
289 * @brief Handle the accessibility action to do the zooming
290 * (by one finger triple tap).
292 * @return Whether the action is performed successfully or not.
294 bool HandleActionZoomEvent();
297 * @brief Handle the accessibility action to pause/resume the current speech
298 * (by two fingers single tap).
300 * @return Whether the action is performed successfully or not.
302 bool HandleActionReadPauseResumeEvent();
305 * @brief Handle the accessibility action to start/stop the current action
306 * (by two fingers double tap).
308 * @return Whether the action is performed successfully or not.
310 bool HandleActionStartStopEvent();
312 public: // Not intended for application developers
315 * @brief Creates a handle using the Adaptor::Internal implementation.
317 * @param[in] adaptor The AccessibilityAdaptor implementation.
319 DALI_INTERNAL AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor& adaptor );
322 * @brief This constructor is used by AccessibilityAdaptor::Get().
324 * @param[in] adaptor A pointer to the accessibility adaptor.
326 explicit DALI_INTERNAL AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor );
331 #endif // DALI_ACCESSIBILITY_ADAPTOR_H