1 #ifndef DALI_ACCESSIBILITY_ADAPTOR_H
2 #define DALI_ACCESSIBILITY_ADAPTOR_H
5 * Copyright (c) 2020 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.
22 #include <dali/devel-api/events/touch-point.h>
23 #include <dali/public-api/dali-adaptor-common.h>
24 #include <dali/public-api/object/base-handle.h>
28 namespace Internal DALI_INTERNAL
32 class AccessibilityAdaptor;
34 } // namespace DALI_INTERNAL
36 class AccessibilityActionHandler;
37 class AccessibilityGestureHandler;
41 * @brief The AccessibilityAdaptor provides communication to the accessibility manager interface (implemented in toolkit).
44 class DALI_ADAPTOR_API AccessibilityAdaptor : public BaseHandle
48 * @brief Create an uninitialized handle.
50 * This can be initialized by calling getting the adaptor from Dali::Adaptor.
52 AccessibilityAdaptor();
55 * @brief Retrieve a handle to the AccessibilityAdaptor.
57 * @return A handle to the AccessibilityAdaptor.
59 static AccessibilityAdaptor Get();
64 * This is non-virtual since derived Handle types must not contain data or virtual methods.
66 ~AccessibilityAdaptor();
69 * @brief Returns the current position of the read action.
70 * @return The current event position.
72 Vector2 GetReadPosition() const;
75 * @brief Enables Accessibility action or not.
76 * @param[in] enabled True if Accessibility action should be enabled.
78 void EnableAccessibility( bool enabled );
81 * @brief Query whether the accessibility(screen-reader) is enabled.
83 * The accessibility will be enabled by system setting.
84 * @return True if the accessibility(screen-reader) is enabled.
86 bool IsEnabled() const;
89 * @brief Sets Accessibility enabled forcibly.
90 * @param forced Whether accessibility sets enabled forcibly
92 void SetForcedEnable( bool forced );
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 navigate back (by two fingers circle draw).
201 * @return Whether the action is performed successfully or not.
203 bool HandleActionBackEvent();
206 * @brief Handle the accessibility action to enable the feature.
208 void HandleActionEnableEvent();
211 * @brief Handle the accessibility action to disable the feature.
213 void HandleActionDisableEvent();
216 * @brief Handle the accessibility action to scroll up the list and focus on
217 * the first item on the list after the scrolling and read the item
218 * (by two finger swipe up).
220 * @return Whether the action is performed successfully or not.
222 bool HandleActionScrollUpEvent();
225 * @brief Handle the accessibility action to scroll down the list and focus on
226 * the first item on the list after the scrolling and read the item
227 * (by two finger swipe down).
229 * @return Whether the action is performed successfully or not.
231 bool HandleActionScrollDownEvent();
234 * @brief Handle the accessibility action to scroll left to the previous page
235 * (by two finger swipe left).
237 * @return Whether the action is performed successfully or not.
239 bool HandleActionPageLeftEvent();
242 * @brief Handle the accessibility action to scroll right to the next page
243 * (by two finger swipe right).
245 * @return Whether the action is performed successfully or not.
247 bool HandleActionPageRightEvent();
250 * @brief Handle the accessibility action to scroll up to the previous page
251 * (by one finger swipe left and right).
253 * @return Whether the action is performed successfully or not.
255 bool HandleActionPageUpEvent();
258 * @brief Handle the accessibility action to scroll down to the next page
259 * (by one finger swipe right and left).
261 * @return Whether the action is performed successfully or not.
263 bool HandleActionPageDownEvent();
266 * @brief Handle the accessibility action to move the focus to the first item on the screen
267 * (by one finger swipe up and down).
269 * @return Whether the action is performed successfully or not.
271 bool HandleActionMoveToFirstEvent();
274 * @brief Handle the accessibility action to move the focus to the last item on the screen
275 * (by one finger swipe down and up).
277 * @return Whether the action is performed successfully or not.
279 bool HandleActionMoveToLastEvent();
282 * @brief Handle the accessibility action to move the focus to the first item on the top
283 * and read from the top item continuously (by three fingers single tap).
285 * @return Whether the action is performed successfully or not.
287 bool HandleActionReadFromTopEvent();
290 * @brief Handle the accessibility action to move focus to and read from the next focusable
291 * actor continuously (by three fingers double tap).
293 * @return Whether the action is performed successfully or not.
295 bool HandleActionReadFromNextEvent();
298 * @brief Handle the accessibility action to do the zooming
299 * (by one finger triple tap).
301 * @return Whether the action is performed successfully or not.
303 bool HandleActionZoomEvent();
306 * @brief Handle the accessibility action to pause/resume the current speech
307 * (by two fingers single tap).
309 * @return Whether the action is performed successfully or not.
311 bool HandleActionReadPauseResumeEvent();
314 * @brief Handle the accessibility action to start/stop the current action
315 * (by two fingers double tap).
317 * @return Whether the action is performed successfully or not.
319 bool HandleActionStartStopEvent();
321 public: // Not intended for application developers
323 * @brief Creates a handle using the Adaptor::Internal implementation.
325 * @param[in] adaptor The AccessibilityAdaptor implementation.
327 DALI_INTERNAL AccessibilityAdaptor(Internal::Adaptor::AccessibilityAdaptor& adaptor);
330 * @brief This constructor is used by AccessibilityAdaptor::Get().
332 * @param[in] adaptor A pointer to the accessibility adaptor.
334 explicit DALI_INTERNAL AccessibilityAdaptor(Internal::Adaptor::AccessibilityAdaptor* adaptor);
339 #endif // DALI_ACCESSIBILITY_ADAPTOR_H