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