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