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 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 touch = Integration::NewTouchEvent(timeStamp, point);
244 return mActionHandler->AccessibilityActionScroll( touch );
249 bool AccessibilityAdaptor::HandleActionBackEvent()
253 return mActionHandler->AccessibilityActionBack();
258 bool AccessibilityAdaptor::HandleActionEnableEvent()
262 return mActionHandler->ChangeAccessibilityStatus();
267 bool AccessibilityAdaptor::HandleActionDisableEvent()
271 return mActionHandler->ChangeAccessibilityStatus();
276 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
280 return mActionHandler->AccessibilityActionScrollUp();
285 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
289 return mActionHandler->AccessibilityActionScrollDown();
294 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
298 return mActionHandler->AccessibilityActionPageLeft();
303 bool AccessibilityAdaptor::HandleActionPageRightEvent()
307 return mActionHandler->AccessibilityActionPageRight();
312 bool AccessibilityAdaptor::HandleActionPageUpEvent()
316 return mActionHandler->AccessibilityActionPageUp();
321 bool AccessibilityAdaptor::HandleActionPageDownEvent()
325 return mActionHandler->AccessibilityActionPageDown();
330 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
334 return mActionHandler->AccessibilityActionMoveToFirst();
339 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
343 return mActionHandler->AccessibilityActionMoveToLast();
348 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
352 return mActionHandler->AccessibilityActionReadFromTop();
357 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
361 return mActionHandler->AccessibilityActionReadFromNext();
366 bool AccessibilityAdaptor::HandleActionZoomEvent()
370 return mActionHandler->AccessibilityActionZoom();
375 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
379 return mActionHandler->AccessibilityActionReadPauseResume();
384 bool AccessibilityAdaptor::HandleActionStartStopEvent()
388 return mActionHandler->AccessibilityActionStartStop();
393 static Internal::Adaptor::AccessibilityAdaptor& GetImplementation(Dali::AccessibilityAdaptor& adaptor)
395 BaseObject& handle = adaptor.GetBaseObject();
396 return static_cast<Internal::Adaptor::AccessibilityAdaptor&>(handle);
399 static const Internal::Adaptor::AccessibilityAdaptor& GetImplementation(const Dali::AccessibilityAdaptor& adaptor)
401 const BaseObject& handle = adaptor.GetBaseObject();
402 return static_cast<const Internal::Adaptor::AccessibilityAdaptor&>(handle);
406 } // namespace Adaptor
407 } // namespace Internal
409 ////////////////////////////////////////////////////////////////////////////////////////////////////
411 AccessibilityAdaptor::AccessibilityAdaptor()
415 AccessibilityAdaptor AccessibilityAdaptor::Get()
417 return Internal::Adaptor::AccessibilityAdaptor::Get();
420 AccessibilityAdaptor::~AccessibilityAdaptor()
426 Vector2 AccessibilityAdaptor::GetReadPosition() const
428 return Internal::Adaptor::GetImplementation(*this).GetReadPosition();
431 bool AccessibilityAdaptor::IsEnabled() const
433 return Internal::Adaptor::GetImplementation(*this).IsEnabled();
436 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
438 Internal::Adaptor::GetImplementation(*this).SetActionHandler(handler);
441 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
443 Internal::Adaptor::GetImplementation(*this).SetGestureHandler(handler);
446 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
448 return Internal::Adaptor::GetImplementation(*this).HandleActionNextEvent(allowEndFeedback);
451 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
453 return Internal::Adaptor::GetImplementation(*this).HandleActionPreviousEvent(allowEndFeedback);
456 bool AccessibilityAdaptor::HandleActionActivateEvent()
458 return Internal::Adaptor::GetImplementation(*this).HandleActionActivateEvent();
461 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
463 return Internal::Adaptor::GetImplementation(*this).HandleActionReadEvent( x, y, allowReadAgain );
466 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
468 return Internal::Adaptor::GetImplementation(*this).HandleActionReadNextEvent(allowEndFeedback);
471 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
473 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPreviousEvent(allowEndFeedback);
476 bool AccessibilityAdaptor::HandleActionUpEvent()
478 return Internal::Adaptor::GetImplementation(*this).HandleActionUpEvent();
481 bool AccessibilityAdaptor::HandleActionDownEvent()
483 return Internal::Adaptor::GetImplementation(*this).HandleActionDownEvent();
486 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
488 return Internal::Adaptor::GetImplementation(*this).HandleActionClearFocusEvent();
491 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
493 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp);
496 bool AccessibilityAdaptor::HandleActionBackEvent()
498 return Internal::Adaptor::GetImplementation(*this).HandleActionBackEvent();
501 void AccessibilityAdaptor::HandleActionEnableEvent()
503 Internal::Adaptor::GetImplementation(*this).HandleActionEnableEvent();
506 void AccessibilityAdaptor::HandleActionDisableEvent()
508 Internal::Adaptor::GetImplementation(*this).HandleActionDisableEvent();
511 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
513 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollUpEvent();
516 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
518 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollDownEvent();
521 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
523 return Internal::Adaptor::GetImplementation(*this).HandleActionPageLeftEvent();
526 bool AccessibilityAdaptor::HandleActionPageRightEvent()
528 return Internal::Adaptor::GetImplementation(*this).HandleActionPageRightEvent();
531 bool AccessibilityAdaptor::HandleActionPageUpEvent()
533 return Internal::Adaptor::GetImplementation(*this).HandleActionPageUpEvent();
536 bool AccessibilityAdaptor::HandleActionPageDownEvent()
538 return Internal::Adaptor::GetImplementation(*this).HandleActionPageDownEvent();
541 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
543 return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToFirstEvent();
546 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
548 return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToLastEvent();
551 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
553 return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromTopEvent();
556 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
558 return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromNextEvent();
561 bool AccessibilityAdaptor::HandleActionZoomEvent()
563 return Internal::Adaptor::GetImplementation(*this).HandleActionZoomEvent();
566 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
568 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPauseResumeEvent();
571 bool AccessibilityAdaptor::HandleActionStartStopEvent()
573 return Internal::Adaptor::GetImplementation(*this).HandleActionStartStopEvent();
576 AccessibilityAdaptor::AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor )
577 : BaseHandle( adaptor )
586 namespace AccessibilityAdaptor
591 void MockSetReadPosition( Dali::AccessibilityAdaptor adaptor, Dali::Vector2& position )
593 Dali::Internal::Adaptor::GetImplementation(adaptor).MockSetReadPosition( position );
596 void SetEnabled( Dali::AccessibilityAdaptor adaptor, bool enabled )
598 Dali::Internal::Adaptor::GetImplementation(adaptor).SetEnabled(enabled);
601 void SendPanGesture( Dali::AccessibilityAdaptor adaptor, const Dali::AccessibilityGestureEvent& panEvent )
603 Dali::Internal::Adaptor::GetImplementation(adaptor).SendPanGesture( panEvent );
606 } // namespace AccessibilityAdaptor