2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <dali/public-api/object/base-object.h>
19 #include <dali/integration-api/events/pan-gesture-event.h>
20 #include <dali/devel-api/adaptor-framework/accessibility-adaptor.h>
21 #include <dali/devel-api/adaptor-framework/accessibility-action-handler.h>
22 #include <dali/devel-api/adaptor-framework/accessibility-gesture-handler.h>
34 * Stub for the AccessibilityAdaptor
36 class AccessibilityAdaptor : public BaseObject
38 public: // Creation & Destruction
40 static Dali::AccessibilityAdaptor Get();
42 AccessibilityAdaptor();
43 ~AccessibilityAdaptor();
47 // Functions to modify mock returns:
49 void MockSetReadPosition( Vector2& position );
51 void SetEnabled(bool enabled)
56 void SendPanGesture( const Dali::Integration::PanGestureEvent& panEvent );
60 bool IsEnabled() const;
61 void SetActionHandler(Dali::AccessibilityActionHandler& handler);
62 void SetGestureHandler(Dali::AccessibilityGestureHandler& handler);
64 Vector2 GetReadPosition() const;
66 bool HandleActionNextEvent(bool);
67 bool HandleActionPreviousEvent(bool);
68 bool HandleActionActivateEvent();
69 bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
70 bool HandleActionReadNextEvent(bool);
71 bool HandleActionReadPreviousEvent(bool);
72 bool HandleActionUpEvent();
73 bool HandleActionDownEvent();
74 bool HandleActionClearFocusEvent();
75 bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
76 bool HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp);
77 bool HandleActionBackEvent();
78 bool HandleActionEnableEvent();
79 bool HandleActionDisableEvent();
80 bool HandleActionScrollUpEvent();
81 bool HandleActionScrollDownEvent();
82 bool HandleActionPageLeftEvent();
83 bool HandleActionPageRightEvent();
84 bool HandleActionPageUpEvent();
85 bool HandleActionPageDownEvent();
86 bool HandleActionMoveToFirstEvent();
87 bool HandleActionMoveToLastEvent();
88 bool HandleActionReadFromTopEvent();
89 bool HandleActionReadFromNextEvent();
90 bool HandleActionZoomEvent();
91 bool HandleActionReadIndicatorInformationEvent();
92 bool HandleActionReadPauseResumeEvent();
93 bool HandleActionStartStopEvent();
98 Dali::AccessibilityActionHandler* mActionHandler;
99 Dali::AccessibilityGestureHandler* mGestureHandler;
100 Vector2 mReadPosition;
102 static Dali::AccessibilityAdaptor mToolkitAccessibilityAdaptor;
105 Dali::AccessibilityAdaptor AccessibilityAdaptor::mToolkitAccessibilityAdaptor;
108 Dali::AccessibilityAdaptor AccessibilityAdaptor::Get()
110 if( !mToolkitAccessibilityAdaptor )
112 mToolkitAccessibilityAdaptor = Dali::AccessibilityAdaptor( new Dali::Internal::Adaptor::AccessibilityAdaptor() );
114 return mToolkitAccessibilityAdaptor;
117 AccessibilityAdaptor::AccessibilityAdaptor()
119 mActionHandler(NULL),
120 mGestureHandler(NULL),
121 mReadPosition( 0.0f, 0.0f )
125 AccessibilityAdaptor::~AccessibilityAdaptor()
129 Vector2 AccessibilityAdaptor::GetReadPosition() const
131 return mReadPosition;
134 void AccessibilityAdaptor::MockSetReadPosition( Vector2& position )
136 mReadPosition = position;
139 bool AccessibilityAdaptor::IsEnabled() const
144 void AccessibilityAdaptor::SendPanGesture( const Integration::PanGestureEvent& panEvent )
146 mGestureHandler->HandlePanGesture( panEvent );
149 void AccessibilityAdaptor::SetActionHandler(Dali::AccessibilityActionHandler& handler)
151 mActionHandler = &handler;
154 void AccessibilityAdaptor::SetGestureHandler(Dali::AccessibilityGestureHandler& handler)
156 mGestureHandler = &handler;
159 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
163 return mActionHandler->AccessibilityActionNext( true );
168 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
172 return mActionHandler->AccessibilityActionPrevious( true );
177 bool AccessibilityAdaptor::HandleActionActivateEvent()
181 return mActionHandler->AccessibilityActionActivate();
186 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
190 return mActionHandler->AccessibilityActionRead( allowReadAgain );
195 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
199 return mActionHandler->AccessibilityActionReadNext( true );
204 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
208 return mActionHandler->AccessibilityActionReadPrevious( true );
213 bool AccessibilityAdaptor::HandleActionUpEvent()
217 return mActionHandler->AccessibilityActionUp();
222 bool AccessibilityAdaptor::HandleActionDownEvent()
226 return mActionHandler->AccessibilityActionDown();
231 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
235 return mActionHandler->ClearAccessibilityFocus();
240 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
244 Dali::TouchEvent touchEvent;
245 touchEvent.points.push_back( point );
246 return mActionHandler->AccessibilityActionScroll( touchEvent );
251 bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
255 Dali::TouchEvent touchEvent;
256 touchEvent.points.push_back( point );
257 return mActionHandler->AccessibilityActionTouch( touchEvent );
262 bool AccessibilityAdaptor::HandleActionBackEvent()
266 return mActionHandler->AccessibilityActionBack();
271 bool AccessibilityAdaptor::HandleActionEnableEvent()
275 return mActionHandler->ChangeAccessibilityStatus();
280 bool AccessibilityAdaptor::HandleActionDisableEvent()
284 return mActionHandler->ChangeAccessibilityStatus();
289 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
293 return mActionHandler->AccessibilityActionScrollUp();
298 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
302 return mActionHandler->AccessibilityActionScrollDown();
307 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
311 return mActionHandler->AccessibilityActionPageLeft();
316 bool AccessibilityAdaptor::HandleActionPageRightEvent()
320 return mActionHandler->AccessibilityActionPageRight();
325 bool AccessibilityAdaptor::HandleActionPageUpEvent()
329 return mActionHandler->AccessibilityActionPageUp();
334 bool AccessibilityAdaptor::HandleActionPageDownEvent()
338 return mActionHandler->AccessibilityActionPageDown();
343 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
347 return mActionHandler->AccessibilityActionMoveToFirst();
352 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
356 return mActionHandler->AccessibilityActionMoveToLast();
361 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
365 return mActionHandler->AccessibilityActionReadFromTop();
370 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
374 return mActionHandler->AccessibilityActionReadFromNext();
379 bool AccessibilityAdaptor::HandleActionZoomEvent()
383 return mActionHandler->AccessibilityActionZoom();
388 bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
392 return mActionHandler->AccessibilityActionReadIndicatorInformation();
397 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
401 return mActionHandler->AccessibilityActionReadPauseResume();
406 bool AccessibilityAdaptor::HandleActionStartStopEvent()
410 return mActionHandler->AccessibilityActionStartStop();
415 static Internal::Adaptor::AccessibilityAdaptor& GetImplementation(Dali::AccessibilityAdaptor& adaptor)
417 BaseObject& handle = adaptor.GetBaseObject();
418 return static_cast<Internal::Adaptor::AccessibilityAdaptor&>(handle);
421 static const Internal::Adaptor::AccessibilityAdaptor& GetImplementation(const Dali::AccessibilityAdaptor& adaptor)
423 const BaseObject& handle = adaptor.GetBaseObject();
424 return static_cast<const Internal::Adaptor::AccessibilityAdaptor&>(handle);
428 } // namespace Adaptor
429 } // namespace Internal
431 ////////////////////////////////////////////////////////////////////////////////////////////////////
433 AccessibilityAdaptor::AccessibilityAdaptor()
437 AccessibilityAdaptor AccessibilityAdaptor::Get()
439 return Internal::Adaptor::AccessibilityAdaptor::Get();
442 AccessibilityAdaptor::~AccessibilityAdaptor()
448 Vector2 AccessibilityAdaptor::GetReadPosition() const
450 return Internal::Adaptor::GetImplementation(*this).GetReadPosition();
453 bool AccessibilityAdaptor::IsEnabled() const
455 return Internal::Adaptor::GetImplementation(*this).IsEnabled();
458 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
460 Internal::Adaptor::GetImplementation(*this).SetActionHandler(handler);
463 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
465 Internal::Adaptor::GetImplementation(*this).SetGestureHandler(handler);
468 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
470 return Internal::Adaptor::GetImplementation(*this).HandleActionNextEvent(allowEndFeedback);
473 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
475 return Internal::Adaptor::GetImplementation(*this).HandleActionPreviousEvent(allowEndFeedback);
478 bool AccessibilityAdaptor::HandleActionActivateEvent()
480 return Internal::Adaptor::GetImplementation(*this).HandleActionActivateEvent();
483 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
485 return Internal::Adaptor::GetImplementation(*this).HandleActionReadEvent( x, y, allowReadAgain );
488 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
490 return Internal::Adaptor::GetImplementation(*this).HandleActionReadNextEvent(allowEndFeedback);
493 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
495 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPreviousEvent(allowEndFeedback);
498 bool AccessibilityAdaptor::HandleActionUpEvent()
500 return Internal::Adaptor::GetImplementation(*this).HandleActionUpEvent();
503 bool AccessibilityAdaptor::HandleActionDownEvent()
505 return Internal::Adaptor::GetImplementation(*this).HandleActionDownEvent();
508 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
510 return Internal::Adaptor::GetImplementation(*this).HandleActionClearFocusEvent();
513 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
515 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp);
518 bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
520 return Internal::Adaptor::GetImplementation(*this).HandleActionTouchEvent(point, timeStamp);
523 bool AccessibilityAdaptor::HandleActionBackEvent()
525 return Internal::Adaptor::GetImplementation(*this).HandleActionBackEvent();
528 void AccessibilityAdaptor::HandleActionEnableEvent()
530 Internal::Adaptor::GetImplementation(*this).HandleActionEnableEvent();
533 void AccessibilityAdaptor::HandleActionDisableEvent()
535 Internal::Adaptor::GetImplementation(*this).HandleActionDisableEvent();
538 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
540 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollUpEvent();
543 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
545 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollDownEvent();
548 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
550 return Internal::Adaptor::GetImplementation(*this).HandleActionPageLeftEvent();
553 bool AccessibilityAdaptor::HandleActionPageRightEvent()
555 return Internal::Adaptor::GetImplementation(*this).HandleActionPageRightEvent();
558 bool AccessibilityAdaptor::HandleActionPageUpEvent()
560 return Internal::Adaptor::GetImplementation(*this).HandleActionPageUpEvent();
563 bool AccessibilityAdaptor::HandleActionPageDownEvent()
565 return Internal::Adaptor::GetImplementation(*this).HandleActionPageDownEvent();
568 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
570 return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToFirstEvent();
573 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
575 return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToLastEvent();
578 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
580 return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromTopEvent();
583 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
585 return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromNextEvent();
588 bool AccessibilityAdaptor::HandleActionZoomEvent()
590 return Internal::Adaptor::GetImplementation(*this).HandleActionZoomEvent();
593 bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
595 return Internal::Adaptor::GetImplementation(*this).HandleActionReadIndicatorInformationEvent();
598 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
600 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPauseResumeEvent();
603 bool AccessibilityAdaptor::HandleActionStartStopEvent()
605 return Internal::Adaptor::GetImplementation(*this).HandleActionStartStopEvent();
608 AccessibilityAdaptor::AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor )
609 : BaseHandle( adaptor )
618 namespace AccessibilityAdaptor
623 void MockSetReadPosition( Dali::AccessibilityAdaptor adaptor, Dali::Vector2& position )
625 Dali::Internal::Adaptor::GetImplementation(adaptor).MockSetReadPosition( position );
628 void SetEnabled( Dali::AccessibilityAdaptor adaptor, bool enabled )
630 Dali::Internal::Adaptor::GetImplementation(adaptor).SetEnabled(enabled);
633 void SendPanGesture( Dali::AccessibilityAdaptor adaptor, const Dali::Integration::PanGestureEvent& panEvent )
635 Dali::Internal::Adaptor::GetImplementation(adaptor).SendPanGesture( panEvent );
638 } // namespace AccessibilityAdaptor