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-event.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 move for the current focused actor
192 * (by 1 finger tap & hold and move).
194 * @param[in] point The touch point information.
195 * @param[in] timeStamp The time the touch occurred.
196 * @return Whether the action is performed successfully or not.
198 bool HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp);
201 * @brief Handle the accessibility action to navigate back (by two fingers circle draw).
202 * @return Whether the action is performed successfully or not.
204 bool HandleActionBackEvent();
207 * @brief Handle the accessibility action to enable the feature.
209 void HandleActionEnableEvent();
212 * @brief Handle the accessibility action to disable the feature.
214 void HandleActionDisableEvent();
217 * @brief Handle the accessibility action to scroll up the list and focus on
218 * the first item on the list after the scrolling and read the item
219 * (by two finger swipe up).
221 * @return Whether the action is performed successfully or not.
223 bool HandleActionScrollUpEvent();
226 * @brief Handle the accessibility action to scroll down the list and focus on
227 * the first item on the list after the scrolling and read the item
228 * (by two finger swipe down).
230 * @return Whether the action is performed successfully or not.
232 bool HandleActionScrollDownEvent();
235 * @brief Handle the accessibility action to scroll left to the previous page
236 * (by two finger swipe left).
238 * @return Whether the action is performed successfully or not.
240 bool HandleActionPageLeftEvent();
243 * @brief Handle the accessibility action to scroll right to the next page
244 * (by two finger swipe right).
246 * @return Whether the action is performed successfully or not.
248 bool HandleActionPageRightEvent();
251 * @brief Handle the accessibility action to scroll up to the previous page
252 * (by one finger swipe left and right).
254 * @return Whether the action is performed successfully or not.
256 bool HandleActionPageUpEvent();
259 * @brief Handle the accessibility action to scroll down to the next page
260 * (by one finger swipe right and left).
262 * @return Whether the action is performed successfully or not.
264 bool HandleActionPageDownEvent();
267 * @brief Handle the accessibility action to move the focus to the first item on the screen
268 * (by one finger swipe up and down).
270 * @return Whether the action is performed successfully or not.
272 bool HandleActionMoveToFirstEvent();
275 * @brief Handle the accessibility action to move the focus to the last item on the screen
276 * (by one finger swipe down and up).
278 * @return Whether the action is performed successfully or not.
280 bool HandleActionMoveToLastEvent();
283 * @brief Handle the accessibility action to move the focus to the first item on the top
284 * and read from the top item continuously (by three fingers single tap).
286 * @return Whether the action is performed successfully or not.
288 bool HandleActionReadFromTopEvent();
291 * @brief Handle the accessibility action to move focus to and read from the next focusable
292 * actor continuously (by three fingers double tap).
294 * @return Whether the action is performed successfully or not.
296 bool HandleActionReadFromNextEvent();
299 * @brief Handle the accessibility action to do the zooming
300 * (by one finger triple tap).
302 * @return Whether the action is performed successfully or not.
304 bool HandleActionZoomEvent();
307 * @brief Handle the accessibility action to pause/resume the current speech
308 * (by two fingers single tap).
310 * @return Whether the action is performed successfully or not.
312 bool HandleActionReadPauseResumeEvent();
315 * @brief Handle the accessibility action to start/stop the current action
316 * (by two fingers double tap).
318 * @return Whether the action is performed successfully or not.
320 bool HandleActionStartStopEvent();
322 public: // Not intended for application developers
325 * @brief Creates a handle using the Adaptor::Internal implementation.
327 * @param[in] adaptor The AccessibilityAdaptor implementation.
329 DALI_INTERNAL AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor& adaptor );
332 * @brief This constructor is used by AccessibilityAdaptor::Get().
334 * @param[in] adaptor A pointer to the accessibility adaptor.
336 explicit DALI_INTERNAL AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor );
341 #endif // DALI_ACCESSIBILITY_ADAPTOR_H