[Tizen] Save and send the position of the focused actor
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / common / accessibility-adaptor-impl.h
1 #ifndef DALI_INTERNAL_ACCESSIBILITY_ADAPTOR_H
2 #define DALI_INTERNAL_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 // EXTERNAL INCLUDES
22 #include <string>
23
24 #include <dali/public-api/object/base-object.h>
25 #include <dali/public-api/math/vector2.h>
26 #include <dali/devel-api/events/touch-point.h>
27 #include <dali/integration-api/events/touch-event-combiner.h>
28
29 // INTERNAL INCLUDES
30 #include <dali/devel-api/adaptor-framework/accessibility-adaptor.h>
31 #include <dali/devel-api/adaptor-framework/accessibility-action-handler.h>
32 #include <dali/devel-api/adaptor-framework/accessibility-gesture-handler.h>
33 #include <dali/internal/accessibility/common/accessibility-gesture-detector.h>
34
35 namespace Dali
36 {
37
38 namespace Internal
39 {
40
41 namespace Adaptor
42 {
43
44 /**
45  * This class detects to accessibility action
46  */
47 class AccessibilityAdaptor : public Dali::BaseObject
48 {
49 public:
50
51   /**
52    * Constructor.
53    */
54   AccessibilityAdaptor();
55
56   /**
57    * @brief Get an instance of the AccessibilityAdaptor.
58    *
59    * @note This singleton-style getter can be reimplemented for different platforms.
60    * @return The instance of the AccessibilityAdaptor.
61    */
62   static Dali::AccessibilityAdaptor Get();
63
64   /**
65    * Turn on accessibility action
66    * This method should be called by vconf callback
67    */
68   void EnableAccessibility();
69
70   /**
71    * Turn off accessibility action
72    * This method should be called by vconf callback
73    */
74   void DisableAccessibility();
75
76   /**
77    * @copydoc Dali::AccessibilityAdaptor::IsEnabled()
78    */
79   bool IsEnabled() const;
80
81   /**
82    * @copydoc Dali::AccessibilityAdaptor::SetForcedEnable()
83    */
84   void SetForcedEnable( bool forced );
85
86   /**
87    * Whether the accessibility is enabled forcibly or not
88    */
89   bool IsForcedEnable() const;
90
91   /**
92    * @copydoc Dali::AccessibilityAdaptor::GetReadPosition() const
93    */
94   Vector2 GetReadPosition() const;
95
96   /**
97    * @copydoc Dali::AccessibilityAdaptor::SetActionHandler()
98    */
99   void SetActionHandler(AccessibilityActionHandler& handler);
100
101   /**
102    * @copydoc Dali::AccessibilityAdaptor::SetGestureHandler()
103    */
104   void SetGestureHandler(AccessibilityGestureHandler& handler);
105
106   /**
107    * @copydoc Dali::AccessibilityAdaptor::SetFocusedActorPosition()
108    */
109   void SetFocusedActorPosition(Vector2 currentPosition);
110
111   /**
112    * @brief Returns the current position of the focused actor.
113    * @return The current position of the focused actor
114    */
115   Vector2 GetFocusedActorPosition() const;
116
117   /**
118    * @copydoc Dali::AccessibilityAdaptor::HandleActionNextEvent()
119    */
120   virtual bool HandleActionNextEvent( bool allowEndFeedback = true);
121
122   /**
123    * @copydoc Dali::AccessibilityAdaptor::HandleActionPreviousEvent()
124    */
125   virtual bool HandleActionPreviousEvent( bool allowEndFeedback = true);
126
127   /**
128    * @copydoc Dali::AccessibilityAdaptor::HandleActionActivateEvent()
129    */
130   virtual bool HandleActionActivateEvent();
131
132   /**
133    * @copydoc Dali::AccessibilityAdaptor::HandleActionReadEvent()
134    */
135   virtual bool HandleActionReadEvent( unsigned int x, unsigned int y, bool allowReadAgain );
136
137   /**
138    * @copydoc Dali::AccessibilityAdaptor::HandleActionReadNextEvent()
139    */
140   virtual bool HandleActionReadNextEvent( bool allowEndFeedback = true);
141
142   /**
143    * @copydoc Dali::AccessibilityAdaptor::HandleActionReadPreviousEvent()
144    */
145   virtual bool HandleActionReadPreviousEvent( bool allowEndFeedback = true);
146
147   /**
148    * @copydoc Dali::AccessibilityAdaptor::HandleActionUpEvent()
149    */
150   virtual bool HandleActionUpEvent();
151
152   /**
153    * @copydoc Dali::AccessibilityAdaptor::HandleActionDownEvent()
154    */
155   virtual bool HandleActionDownEvent();
156
157   /**
158    * @copydoc Dali::AccessibilityAdaptor::HandleActionClearFocusEvent()
159    */
160   bool HandleActionClearFocusEvent();
161
162   /**
163    * @copydoc Dali::AccessibilityAdaptor::HandleActionScrollEvent()
164    */
165   bool HandleActionScrollEvent(const TouchPoint& point, uint32_t timeStamp);
166
167   /**
168    * @copydoc Dali::AccessibilityAdaptor::HandleActionBackEvent()
169    */
170   bool HandleActionBackEvent();
171
172   /**
173    * @copydoc Dali::AccessibilityAdaptor::HandleActionEnableEvent()
174    */
175   void HandleActionEnableEvent();
176
177   /**
178    * @copydoc Dali::AccessibilityAdaptor::HandleActionDisableEvent()
179    */
180   void HandleActionDisableEvent();
181
182   /**
183    * @copydoc Dali::AccessibilityAdaptor::HandleActionScrollUpEvent()
184    */
185   bool HandleActionScrollUpEvent();
186
187   /**
188    * @copydoc Dali::AccessibilityAdaptor::HandleActionScrollDownEvent()
189    */
190   bool HandleActionScrollDownEvent();
191
192   /**
193    * @copydoc Dali::AccessibilityAdaptor::HandleActionPageLeftEvent()
194    */
195   bool HandleActionPageLeftEvent();
196
197   /**
198    * @copydoc Dali::AccessibilityAdaptor::HandleActionPageRightEvent()
199    */
200   bool HandleActionPageRightEvent();
201
202   /**
203    * @copydoc Dali::AccessibilityAdaptor::HandleActionPageUpEvent()
204    */
205   bool HandleActionPageUpEvent();
206
207   /**
208    * @copydoc Dali::AccessibilityAdaptor::HandleActionPageDownEvent()
209    */
210   bool HandleActionPageDownEvent();
211
212   /**
213    * @copydoc Dali::AccessibilityAdaptor::HandleActionMoveToFirstEvent()
214    */
215   bool HandleActionMoveToFirstEvent();
216
217   /**
218    * @copydoc Dali::AccessibilityAdaptor::HandleActionMoveToLastEvent()
219    */
220   bool HandleActionMoveToLastEvent();
221
222   /**
223    * @copydoc Dali::AccessibilityAdaptor::HandleActionReadFromTopEvent()
224    */
225   bool HandleActionReadFromTopEvent();
226
227   /**
228    * @copydoc Dali::AccessibilityAdaptor::HandleActionReadFromNextEvent()
229    */
230   bool HandleActionReadFromNextEvent();
231
232   /**
233    * @copydoc Dali::AccessibilityAdaptor::HandleActionZoomEvent()
234    */
235   bool HandleActionZoomEvent();
236
237   /**
238    * @copydoc Dali::AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
239    */
240   bool HandleActionReadPauseResumeEvent();
241
242   /**
243    * @copydoc Dali::AccessibilityAdaptor::HandleActionStartStopEvent()
244    */
245   bool HandleActionStartStopEvent();
246
247 protected:
248
249   /**
250    * Destructor.
251    */
252   ~AccessibilityAdaptor() override;
253
254 private:
255
256   /**
257    * @brief Called when the singleton is destroyed.
258    *
259    * @note This can be reimplemented for different platforms.
260    * @return The instance of the AccessibilityAdaptor.
261    */
262   static void OnDestroy();
263
264   // Undefined
265   AccessibilityAdaptor( const AccessibilityAdaptor& );
266   AccessibilityAdaptor& operator=( AccessibilityAdaptor& );
267
268 protected:
269
270   Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
271
272   Vector2 mReadPosition; ///< ActionRead position
273   Vector2 mFocusedActorPosition; ///< Focused actor position
274
275   AccessibilityActionHandler* mActionHandler; ///< The pointer of accessibility action handler
276
277   AccessibilityGestureDetectorPtr mAccessibilityGestureDetector; ///< The accessibility gesture detector
278
279   bool mIsEnabled        : 1; ///< enable/disable the accessibility action
280
281   bool mIsForced         : 1; ///< Is the accessibility enabled forcibly
282
283 public:
284
285   // Helpers for public-api forwarding methods
286
287   inline static Internal::Adaptor::AccessibilityAdaptor& GetImplementation(Dali::AccessibilityAdaptor& adaptor)
288   {
289     DALI_ASSERT_ALWAYS( adaptor && "AccessibilityAdaptor handle is empty" );
290
291     BaseObject& handle = adaptor.GetBaseObject();
292
293     return static_cast<Internal::Adaptor::AccessibilityAdaptor&>(handle);
294   }
295
296   inline static const Internal::Adaptor::AccessibilityAdaptor& GetImplementation(const Dali::AccessibilityAdaptor& adaptor)
297   {
298     DALI_ASSERT_ALWAYS( adaptor && "AccessibilityAdaptor handle is empty" );
299
300     const BaseObject& handle = adaptor.GetBaseObject();
301
302     return static_cast<const Internal::Adaptor::AccessibilityAdaptor&>(handle);
303   }
304
305 };
306
307 } // namespace Adaptor
308
309 } // namespace Internal
310
311 } // namespace Dali
312
313 #endif // DALI_INTERNAL_ACCESSIBILITY_ADAPTOR_H