Use existing callback ID for recurring callbacks
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / accessibility-adaptor.h
1 #ifndef DALI_ACCESSIBILITY_ADAPTOR_H
2 #define DALI_ACCESSIBILITY_ADAPTOR_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
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>
25
26 namespace Dali
27 {
28 namespace Internal DALI_INTERNAL
29 {
30 namespace Adaptor
31 {
32 class AccessibilityAdaptor;
33 }
34 } // namespace DALI_INTERNAL
35
36 class AccessibilityActionHandler;
37 class AccessibilityGestureHandler;
38 struct TouchPoint;
39
40 /**
41  * @brief The AccessibilityAdaptor provides communication to the accessibility manager interface (implemented in toolkit).
42  *
43  */
44 class DALI_ADAPTOR_API AccessibilityAdaptor : public BaseHandle
45 {
46 public:
47   /**
48    * @brief Create an uninitialized handle.
49    *
50    * This can be initialized by calling getting the adaptor from Dali::Adaptor.
51    */
52   AccessibilityAdaptor();
53
54   /**
55    * @brief Retrieve a handle to the AccessibilityAdaptor.
56    *
57    * @return A handle to the AccessibilityAdaptor.
58    */
59   static AccessibilityAdaptor Get();
60
61   /**
62    * @brief Destructor
63    *
64    * This is non-virtual since derived Handle types must not contain data or virtual methods.
65    */
66   ~AccessibilityAdaptor();
67
68   /**
69    * @brief Returns the current position of the read action.
70    * @return The current event position.
71    */
72   Vector2 GetReadPosition() const;
73
74   /**
75    * @brief Query whether the accessibility(screen-reader) is enabled.
76    *
77    * The accessibility will be enabled by system setting.
78    * @return True if the accessibility(screen-reader) is enabled.
79    */
80   bool IsEnabled() const;
81
82   /**
83    * @brief Set the handler to handle accessibility actions.
84    *
85    * @param[in] handler The Accessibility action handler.
86    * @note Handlers should remove themselves when they are destroyed.
87    */
88   void SetActionHandler(AccessibilityActionHandler& handler);
89
90   /**
91    * @brief Set the handler to handle accessibility gestures.
92    *
93    * @param[in] handler The Accessibility gesture handler.
94    * @note Handlers should remove themselves when they are destroyed.
95    */
96   void SetGestureHandler(AccessibilityGestureHandler& handler);
97
98   /**
99    * @brief Handle the accessibility action to move focus to the next focusable actor
100    * (by one finger flick down).
101    *
102    * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
103    * @return Whether the action is performed successfully or not.
104    */
105   bool HandleActionNextEvent(bool allowEndFeedback = true);
106
107   /**
108    * @brief Handle the accessibility action to move focus to the previous focusable actor
109    * (by one finger flick up).
110    *
111    * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
112    * @return Whether the action is performed successfully or not.
113    */
114   bool HandleActionPreviousEvent(bool allowEndFeedback = true);
115
116   /**
117    * @brief Handle the accessibility action to activate the current focused actor (by one
118    * finger )
119    *
120    * @return Whether the action is performed successfully or not.
121    */
122   bool HandleActionActivateEvent();
123
124   /**
125    * @brief Handle the accessibility action to focus and read the actor (by one finger tap or move).
126    *
127    * @param x x position of event
128    * @param y y position of event
129    * @param allowReadAgain true if the action read again the same object (i.e. read action)
130    *                       false if the action just read when the focus object is changed (i.e. over action)
131    * @return Whether the action is performed successfully or not.
132    */
133   bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
134
135   /**
136    * @brief Handle the accessibility action to move focus to the next focusable actor
137    * (by one finger flick right).
138    *
139    * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
140    * @return Whether the action is performed successfully or not.
141    */
142   bool HandleActionReadNextEvent(bool allowEndFeedback = true);
143
144   /**
145    * @brief Handle the accessibility action to move focus to the previous focusable actor
146    * (by one finger flick up).
147    *
148    * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the front
149    * @return Whether the action is performed successfully or not.
150    */
151   bool HandleActionReadPreviousEvent(bool allowEndFeedback = true);
152
153   /**
154    * @brief Handle the accessibility action to change the value when the current focused
155    * actor is a slider (by double finger down and move up and right).
156    *
157    * @return Whether the action is performed successfully or not.
158    */
159   bool HandleActionUpEvent();
160
161   /**
162    * @brief Handle the accessibility action to change the value when the current focused
163    * actor is a slider (by double finger down and move down and left).
164    *
165    * @return Whether the action is performed successfully or not.
166    */
167   bool HandleActionDownEvent();
168
169   /**
170    * @brief Handle the accessibility action to clear the focus from the current focused
171    * actor if any, so that no actor is focused in the focus chain.
172    *
173    * @return Whether the action is performed successfully or not.
174    */
175   bool HandleActionClearFocusEvent();
176
177   /**
178    * @brief Handle the accessibility action to scroll when there is a scroller on the touched position
179    * (by 2 finger touch & move, 2 finger flick).
180    *
181    * @param[in]  point      The touch point information.
182    * @param[in]  timeStamp  The time the touch occurred.
183    * @return Whether the action is performed successfully or not.
184    */
185   bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
186
187   /**
188    * @brief Handle the accessibility action to navigate back (by two fingers circle draw).
189    * @return Whether the action is performed successfully or not.
190    */
191   bool HandleActionBackEvent();
192
193   /**
194    * @brief Handle the accessibility action to enable the feature.
195    */
196   void HandleActionEnableEvent();
197
198   /**
199    * @brief Handle the accessibility action to disable the feature.
200    */
201   void HandleActionDisableEvent();
202
203   /**
204    * @brief Handle the accessibility action to scroll up the list and focus on
205    * the first item on the list after the scrolling and read the item
206    * (by two finger swipe up).
207    *
208    * @return Whether the action is performed successfully or not.
209    */
210   bool HandleActionScrollUpEvent();
211
212   /**
213    * @brief Handle the accessibility action to scroll down the list and focus on
214    * the first item on the list after the scrolling and read the item
215    * (by two finger swipe down).
216    *
217    * @return Whether the action is performed successfully or not.
218    */
219   bool HandleActionScrollDownEvent();
220
221   /**
222    * @brief Handle the accessibility action to scroll left to the previous page
223    * (by two finger swipe left).
224    *
225    * @return Whether the action is performed successfully or not.
226    */
227   bool HandleActionPageLeftEvent();
228
229   /**
230    * @brief Handle the accessibility action to scroll right to the next page
231    * (by two finger swipe right).
232    *
233    * @return Whether the action is performed successfully or not.
234    */
235   bool HandleActionPageRightEvent();
236
237   /**
238    * @brief Handle the accessibility action to scroll up to the previous page
239    * (by one finger swipe left and right).
240    *
241    * @return Whether the action is performed successfully or not.
242    */
243   bool HandleActionPageUpEvent();
244
245   /**
246    * @brief Handle the accessibility action to scroll down to the next page
247    * (by one finger swipe right and left).
248    *
249    * @return Whether the action is performed successfully or not.
250    */
251   bool HandleActionPageDownEvent();
252
253   /**
254    * @brief Handle the accessibility action to move the focus to the first item on the screen
255    * (by one finger swipe up and down).
256    *
257    * @return Whether the action is performed successfully or not.
258    */
259   bool HandleActionMoveToFirstEvent();
260
261   /**
262    * @brief Handle the accessibility action to move the focus to the last item on the screen
263    * (by one finger swipe down and up).
264    *
265    * @return Whether the action is performed successfully or not.
266    */
267   bool HandleActionMoveToLastEvent();
268
269   /**
270    * @brief Handle the accessibility action to move the focus to the first item on the top
271    * and read from the top item continuously (by three fingers single tap).
272    *
273    * @return Whether the action is performed successfully or not.
274    */
275   bool HandleActionReadFromTopEvent();
276
277   /**
278    * @brief Handle the accessibility action to move focus to and read from the next focusable
279    * actor continuously (by three fingers double tap).
280    *
281    * @return Whether the action is performed successfully or not.
282    */
283   bool HandleActionReadFromNextEvent();
284
285   /**
286    * @brief Handle the accessibility action to do the zooming
287    * (by one finger triple tap).
288    *
289    * @return Whether the action is performed successfully or not.
290    */
291   bool HandleActionZoomEvent();
292
293   /**
294    * @brief Handle the accessibility action to pause/resume the current speech
295    * (by two fingers single tap).
296    *
297    * @return Whether the action is performed successfully or not.
298    */
299   bool HandleActionReadPauseResumeEvent();
300
301   /**
302    * @brief Handle the accessibility action to start/stop the current action
303    * (by two fingers double tap).
304    *
305    * @return Whether the action is performed successfully or not.
306    */
307   bool HandleActionStartStopEvent();
308
309 public: // Not intended for application developers
310   /**
311    * @brief Creates a handle using the Adaptor::Internal implementation.
312    *
313    * @param[in] adaptor The AccessibilityAdaptor implementation.
314    */
315   DALI_INTERNAL AccessibilityAdaptor(Internal::Adaptor::AccessibilityAdaptor& adaptor);
316
317   /**
318    * @brief This constructor is used by AccessibilityAdaptor::Get().
319    *
320    * @param[in] adaptor A pointer to the accessibility adaptor.
321    */
322   explicit DALI_INTERNAL AccessibilityAdaptor(Internal::Adaptor::AccessibilityAdaptor* adaptor);
323 };
324
325 } // namespace Dali
326
327 #endif // DALI_ACCESSIBILITY_ADAPTOR_H