2 * Copyright (c) 2019 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/devel-api/adaptor-framework/accessibility-adaptor.h>
20 #include <dali/devel-api/adaptor-framework/accessibility-action-handler.h>
21 #include <dali/devel-api/adaptor-framework/accessibility-gesture-handler.h>
22 #include <dali/devel-api/adaptor-framework/accessibility-gesture-event.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 AccessibilityGestureEvent& 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 HandleActionReadPauseResumeEvent();
92 bool HandleActionStartStopEvent();
97 Dali::AccessibilityActionHandler* mActionHandler;
98 Dali::AccessibilityGestureHandler* mGestureHandler;
99 Vector2 mReadPosition;
101 static Dali::AccessibilityAdaptor mToolkitAccessibilityAdaptor;
104 Dali::AccessibilityAdaptor AccessibilityAdaptor::mToolkitAccessibilityAdaptor;
107 Dali::AccessibilityAdaptor AccessibilityAdaptor::Get()
109 if( !mToolkitAccessibilityAdaptor )
111 mToolkitAccessibilityAdaptor = Dali::AccessibilityAdaptor( new Dali::Internal::Adaptor::AccessibilityAdaptor() );
113 return mToolkitAccessibilityAdaptor;
116 AccessibilityAdaptor::AccessibilityAdaptor()
118 mActionHandler(NULL),
119 mGestureHandler(NULL),
120 mReadPosition( 0.0f, 0.0f )
124 AccessibilityAdaptor::~AccessibilityAdaptor()
128 Vector2 AccessibilityAdaptor::GetReadPosition() const
130 return mReadPosition;
133 void AccessibilityAdaptor::MockSetReadPosition( Vector2& position )
135 mReadPosition = position;
138 bool AccessibilityAdaptor::IsEnabled() const
143 void AccessibilityAdaptor::SendPanGesture( const AccessibilityGestureEvent& panEvent )
145 mGestureHandler->HandlePanGesture( panEvent );
148 void AccessibilityAdaptor::SetActionHandler(Dali::AccessibilityActionHandler& handler)
150 mActionHandler = &handler;
153 void AccessibilityAdaptor::SetGestureHandler(Dali::AccessibilityGestureHandler& handler)
155 mGestureHandler = &handler;
158 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
162 return mActionHandler->AccessibilityActionNext( true );
167 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
171 return mActionHandler->AccessibilityActionPrevious( true );
176 bool AccessibilityAdaptor::HandleActionActivateEvent()
180 return mActionHandler->AccessibilityActionActivate();
185 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
189 return mActionHandler->AccessibilityActionRead( allowReadAgain );
194 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
198 return mActionHandler->AccessibilityActionReadNext( true );
203 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
207 return mActionHandler->AccessibilityActionReadPrevious( true );
212 bool AccessibilityAdaptor::HandleActionUpEvent()
216 return mActionHandler->AccessibilityActionUp();
221 bool AccessibilityAdaptor::HandleActionDownEvent()
225 return mActionHandler->AccessibilityActionDown();
230 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
234 return mActionHandler->ClearAccessibilityFocus();
239 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
243 Dali::TouchEvent touchEvent;
244 touchEvent.points.push_back( point );
245 return mActionHandler->AccessibilityActionScroll( touchEvent );
250 bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
254 Dali::TouchEvent touchEvent;
255 touchEvent.points.push_back( point );
256 return mActionHandler->AccessibilityActionTouch( touchEvent );
261 bool AccessibilityAdaptor::HandleActionBackEvent()
265 return mActionHandler->AccessibilityActionBack();
270 bool AccessibilityAdaptor::HandleActionEnableEvent()
274 return mActionHandler->ChangeAccessibilityStatus();
279 bool AccessibilityAdaptor::HandleActionDisableEvent()
283 return mActionHandler->ChangeAccessibilityStatus();
288 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
292 return mActionHandler->AccessibilityActionScrollUp();
297 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
301 return mActionHandler->AccessibilityActionScrollDown();
306 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
310 return mActionHandler->AccessibilityActionPageLeft();
315 bool AccessibilityAdaptor::HandleActionPageRightEvent()
319 return mActionHandler->AccessibilityActionPageRight();
324 bool AccessibilityAdaptor::HandleActionPageUpEvent()
328 return mActionHandler->AccessibilityActionPageUp();
333 bool AccessibilityAdaptor::HandleActionPageDownEvent()
337 return mActionHandler->AccessibilityActionPageDown();
342 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
346 return mActionHandler->AccessibilityActionMoveToFirst();
351 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
355 return mActionHandler->AccessibilityActionMoveToLast();
360 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
364 return mActionHandler->AccessibilityActionReadFromTop();
369 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
373 return mActionHandler->AccessibilityActionReadFromNext();
378 bool AccessibilityAdaptor::HandleActionZoomEvent()
382 return mActionHandler->AccessibilityActionZoom();
387 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
391 return mActionHandler->AccessibilityActionReadPauseResume();
396 bool AccessibilityAdaptor::HandleActionStartStopEvent()
400 return mActionHandler->AccessibilityActionStartStop();
405 static Internal::Adaptor::AccessibilityAdaptor& GetImplementation(Dali::AccessibilityAdaptor& adaptor)
407 BaseObject& handle = adaptor.GetBaseObject();
408 return static_cast<Internal::Adaptor::AccessibilityAdaptor&>(handle);
411 static const Internal::Adaptor::AccessibilityAdaptor& GetImplementation(const Dali::AccessibilityAdaptor& adaptor)
413 const BaseObject& handle = adaptor.GetBaseObject();
414 return static_cast<const Internal::Adaptor::AccessibilityAdaptor&>(handle);
418 } // namespace Adaptor
419 } // namespace Internal
421 ////////////////////////////////////////////////////////////////////////////////////////////////////
423 AccessibilityAdaptor::AccessibilityAdaptor()
427 AccessibilityAdaptor AccessibilityAdaptor::Get()
429 return Internal::Adaptor::AccessibilityAdaptor::Get();
432 AccessibilityAdaptor::~AccessibilityAdaptor()
438 Vector2 AccessibilityAdaptor::GetReadPosition() const
440 return Internal::Adaptor::GetImplementation(*this).GetReadPosition();
443 bool AccessibilityAdaptor::IsEnabled() const
445 return Internal::Adaptor::GetImplementation(*this).IsEnabled();
448 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
450 Internal::Adaptor::GetImplementation(*this).SetActionHandler(handler);
453 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
455 Internal::Adaptor::GetImplementation(*this).SetGestureHandler(handler);
458 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
460 return Internal::Adaptor::GetImplementation(*this).HandleActionNextEvent(allowEndFeedback);
463 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
465 return Internal::Adaptor::GetImplementation(*this).HandleActionPreviousEvent(allowEndFeedback);
468 bool AccessibilityAdaptor::HandleActionActivateEvent()
470 return Internal::Adaptor::GetImplementation(*this).HandleActionActivateEvent();
473 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
475 return Internal::Adaptor::GetImplementation(*this).HandleActionReadEvent( x, y, allowReadAgain );
478 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
480 return Internal::Adaptor::GetImplementation(*this).HandleActionReadNextEvent(allowEndFeedback);
483 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
485 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPreviousEvent(allowEndFeedback);
488 bool AccessibilityAdaptor::HandleActionUpEvent()
490 return Internal::Adaptor::GetImplementation(*this).HandleActionUpEvent();
493 bool AccessibilityAdaptor::HandleActionDownEvent()
495 return Internal::Adaptor::GetImplementation(*this).HandleActionDownEvent();
498 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
500 return Internal::Adaptor::GetImplementation(*this).HandleActionClearFocusEvent();
503 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
505 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp);
508 bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
510 return Internal::Adaptor::GetImplementation(*this).HandleActionTouchEvent(point, timeStamp);
513 bool AccessibilityAdaptor::HandleActionBackEvent()
515 return Internal::Adaptor::GetImplementation(*this).HandleActionBackEvent();
518 void AccessibilityAdaptor::HandleActionEnableEvent()
520 Internal::Adaptor::GetImplementation(*this).HandleActionEnableEvent();
523 void AccessibilityAdaptor::HandleActionDisableEvent()
525 Internal::Adaptor::GetImplementation(*this).HandleActionDisableEvent();
528 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
530 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollUpEvent();
533 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
535 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollDownEvent();
538 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
540 return Internal::Adaptor::GetImplementation(*this).HandleActionPageLeftEvent();
543 bool AccessibilityAdaptor::HandleActionPageRightEvent()
545 return Internal::Adaptor::GetImplementation(*this).HandleActionPageRightEvent();
548 bool AccessibilityAdaptor::HandleActionPageUpEvent()
550 return Internal::Adaptor::GetImplementation(*this).HandleActionPageUpEvent();
553 bool AccessibilityAdaptor::HandleActionPageDownEvent()
555 return Internal::Adaptor::GetImplementation(*this).HandleActionPageDownEvent();
558 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
560 return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToFirstEvent();
563 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
565 return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToLastEvent();
568 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
570 return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromTopEvent();
573 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
575 return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromNextEvent();
578 bool AccessibilityAdaptor::HandleActionZoomEvent()
580 return Internal::Adaptor::GetImplementation(*this).HandleActionZoomEvent();
583 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
585 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPauseResumeEvent();
588 bool AccessibilityAdaptor::HandleActionStartStopEvent()
590 return Internal::Adaptor::GetImplementation(*this).HandleActionStartStopEvent();
593 AccessibilityAdaptor::AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor )
594 : BaseHandle( adaptor )
603 namespace AccessibilityAdaptor
608 void MockSetReadPosition( Dali::AccessibilityAdaptor adaptor, Dali::Vector2& position )
610 Dali::Internal::Adaptor::GetImplementation(adaptor).MockSetReadPosition( position );
613 void SetEnabled( Dali::AccessibilityAdaptor adaptor, bool enabled )
615 Dali::Internal::Adaptor::GetImplementation(adaptor).SetEnabled(enabled);
618 void SendPanGesture( Dali::AccessibilityAdaptor adaptor, const Dali::AccessibilityGestureEvent& panEvent )
620 Dali::Internal::Adaptor::GetImplementation(adaptor).SendPanGesture( panEvent );
623 } // namespace AccessibilityAdaptor