[Tizen] Make EnableAccessibility API public
[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 Enables Accessibility action or not.
76    * @param[in] enabled True if Accessibility action should be enabled.
77    */
78   void EnableAccessibility( bool enabled );
79
80   /**
81    * @brief Query whether the accessibility(screen-reader) is enabled.
82    *
83    * The accessibility will be enabled by system setting.
84    * @return True if the accessibility(screen-reader) is enabled.
85    */
86   bool IsEnabled() const;
87
88   /**
89    * @brief Set the handler to handle accessibility actions.
90    *
91    * @param[in] handler The Accessibility action handler.
92    * @note Handlers should remove themselves when they are destroyed.
93    */
94   void SetActionHandler(AccessibilityActionHandler& handler);
95
96   /**
97    * @brief Set the handler to handle accessibility gestures.
98    *
99    * @param[in] handler The Accessibility gesture handler.
100    * @note Handlers should remove themselves when they are destroyed.
101    */
102   void SetGestureHandler(AccessibilityGestureHandler& handler);
103
104   /**
105    * @brief Handle the accessibility action to move focus to the next focusable actor
106    * (by one finger flick down).
107    *
108    * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
109    * @return Whether the action is performed successfully or not.
110    */
111   bool HandleActionNextEvent(bool allowEndFeedback = true);
112
113   /**
114    * @brief Handle the accessibility action to move focus to the previous focusable actor
115    * (by one finger flick up).
116    *
117    * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
118    * @return Whether the action is performed successfully or not.
119    */
120   bool HandleActionPreviousEvent(bool allowEndFeedback = true);
121
122   /**
123    * @brief Handle the accessibility action to activate the current focused actor (by one
124    * finger )
125    *
126    * @return Whether the action is performed successfully or not.
127    */
128   bool HandleActionActivateEvent();
129
130   /**
131    * @brief Handle the accessibility action to focus and read the actor (by one finger tap or move).
132    *
133    * @param x x position of event
134    * @param y y position of event
135    * @param allowReadAgain true if the action read again the same object (i.e. read action)
136    *                       false if the action just read when the focus object is changed (i.e. over action)
137    * @return Whether the action is performed successfully or not.
138    */
139   bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
140
141   /**
142    * @brief Handle the accessibility action to move focus to the next focusable actor
143    * (by one finger flick right).
144    *
145    * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
146    * @return Whether the action is performed successfully or not.
147    */
148   bool HandleActionReadNextEvent(bool allowEndFeedback = true);
149
150   /**
151    * @brief Handle the accessibility action to move focus to the previous focusable actor
152    * (by one finger flick up).
153    *
154    * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the front
155    * @return Whether the action is performed successfully or not.
156    */
157   bool HandleActionReadPreviousEvent(bool allowEndFeedback = true);
158
159   /**
160    * @brief Handle the accessibility action to change the value when the current focused
161    * actor is a slider (by double finger down and move up and right).
162    *
163    * @return Whether the action is performed successfully or not.
164    */
165   bool HandleActionUpEvent();
166
167   /**
168    * @brief Handle the accessibility action to change the value when the current focused
169    * actor is a slider (by double finger down and move down and left).
170    *
171    * @return Whether the action is performed successfully or not.
172    */
173   bool HandleActionDownEvent();
174
175   /**
176    * @brief Handle the accessibility action to clear the focus from the current focused
177    * actor if any, so that no actor is focused in the focus chain.
178    *
179    * @return Whether the action is performed successfully or not.
180    */
181   bool HandleActionClearFocusEvent();
182
183   /**
184    * @brief Handle the accessibility action to scroll when there is a scroller on the touched position
185    * (by 2 finger touch & move, 2 finger flick).
186    *
187    * @param[in]  point      The touch point information.
188    * @param[in]  timeStamp  The time the touch occurred.
189    * @return Whether the action is performed successfully or not.
190    */
191   bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
192
193   /**
194    * @brief Handle the accessibility action to navigate back (by two fingers circle draw).
195    * @return Whether the action is performed successfully or not.
196    */
197   bool HandleActionBackEvent();
198
199   /**
200    * @brief Handle the accessibility action to enable the feature.
201    */
202   void HandleActionEnableEvent();
203
204   /**
205    * @brief Handle the accessibility action to disable the feature.
206    */
207   void HandleActionDisableEvent();
208
209   /**
210    * @brief Handle the accessibility action to scroll up the list and focus on
211    * the first item on the list after the scrolling and read the item
212    * (by two finger swipe up).
213    *
214    * @return Whether the action is performed successfully or not.
215    */
216   bool HandleActionScrollUpEvent();
217
218   /**
219    * @brief Handle the accessibility action to scroll down the list and focus on
220    * the first item on the list after the scrolling and read the item
221    * (by two finger swipe down).
222    *
223    * @return Whether the action is performed successfully or not.
224    */
225   bool HandleActionScrollDownEvent();
226
227   /**
228    * @brief Handle the accessibility action to scroll left to the previous page
229    * (by two finger swipe left).
230    *
231    * @return Whether the action is performed successfully or not.
232    */
233   bool HandleActionPageLeftEvent();
234
235   /**
236    * @brief Handle the accessibility action to scroll right to the next page
237    * (by two finger swipe right).
238    *
239    * @return Whether the action is performed successfully or not.
240    */
241   bool HandleActionPageRightEvent();
242
243   /**
244    * @brief Handle the accessibility action to scroll up to the previous page
245    * (by one finger swipe left and right).
246    *
247    * @return Whether the action is performed successfully or not.
248    */
249   bool HandleActionPageUpEvent();
250
251   /**
252    * @brief Handle the accessibility action to scroll down to the next page
253    * (by one finger swipe right and left).
254    *
255    * @return Whether the action is performed successfully or not.
256    */
257   bool HandleActionPageDownEvent();
258
259   /**
260    * @brief Handle the accessibility action to move the focus to the first item on the screen
261    * (by one finger swipe up and down).
262    *
263    * @return Whether the action is performed successfully or not.
264    */
265   bool HandleActionMoveToFirstEvent();
266
267   /**
268    * @brief Handle the accessibility action to move the focus to the last item on the screen
269    * (by one finger swipe down and up).
270    *
271    * @return Whether the action is performed successfully or not.
272    */
273   bool HandleActionMoveToLastEvent();
274
275   /**
276    * @brief Handle the accessibility action to move the focus to the first item on the top
277    * and read from the top item continuously (by three fingers single tap).
278    *
279    * @return Whether the action is performed successfully or not.
280    */
281   bool HandleActionReadFromTopEvent();
282
283   /**
284    * @brief Handle the accessibility action to move focus to and read from the next focusable
285    * actor continuously (by three fingers double tap).
286    *
287    * @return Whether the action is performed successfully or not.
288    */
289   bool HandleActionReadFromNextEvent();
290
291   /**
292    * @brief Handle the accessibility action to do the zooming
293    * (by one finger triple tap).
294    *
295    * @return Whether the action is performed successfully or not.
296    */
297   bool HandleActionZoomEvent();
298
299   /**
300    * @brief Handle the accessibility action to pause/resume the current speech
301    * (by two fingers single tap).
302    *
303    * @return Whether the action is performed successfully or not.
304    */
305   bool HandleActionReadPauseResumeEvent();
306
307   /**
308    * @brief Handle the accessibility action to start/stop the current action
309    * (by two fingers double tap).
310    *
311    * @return Whether the action is performed successfully or not.
312    */
313   bool HandleActionStartStopEvent();
314
315 public: // Not intended for application developers
316   /**
317    * @brief Creates a handle using the Adaptor::Internal implementation.
318    *
319    * @param[in] adaptor The AccessibilityAdaptor implementation.
320    */
321   DALI_INTERNAL AccessibilityAdaptor(Internal::Adaptor::AccessibilityAdaptor& adaptor);
322
323   /**
324    * @brief This constructor is used by AccessibilityAdaptor::Get().
325    *
326    * @param[in] adaptor A pointer to the accessibility adaptor.
327    */
328   explicit DALI_INTERNAL AccessibilityAdaptor(Internal::Adaptor::AccessibilityAdaptor* adaptor);
329 };
330
331 } // namespace Dali
332
333 #endif // DALI_ACCESSIBILITY_ADAPTOR_H