2 * Copyright (c) 2020 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>
23 #include <dali/integration-api/events/touch-integ.h>
35 * Stub for the AccessibilityAdaptor
37 class AccessibilityAdaptor : public BaseObject
39 public: // Creation & Destruction
41 static Dali::AccessibilityAdaptor Get();
43 AccessibilityAdaptor();
44 ~AccessibilityAdaptor();
48 // Functions to modify mock returns:
50 void MockSetReadPosition( Vector2& position );
52 void SetEnabled(bool enabled)
57 void SendPanGesture( const AccessibilityGestureEvent& panEvent );
61 bool IsEnabled() const;
62 void SetActionHandler(Dali::AccessibilityActionHandler& handler);
63 void SetGestureHandler(Dali::AccessibilityGestureHandler& handler);
65 Vector2 GetReadPosition() const;
67 bool HandleActionNextEvent(bool);
68 bool HandleActionPreviousEvent(bool);
69 bool HandleActionActivateEvent();
70 bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
71 bool HandleActionReadNextEvent(bool);
72 bool HandleActionReadPreviousEvent(bool);
73 bool HandleActionUpEvent();
74 bool HandleActionDownEvent();
75 bool HandleActionClearFocusEvent();
76 bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
77 bool HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp);
78 bool HandleActionBackEvent();
79 bool HandleActionEnableEvent();
80 bool HandleActionDisableEvent();
81 bool HandleActionScrollUpEvent();
82 bool HandleActionScrollDownEvent();
83 bool HandleActionPageLeftEvent();
84 bool HandleActionPageRightEvent();
85 bool HandleActionPageUpEvent();
86 bool HandleActionPageDownEvent();
87 bool HandleActionMoveToFirstEvent();
88 bool HandleActionMoveToLastEvent();
89 bool HandleActionReadFromTopEvent();
90 bool HandleActionReadFromNextEvent();
91 bool HandleActionZoomEvent();
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 AccessibilityGestureEvent& 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 touch = Integration::NewTouchEvent(timeStamp, point);
245 return mActionHandler->AccessibilityActionScroll( touch );
250 bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
254 Dali::TouchEvent touch = Integration::NewTouchEvent(timeStamp, point);
255 return mActionHandler->AccessibilityActionTouch( touch );
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::HandleActionReadPauseResumeEvent()
390 return mActionHandler->AccessibilityActionReadPauseResume();
395 bool AccessibilityAdaptor::HandleActionStartStopEvent()
399 return mActionHandler->AccessibilityActionStartStop();
404 static Internal::Adaptor::AccessibilityAdaptor& GetImplementation(Dali::AccessibilityAdaptor& adaptor)
406 BaseObject& handle = adaptor.GetBaseObject();
407 return static_cast<Internal::Adaptor::AccessibilityAdaptor&>(handle);
410 static const Internal::Adaptor::AccessibilityAdaptor& GetImplementation(const Dali::AccessibilityAdaptor& adaptor)
412 const BaseObject& handle = adaptor.GetBaseObject();
413 return static_cast<const Internal::Adaptor::AccessibilityAdaptor&>(handle);
417 } // namespace Adaptor
418 } // namespace Internal
420 ////////////////////////////////////////////////////////////////////////////////////////////////////
422 AccessibilityAdaptor::AccessibilityAdaptor()
426 AccessibilityAdaptor AccessibilityAdaptor::Get()
428 return Internal::Adaptor::AccessibilityAdaptor::Get();
431 AccessibilityAdaptor::~AccessibilityAdaptor()
437 Vector2 AccessibilityAdaptor::GetReadPosition() const
439 return Internal::Adaptor::GetImplementation(*this).GetReadPosition();
442 bool AccessibilityAdaptor::IsEnabled() const
444 return Internal::Adaptor::GetImplementation(*this).IsEnabled();
447 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
449 Internal::Adaptor::GetImplementation(*this).SetActionHandler(handler);
452 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
454 Internal::Adaptor::GetImplementation(*this).SetGestureHandler(handler);
457 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
459 return Internal::Adaptor::GetImplementation(*this).HandleActionNextEvent(allowEndFeedback);
462 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
464 return Internal::Adaptor::GetImplementation(*this).HandleActionPreviousEvent(allowEndFeedback);
467 bool AccessibilityAdaptor::HandleActionActivateEvent()
469 return Internal::Adaptor::GetImplementation(*this).HandleActionActivateEvent();
472 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
474 return Internal::Adaptor::GetImplementation(*this).HandleActionReadEvent( x, y, allowReadAgain );
477 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
479 return Internal::Adaptor::GetImplementation(*this).HandleActionReadNextEvent(allowEndFeedback);
482 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
484 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPreviousEvent(allowEndFeedback);
487 bool AccessibilityAdaptor::HandleActionUpEvent()
489 return Internal::Adaptor::GetImplementation(*this).HandleActionUpEvent();
492 bool AccessibilityAdaptor::HandleActionDownEvent()
494 return Internal::Adaptor::GetImplementation(*this).HandleActionDownEvent();
497 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
499 return Internal::Adaptor::GetImplementation(*this).HandleActionClearFocusEvent();
502 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
504 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp);
507 bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
509 return Internal::Adaptor::GetImplementation(*this).HandleActionTouchEvent(point, timeStamp);
512 bool AccessibilityAdaptor::HandleActionBackEvent()
514 return Internal::Adaptor::GetImplementation(*this).HandleActionBackEvent();
517 void AccessibilityAdaptor::HandleActionEnableEvent()
519 Internal::Adaptor::GetImplementation(*this).HandleActionEnableEvent();
522 void AccessibilityAdaptor::HandleActionDisableEvent()
524 Internal::Adaptor::GetImplementation(*this).HandleActionDisableEvent();
527 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
529 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollUpEvent();
532 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
534 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollDownEvent();
537 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
539 return Internal::Adaptor::GetImplementation(*this).HandleActionPageLeftEvent();
542 bool AccessibilityAdaptor::HandleActionPageRightEvent()
544 return Internal::Adaptor::GetImplementation(*this).HandleActionPageRightEvent();
547 bool AccessibilityAdaptor::HandleActionPageUpEvent()
549 return Internal::Adaptor::GetImplementation(*this).HandleActionPageUpEvent();
552 bool AccessibilityAdaptor::HandleActionPageDownEvent()
554 return Internal::Adaptor::GetImplementation(*this).HandleActionPageDownEvent();
557 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
559 return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToFirstEvent();
562 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
564 return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToLastEvent();
567 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
569 return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromTopEvent();
572 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
574 return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromNextEvent();
577 bool AccessibilityAdaptor::HandleActionZoomEvent()
579 return Internal::Adaptor::GetImplementation(*this).HandleActionZoomEvent();
582 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
584 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPauseResumeEvent();
587 bool AccessibilityAdaptor::HandleActionStartStopEvent()
589 return Internal::Adaptor::GetImplementation(*this).HandleActionStartStopEvent();
592 AccessibilityAdaptor::AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor )
593 : BaseHandle( adaptor )
602 namespace AccessibilityAdaptor
607 void MockSetReadPosition( Dali::AccessibilityAdaptor adaptor, Dali::Vector2& position )
609 Dali::Internal::Adaptor::GetImplementation(adaptor).MockSetReadPosition( position );
612 void SetEnabled( Dali::AccessibilityAdaptor adaptor, bool enabled )
614 Dali::Internal::Adaptor::GetImplementation(adaptor).SetEnabled(enabled);
617 void SendPanGesture( Dali::AccessibilityAdaptor adaptor, const Dali::AccessibilityGestureEvent& panEvent )
619 Dali::Internal::Adaptor::GetImplementation(adaptor).SendPanGesture( panEvent );
622 } // namespace AccessibilityAdaptor