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 "toolkit-accessibility-adaptor.h"
20 #include <dali/public-api/object/base-object.h>
21 #include <dali/public-api/object/base-object.h>
22 #include <dali/devel-api/adaptor-framework/accessibility-action-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 );
53 bool IsEnabled() const;
54 void SetActionHandler(Dali::AccessibilityActionHandler& handler);
55 void SetGestureHandler(Dali::AccessibilityGestureHandler& handler);
57 Vector2 GetReadPosition() const;
59 bool HandleActionNextEvent();
60 bool HandleActionPreviousEvent();
61 bool HandleActionActivateEvent();
62 bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
63 bool HandleActionReadNextEvent();
64 bool HandleActionReadPreviousEvent();
65 bool HandleActionUpEvent();
66 bool HandleActionDownEvent();
67 bool HandleActionClearFocusEvent();
68 bool HandleActionScrollEvent(TouchPoint& point, unsigned long timeStamp);
69 bool HandleActionBackEvent();
70 bool HandleActionEnableEvent();
71 bool HandleActionDisableEvent();
72 bool HandleActionScrollUpEvent();
73 bool HandleActionScrollDownEvent();
74 bool HandleActionPageLeftEvent();
75 bool HandleActionPageRightEvent();
76 bool HandleActionPageUpEvent();
77 bool HandleActionPageDownEvent();
78 bool HandleActionMoveToFirstEvent();
79 bool HandleActionMoveToLastEvent();
80 bool HandleActionReadFromTopEvent();
81 bool HandleActionReadFromNextEvent();
82 bool HandleActionZoomEvent();
83 bool HandleActionReadIndicatorInformationEvent();
84 bool HandleActionReadPauseResumeEvent();
85 bool HandleActionStartStopEvent();
92 Dali::AccessibilityActionHandler* mActionHandler;
93 Dali::AccessibilityGestureHandler* mGestureHandler;
94 Vector2 mReadPosition;
96 static Dali::AccessibilityAdaptor mToolkitAccessibilityAdaptor;
99 Dali::AccessibilityAdaptor AccessibilityAdaptor::mToolkitAccessibilityAdaptor;
102 Dali::AccessibilityAdaptor AccessibilityAdaptor::Get()
104 if( !mToolkitAccessibilityAdaptor )
106 mToolkitAccessibilityAdaptor = Dali::AccessibilityAdaptor( new Dali::Internal::Adaptor::AccessibilityAdaptor() );
108 return mToolkitAccessibilityAdaptor;
111 AccessibilityAdaptor::AccessibilityAdaptor()
113 mReadPosition( 0.0f, 0.0f )
117 AccessibilityAdaptor::~AccessibilityAdaptor()
121 Vector2 AccessibilityAdaptor::GetReadPosition() const
123 return mReadPosition;
126 void AccessibilityAdaptor::MockSetReadPosition( Vector2& position )
128 mReadPosition = position;
131 bool AccessibilityAdaptor::IsEnabled() const
136 void AccessibilityAdaptor::SetActionHandler(Dali::AccessibilityActionHandler& handler)
138 mActionHandler = &handler;
141 void AccessibilityAdaptor::SetGestureHandler(Dali::AccessibilityGestureHandler& handler)
143 mGestureHandler = &handler;
146 bool AccessibilityAdaptor::HandleActionNextEvent()
150 return mActionHandler->AccessibilityActionNext( true );
155 bool AccessibilityAdaptor::HandleActionPreviousEvent()
159 return mActionHandler->AccessibilityActionPrevious( true );
164 bool AccessibilityAdaptor::HandleActionActivateEvent()
168 return mActionHandler->AccessibilityActionActivate();
173 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
177 return mActionHandler->AccessibilityActionRead( allowReadAgain );
182 bool AccessibilityAdaptor::HandleActionReadNextEvent()
186 return mActionHandler->AccessibilityActionReadNext( true );
191 bool AccessibilityAdaptor::HandleActionReadPreviousEvent()
195 return mActionHandler->AccessibilityActionReadPrevious( true );
200 bool AccessibilityAdaptor::HandleActionUpEvent()
204 return mActionHandler->AccessibilityActionUp();
209 bool AccessibilityAdaptor::HandleActionDownEvent()
213 return mActionHandler->AccessibilityActionDown();
218 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
222 return mActionHandler->ClearAccessibilityFocus();
227 bool AccessibilityAdaptor::HandleActionScrollEvent(TouchPoint& point, unsigned long timeStamp)
231 Dali::TouchEvent touchEvent;
232 touchEvent.points.push_back( point );
233 return mActionHandler->AccessibilityActionScroll( touchEvent );
238 bool AccessibilityAdaptor::HandleActionBackEvent()
242 return mActionHandler->AccessibilityActionBack();
247 bool AccessibilityAdaptor::HandleActionEnableEvent()
251 return mActionHandler->ChangeAccessibilityStatus();
256 bool AccessibilityAdaptor::HandleActionDisableEvent()
260 return mActionHandler->ChangeAccessibilityStatus();
265 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
269 return mActionHandler->AccessibilityActionScrollUp();
274 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
278 return mActionHandler->AccessibilityActionScrollDown();
283 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
287 return mActionHandler->AccessibilityActionPageLeft();
292 bool AccessibilityAdaptor::HandleActionPageRightEvent()
296 return mActionHandler->AccessibilityActionPageRight();
301 bool AccessibilityAdaptor::HandleActionPageUpEvent()
305 return mActionHandler->AccessibilityActionPageUp();
310 bool AccessibilityAdaptor::HandleActionPageDownEvent()
314 return mActionHandler->AccessibilityActionPageDown();
319 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
323 return mActionHandler->AccessibilityActionMoveToFirst();
328 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
332 return mActionHandler->AccessibilityActionMoveToLast();
337 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
341 return mActionHandler->AccessibilityActionReadFromTop();
346 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
350 return mActionHandler->AccessibilityActionReadFromNext();
355 bool AccessibilityAdaptor::HandleActionZoomEvent()
359 return mActionHandler->AccessibilityActionZoom();
364 bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
368 return mActionHandler->AccessibilityActionReadIndicatorInformation();
373 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
377 return mActionHandler->AccessibilityActionReadPauseResume();
382 bool AccessibilityAdaptor::HandleActionStartStopEvent()
386 return mActionHandler->AccessibilityActionStartStop();
391 static Internal::Adaptor::AccessibilityAdaptor& GetImplementation(Dali::AccessibilityAdaptor& adaptor)
393 BaseObject& handle = adaptor.GetBaseObject();
394 return static_cast<Internal::Adaptor::AccessibilityAdaptor&>(handle);
398 } // namespace Adaptor
399 } // namespace Internal
401 ////////////////////////////////////////////////////////////////////////////////////////////////////
403 AccessibilityAdaptor::AccessibilityAdaptor()
407 AccessibilityAdaptor AccessibilityAdaptor::Get()
409 return Internal::Adaptor::AccessibilityAdaptor::Get();
412 AccessibilityAdaptor::~AccessibilityAdaptor()
418 void AccessibilityAdaptor::MockSetReadPosition( Vector2& position )
420 Internal::Adaptor::GetImplementation(*this).MockSetReadPosition( position );
425 Vector2 AccessibilityAdaptor::GetReadPosition()
427 return Internal::Adaptor::GetImplementation(*this).GetReadPosition();
430 bool AccessibilityAdaptor::IsEnabled() const
432 //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()
448 return Internal::Adaptor::GetImplementation(*this).HandleActionNextEvent();
451 bool AccessibilityAdaptor::HandleActionPreviousEvent()
453 return Internal::Adaptor::GetImplementation(*this).HandleActionPreviousEvent();
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()
468 return Internal::Adaptor::GetImplementation(*this).HandleActionReadNextEvent();
471 bool AccessibilityAdaptor::HandleActionReadPreviousEvent()
473 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPreviousEvent();
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(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::HandleActionReadIndicatorInformationEvent()
568 return Internal::Adaptor::GetImplementation(*this).HandleActionReadIndicatorInformationEvent();
571 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
573 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPauseResumeEvent();
576 bool AccessibilityAdaptor::HandleActionStartStopEvent()
578 return Internal::Adaptor::GetImplementation(*this).HandleActionStartStopEvent();
581 AccessibilityAdaptor::AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor )
582 : BaseHandle( adaptor )