9be248321bcc0cf5368b39db618b10d0fb865bd9
[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) 2019 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
22 // EXTERNAL INCLUDES
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>
26
27 namespace Dali
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 namespace Adaptor
33 {
34 class AccessibilityAdaptor;
35 }
36 }
37
38 class AccessibilityActionHandler;
39 class AccessibilityGestureHandler;
40 class TouchPoint;
41
42 /**
43  * @brief The AccessibilityAdaptor provides communication to the accessibility manager interface (implemented in toolkit).
44  *
45  */
46 class DALI_ADAPTOR_API AccessibilityAdaptor : public BaseHandle
47 {
48 public:
49
50   /**
51    * @brief Create an uninitialized handle.
52    *
53    * This can be initialized by calling getting the adaptor from Dali::Adaptor.
54    */
55   AccessibilityAdaptor();
56
57   /**
58    * @brief Retrieve a handle to the AccessibilityAdaptor.
59    *
60    * @return A handle to the AccessibilityAdaptor.
61    */
62   static AccessibilityAdaptor Get();
63
64   /**
65    * @brief Destructor
66    *
67    * This is non-virtual since derived Handle types must not contain data or virtual methods.
68    */
69   ~AccessibilityAdaptor();
70
71   /**
72    * @brief Returns the current position of the read action.
73    * @return The current event position.
74    */
75   Vector2 GetReadPosition() const;
76
77   /**
78    * @brief Query whether the accessibility(screen-reader) is enabled.
79    *
80    * The accessibility will be enabled by system setting.
81    * @return True if the accessibility(screen-reader) is enabled.
82    */
83   bool IsEnabled() const;
84
85   /**
86    * @brief Set the handler to handle accessibility actions.
87    *
88    * @param[in] handler The Accessibility action handler.
89    * @note Handlers should remove themselves when they are destroyed.
90    */
91   void SetActionHandler(AccessibilityActionHandler& handler);
92
93   /**
94    * @brief Set the handler to handle accessibility gestures.
95    *
96    * @param[in] handler The Accessibility gesture handler.
97    * @note Handlers should remove themselves when they are destroyed.
98    */
99   void SetGestureHandler(AccessibilityGestureHandler& handler);
100
101   /**
102    * @brief Handle the accessibility action to move focus to the next focusable actor
103    * (by one finger flick down).
104    *
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.
107    */
108   bool HandleActionNextEvent(bool allowEndFeedback = true);
109
110   /**
111    * @brief Handle the accessibility action to move focus to the previous focusable actor
112    * (by one finger flick up).
113    *
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.
116    */
117   bool HandleActionPreviousEvent(bool allowEndFeedback = true);
118
119   /**
120    * @brief Handle the accessibility action to activate the current focused actor (by one
121    * finger )
122    *
123    * @return Whether the action is performed successfully or not.
124    */
125   bool HandleActionActivateEvent();
126
127   /**
128    * @brief Handle the accessibility action to focus and read the actor (by one finger tap or move).
129    *
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.
135    */
136   bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
137
138   /**
139    * @brief Handle the accessibility action to move focus to the next focusable actor
140    * (by one finger flick right).
141    *
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.
144    */
145   bool HandleActionReadNextEvent(bool allowEndFeedback = true);
146
147   /**
148    * @brief Handle the accessibility action to move focus to the previous focusable actor
149    * (by one finger flick up).
150    *
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.
153    */
154   bool HandleActionReadPreviousEvent(bool allowEndFeedback = true);
155
156   /**
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).
159    *
160    * @return Whether the action is performed successfully or not.
161    */
162   bool HandleActionUpEvent();
163
164   /**
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).
167    *
168    * @return Whether the action is performed successfully or not.
169    */
170   bool HandleActionDownEvent();
171
172   /**
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.
175    *
176    * @return Whether the action is performed successfully or not.
177    */
178   bool HandleActionClearFocusEvent();
179
180   /**
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).
183    *
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.
187    */
188   bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
189
190   /**
191    * @brief Handle the accessibility action to navigate back (by two fingers circle draw).
192    * @return Whether the action is performed successfully or not.
193    */
194   bool HandleActionBackEvent();
195
196   /**
197    * @brief Handle the accessibility action to enable the feature.
198    */
199   void HandleActionEnableEvent();
200
201   /**
202    * @brief Handle the accessibility action to disable the feature.
203    */
204   void HandleActionDisableEvent();
205
206   /**
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).
210    *
211    * @return Whether the action is performed successfully or not.
212    */
213   bool HandleActionScrollUpEvent();
214
215   /**
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).
219    *
220    * @return Whether the action is performed successfully or not.
221    */
222   bool HandleActionScrollDownEvent();
223
224   /**
225    * @brief Handle the accessibility action to scroll left to the previous page
226    * (by two finger swipe left).
227    *
228    * @return Whether the action is performed successfully or not.
229    */
230   bool HandleActionPageLeftEvent();
231
232   /**
233    * @brief Handle the accessibility action to scroll right to the next page
234    * (by two finger swipe right).
235    *
236    * @return Whether the action is performed successfully or not.
237    */
238   bool HandleActionPageRightEvent();
239
240   /**
241    * @brief Handle the accessibility action to scroll up to the previous page
242    * (by one finger swipe left and right).
243    *
244    * @return Whether the action is performed successfully or not.
245    */
246   bool HandleActionPageUpEvent();
247
248   /**
249    * @brief Handle the accessibility action to scroll down to the next page
250    * (by one finger swipe right and left).
251    *
252    * @return Whether the action is performed successfully or not.
253    */
254   bool HandleActionPageDownEvent();
255
256   /**
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).
259    *
260    * @return Whether the action is performed successfully or not.
261    */
262   bool HandleActionMoveToFirstEvent();
263
264   /**
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).
267    *
268    * @return Whether the action is performed successfully or not.
269    */
270   bool HandleActionMoveToLastEvent();
271
272   /**
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).
275    *
276    * @return Whether the action is performed successfully or not.
277    */
278   bool HandleActionReadFromTopEvent();
279
280   /**
281    * @brief Handle the accessibility action to move focus to and read from the next focusable
282    * actor continuously (by three fingers double tap).
283    *
284    * @return Whether the action is performed successfully or not.
285    */
286   bool HandleActionReadFromNextEvent();
287
288   /**
289    * @brief Handle the accessibility action to do the zooming
290    * (by one finger triple tap).
291    *
292    * @return Whether the action is performed successfully or not.
293    */
294   bool HandleActionZoomEvent();
295
296   /**
297    * @brief Handle the accessibility action to pause/resume the current speech
298    * (by two fingers single tap).
299    *
300    * @return Whether the action is performed successfully or not.
301    */
302   bool HandleActionReadPauseResumeEvent();
303
304   /**
305    * @brief Handle the accessibility action to start/stop the current action
306    * (by two fingers double tap).
307    *
308    * @return Whether the action is performed successfully or not.
309    */
310   bool HandleActionStartStopEvent();
311
312 public: // Not intended for application developers
313
314   /**
315    * @brief Creates a handle using the Adaptor::Internal implementation.
316    *
317    * @param[in] adaptor The AccessibilityAdaptor implementation.
318    */
319   DALI_INTERNAL AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor& adaptor );
320
321   /**
322    * @brief This constructor is used by AccessibilityAdaptor::Get().
323    *
324    * @param[in] adaptor A pointer to the accessibility adaptor.
325    */
326   explicit DALI_INTERNAL AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor );
327 };
328
329 } // namespace Dali
330
331 #endif // DALI_ACCESSIBILITY_ADAPTOR_H