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 mReadPosition( 0.0f, 0.0f )
123 AccessibilityAdaptor::~AccessibilityAdaptor()
127 Vector2 AccessibilityAdaptor::GetReadPosition() const
129 return mReadPosition;
132 void AccessibilityAdaptor::MockSetReadPosition( Vector2& position )
134 mReadPosition = position;
137 bool AccessibilityAdaptor::IsEnabled() const
142 void AccessibilityAdaptor::SendPanGesture( const Integration::PanGestureEvent& panEvent )
144 mGestureHandler->HandlePanGesture( panEvent );
147 void AccessibilityAdaptor::SetActionHandler(Dali::AccessibilityActionHandler& handler)
149 mActionHandler = &handler;
152 void AccessibilityAdaptor::SetGestureHandler(Dali::AccessibilityGestureHandler& handler)
154 mGestureHandler = &handler;
157 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
161 return mActionHandler->AccessibilityActionNext( true );
166 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
170 return mActionHandler->AccessibilityActionPrevious( true );
175 bool AccessibilityAdaptor::HandleActionActivateEvent()
179 return mActionHandler->AccessibilityActionActivate();
184 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
188 return mActionHandler->AccessibilityActionRead( allowReadAgain );
193 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
197 return mActionHandler->AccessibilityActionReadNext( true );
202 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
206 return mActionHandler->AccessibilityActionReadPrevious( true );
211 bool AccessibilityAdaptor::HandleActionUpEvent()
215 return mActionHandler->AccessibilityActionUp();
220 bool AccessibilityAdaptor::HandleActionDownEvent()
224 return mActionHandler->AccessibilityActionDown();
229 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
233 return mActionHandler->ClearAccessibilityFocus();
238 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
242 Dali::TouchEvent touchEvent;
243 touchEvent.points.push_back( point );
244 return mActionHandler->AccessibilityActionScroll( touchEvent );
249 bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
253 Dali::TouchEvent touchEvent;
254 touchEvent.points.push_back( point );
255 return mActionHandler->AccessibilityActionTouch( touchEvent );
260 bool AccessibilityAdaptor::HandleActionBackEvent()
264 return mActionHandler->AccessibilityActionBack();
269 bool AccessibilityAdaptor::HandleActionEnableEvent()
273 return mActionHandler->ChangeAccessibilityStatus();
278 bool AccessibilityAdaptor::HandleActionDisableEvent()
282 return mActionHandler->ChangeAccessibilityStatus();
287 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
291 return mActionHandler->AccessibilityActionScrollUp();
296 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
300 return mActionHandler->AccessibilityActionScrollDown();
305 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
309 return mActionHandler->AccessibilityActionPageLeft();
314 bool AccessibilityAdaptor::HandleActionPageRightEvent()
318 return mActionHandler->AccessibilityActionPageRight();
323 bool AccessibilityAdaptor::HandleActionPageUpEvent()
327 return mActionHandler->AccessibilityActionPageUp();
332 bool AccessibilityAdaptor::HandleActionPageDownEvent()
336 return mActionHandler->AccessibilityActionPageDown();
341 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
345 return mActionHandler->AccessibilityActionMoveToFirst();
350 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
354 return mActionHandler->AccessibilityActionMoveToLast();
359 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
363 return mActionHandler->AccessibilityActionReadFromTop();
368 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
372 return mActionHandler->AccessibilityActionReadFromNext();
377 bool AccessibilityAdaptor::HandleActionZoomEvent()
381 return mActionHandler->AccessibilityActionZoom();
386 bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
390 return mActionHandler->AccessibilityActionReadIndicatorInformation();
395 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
399 return mActionHandler->AccessibilityActionReadPauseResume();
404 bool AccessibilityAdaptor::HandleActionStartStopEvent()
408 return mActionHandler->AccessibilityActionStartStop();
413 static Internal::Adaptor::AccessibilityAdaptor& GetImplementation(Dali::AccessibilityAdaptor& adaptor)
415 BaseObject& handle = adaptor.GetBaseObject();
416 return static_cast<Internal::Adaptor::AccessibilityAdaptor&>(handle);
419 static const Internal::Adaptor::AccessibilityAdaptor& GetImplementation(const Dali::AccessibilityAdaptor& adaptor)
421 const BaseObject& handle = adaptor.GetBaseObject();
422 return static_cast<const Internal::Adaptor::AccessibilityAdaptor&>(handle);
426 } // namespace Adaptor
427 } // namespace Internal
429 ////////////////////////////////////////////////////////////////////////////////////////////////////
431 AccessibilityAdaptor::AccessibilityAdaptor()
435 AccessibilityAdaptor AccessibilityAdaptor::Get()
437 return Internal::Adaptor::AccessibilityAdaptor::Get();
440 AccessibilityAdaptor::~AccessibilityAdaptor()
446 Vector2 AccessibilityAdaptor::GetReadPosition() const
448 return Internal::Adaptor::GetImplementation(*this).GetReadPosition();
451 bool AccessibilityAdaptor::IsEnabled() const
453 return Internal::Adaptor::GetImplementation(*this).IsEnabled();
456 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
458 Internal::Adaptor::GetImplementation(*this).SetActionHandler(handler);
461 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
463 Internal::Adaptor::GetImplementation(*this).SetGestureHandler(handler);
466 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
468 return Internal::Adaptor::GetImplementation(*this).HandleActionNextEvent(allowEndFeedback);
471 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
473 return Internal::Adaptor::GetImplementation(*this).HandleActionPreviousEvent(allowEndFeedback);
476 bool AccessibilityAdaptor::HandleActionActivateEvent()
478 return Internal::Adaptor::GetImplementation(*this).HandleActionActivateEvent();
481 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
483 return Internal::Adaptor::GetImplementation(*this).HandleActionReadEvent( x, y, allowReadAgain );
486 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
488 return Internal::Adaptor::GetImplementation(*this).HandleActionReadNextEvent(allowEndFeedback);
491 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
493 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPreviousEvent(allowEndFeedback);
496 bool AccessibilityAdaptor::HandleActionUpEvent()
498 return Internal::Adaptor::GetImplementation(*this).HandleActionUpEvent();
501 bool AccessibilityAdaptor::HandleActionDownEvent()
503 return Internal::Adaptor::GetImplementation(*this).HandleActionDownEvent();
506 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
508 return Internal::Adaptor::GetImplementation(*this).HandleActionClearFocusEvent();
511 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
513 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp);
516 bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
518 return Internal::Adaptor::GetImplementation(*this).HandleActionTouchEvent(point, timeStamp);
521 bool AccessibilityAdaptor::HandleActionBackEvent()
523 return Internal::Adaptor::GetImplementation(*this).HandleActionBackEvent();
526 void AccessibilityAdaptor::HandleActionEnableEvent()
528 Internal::Adaptor::GetImplementation(*this).HandleActionEnableEvent();
531 void AccessibilityAdaptor::HandleActionDisableEvent()
533 Internal::Adaptor::GetImplementation(*this).HandleActionDisableEvent();
536 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
538 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollUpEvent();
541 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
543 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollDownEvent();
546 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
548 return Internal::Adaptor::GetImplementation(*this).HandleActionPageLeftEvent();
551 bool AccessibilityAdaptor::HandleActionPageRightEvent()
553 return Internal::Adaptor::GetImplementation(*this).HandleActionPageRightEvent();
556 bool AccessibilityAdaptor::HandleActionPageUpEvent()
558 return Internal::Adaptor::GetImplementation(*this).HandleActionPageUpEvent();
561 bool AccessibilityAdaptor::HandleActionPageDownEvent()
563 return Internal::Adaptor::GetImplementation(*this).HandleActionPageDownEvent();
566 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
568 return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToFirstEvent();
571 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
573 return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToLastEvent();
576 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
578 return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromTopEvent();
581 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
583 return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromNextEvent();
586 bool AccessibilityAdaptor::HandleActionZoomEvent()
588 return Internal::Adaptor::GetImplementation(*this).HandleActionZoomEvent();
591 bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
593 return Internal::Adaptor::GetImplementation(*this).HandleActionReadIndicatorInformationEvent();
596 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
598 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPauseResumeEvent();
601 bool AccessibilityAdaptor::HandleActionStartStopEvent()
603 return Internal::Adaptor::GetImplementation(*this).HandleActionStartStopEvent();
606 AccessibilityAdaptor::AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor )
607 : BaseHandle( adaptor )
616 namespace AccessibilityAdaptor
621 void MockSetReadPosition( Dali::AccessibilityAdaptor adaptor, Dali::Vector2& position )
623 Dali::Internal::Adaptor::GetImplementation(adaptor).MockSetReadPosition( position );
626 void SetEnabled( Dali::AccessibilityAdaptor adaptor, bool enabled )
628 Dali::Internal::Adaptor::GetImplementation(adaptor).SetEnabled(enabled);
631 void SendPanGesture( Dali::AccessibilityAdaptor adaptor, const Dali::Integration::PanGestureEvent& panEvent )
633 Dali::Internal::Adaptor::GetImplementation(adaptor).SendPanGesture( panEvent );
636 } // namespace AccessibilityAdaptor