Dali 3D User Interface Engine
accessibility-adaptor-impl.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 // CLASS HEADER
20 
21 // EXTERNAL INCLUDES
27 
28 // INTERNAL INCLUDES
29 #include "system-settings.h"
30 
31 namespace Dali
32 {
33 
34 namespace Internal
35 {
36 
37 namespace Adaptor
38 {
39 
40 namespace // unnamed namespace
41 {
42 
43 #if defined(DEBUG_ENABLED)
44 Debug::Filter* gAccessibilityAdaptorLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_ADAPTOR");
45 #endif
46 
47 } // unnamed namespace
48 
50 : mReadPosition(),
51  mActionHandler( NULL ),
52  mIndicator( NULL ),
53  mIsEnabled( false ),
54  mIndicatorFocused( false )
55 {
57 }
58 
60 {
61  if(mIsEnabled == false)
62  {
63  mIsEnabled = true;
64 
65  if( mActionHandler )
66  {
67  mActionHandler->ChangeAccessibilityStatus();
68  }
69  }
70 }
71 
73 {
74  if(mIsEnabled == true)
75  {
76  mIsEnabled = false;
77 
78  if( mActionHandler )
79  {
80  mActionHandler->ChangeAccessibilityStatus();
81  }
82 
83  // Destroy the TtsPlayer if exists.
84  if ( Adaptor::IsAvailable() )
85  {
86  Dali::Adaptor& adaptor = Dali::Adaptor::Get();
87  Adaptor& adaptorImpl = Adaptor::GetImplementation( adaptor );
88  adaptorImpl.DestroyTtsPlayer( Dali::TtsPlayer::SCREEN_READER );
89  }
90  }
91 }
92 
94 {
95  return mIsEnabled;
96 }
97 
99 {
100  return mReadPosition;
101 }
102 
103 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
104 {
105  mActionHandler = &handler;
106 }
107 
108 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
109 {
111  {
112  mAccessibilityGestureDetector->SetGestureHandler(handler);
113  }
114 }
115 
117 {
118  mIndicator = indicator;
119 }
120 
122 {
123  bool ret = false;
124 
125  if( mActionHandler )
126  {
127  ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
128  }
129 
130  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
131 
132  return ret;
133 }
134 
136 {
137  bool ret = false;
138 
139  if( mActionHandler )
140  {
141  ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
142  }
143 
144  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
145 
146  return ret;
147 }
148 
150 {
151  bool ret = false;
152 
153  if( mActionHandler )
154  {
155  ret = mActionHandler->AccessibilityActionActivate();
156  }
157 
158  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
159 
160  return ret;
161 }
162 
163 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
164 {
165  bool ret = false;
166 
167  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
168 
169  mReadPosition.x = x;
170  mReadPosition.y = y;
171 
172  if( mActionHandler )
173  {
174  ret = mActionHandler->AccessibilityActionRead( allowReadAgain );
175  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
176  }
177 
178  return ret;
179 }
180 
182 {
183  bool ret = false;
184 
185  if( mActionHandler )
186  {
187  ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
188  }
189 
190  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
191 
192  return ret;
193 }
194 
196 {
197  bool ret = false;
198 
199  if( mActionHandler )
200  {
201  ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
202  }
203 
204  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
205 
206  return ret;
207 }
208 
210 {
211  bool ret = false;
212 
213  if( mActionHandler )
214  {
215  ret = mActionHandler->AccessibilityActionUp();
216  }
217 
218  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
219 
220  return ret;
221 }
222 
224 {
225  bool ret = false;
226 
227  if( mActionHandler )
228  {
229  ret = mActionHandler->AccessibilityActionDown();
230  }
231 
232  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
233 
234  return ret;
235 }
236 
238 {
239  bool ret = false;
240 
241  if( mActionHandler )
242  {
243  ret = mActionHandler->ClearAccessibilityFocus();
244  }
245 
246  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
247 
248  return ret;
249 }
250 
251 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
252 {
253  bool ret = false;
254 
255  // We always need to emit a scroll signal, whether it's only a hover or not,
256  // so always send the action to the action handler.
257  if( mActionHandler )
258  {
259  Dali::TouchEvent event(timeStamp);
260  event.points.push_back(point);
261  ret = mActionHandler->AccessibilityActionScroll( event );
262  }
263 
264  Integration::TouchEvent touchEvent;
265  Integration::HoverEvent hoverEvent;
266  Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
267  if( type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth ) // hover event is ignored
268  {
269  // Process the touch event in accessibility gesture detector
271  {
272  mAccessibilityGestureDetector->SendEvent( touchEvent );
273  ret = true;
274  }
275  }
276 
277  return ret;
278 }
279 
280 bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
281 {
282  bool ret = false;
283 
284  Dali::TouchEvent touchEvent(timeStamp);
285  touchEvent.points.push_back(point);
286 
287  if( mActionHandler )
288  {
289  ret = mActionHandler->AccessibilityActionTouch(touchEvent);
290  }
291  return ret;
292 }
293 
295 {
296  bool ret = false;
297 
298  if( mActionHandler )
299  {
300  ret = mActionHandler->AccessibilityActionBack();
301  }
302 
303  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
304 
305  return ret;
306 }
307 
309 {
311 }
312 
314 {
316 }
317 
319 {
320  bool ret = false;
321 
322  if( mActionHandler )
323  {
324  ret = mActionHandler->AccessibilityActionScrollUp();
325  }
326 
327  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
328 
329  return ret;
330 }
331 
332 
334 {
335  bool ret = false;
336 
337  if( mActionHandler )
338  {
339  ret = mActionHandler->AccessibilityActionScrollDown();
340  }
341 
342  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
343 
344  return ret;
345 }
346 
348 {
349  bool ret = false;
350 
351  if( mActionHandler )
352  {
353  ret = mActionHandler->AccessibilityActionPageLeft();
354  }
355 
356  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
357 
358  return ret;
359 }
360 
362 {
363  bool ret = false;
364 
365  if( mActionHandler )
366  {
367  ret = mActionHandler->AccessibilityActionPageRight();
368  }
369 
370  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
371 
372  return ret;
373 }
374 
376 {
377  bool ret = false;
378 
379  if( mActionHandler )
380  {
381  ret = mActionHandler->AccessibilityActionPageUp();
382  }
383 
384  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
385 
386  return ret;
387 }
388 
390 {
391  bool ret = false;
392 
393  if( mActionHandler )
394  {
395  ret = mActionHandler->AccessibilityActionPageDown();
396  }
397 
398  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
399 
400  return ret;
401 }
402 
404 {
405  bool ret = false;
406 
407  if( mActionHandler )
408  {
409  ret = mActionHandler->AccessibilityActionMoveToFirst();
410  }
411 
412  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
413 
414  return ret;
415 }
416 
418 {
419  bool ret = false;
420 
421  if( mActionHandler )
422  {
423  ret = mActionHandler->AccessibilityActionMoveToLast();
424  }
425 
426  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
427 
428  return ret;
429 }
430 
432 {
433  bool ret = false;
434 
435  if( mActionHandler )
436  {
437  ret = mActionHandler->AccessibilityActionReadFromTop();
438  }
439 
440  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
441 
442  return ret;
443 }
444 
446 {
447  bool ret = false;
448 
449  if( mActionHandler )
450  {
451  ret = mActionHandler->AccessibilityActionReadFromNext();
452  }
453 
454  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
455 
456  return ret;
457 }
458 
460 {
461  bool ret = false;
462 
463  if( mActionHandler )
464  {
465  ret = mActionHandler->AccessibilityActionZoom();
466  }
467 
468  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
469 
470  return ret;
471 }
472 
474 {
475  bool ret = false;
476 
477  if( mActionHandler )
478  {
479  ret = mActionHandler->AccessibilityActionReadIndicatorInformation();
480  }
481 
482  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
483 
484  return ret;
485 }
486 
488 {
489  bool ret = false;
490 
491  if( mActionHandler )
492  {
493  ret = mActionHandler->AccessibilityActionReadPauseResume();
494  }
495 
496  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
497 
498  return ret;
499 }
500 
502 {
503  bool ret = false;
504 
505  if( mActionHandler )
506  {
507  ret = mActionHandler->AccessibilityActionStartStop();
508  }
509 
510  DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
511 
512  return ret;
513 }
514 
516 {
517  // Do any platform specific clean-up in OnDestroy()
518  OnDestroy();
519 }
520 
521 } // namespace Adaptor
522 
523 } // namespace Internal
524 
525 } // namespace Dali
Dali Docs Home
Read more about Dali