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);
397 static const Internal::Adaptor::AccessibilityAdaptor& GetImplementation(const Dali::AccessibilityAdaptor& adaptor)
399 const BaseObject& handle = adaptor.GetBaseObject();
400 return static_cast<const Internal::Adaptor::AccessibilityAdaptor&>(handle);
404 } // namespace Adaptor
405 } // namespace Internal
407 ////////////////////////////////////////////////////////////////////////////////////////////////////
409 AccessibilityAdaptor::AccessibilityAdaptor()
413 AccessibilityAdaptor AccessibilityAdaptor::Get()
415 return Internal::Adaptor::AccessibilityAdaptor::Get();
418 AccessibilityAdaptor::~AccessibilityAdaptor()
424 void AccessibilityAdaptor::MockSetReadPosition( Vector2& position )
426 Internal::Adaptor::GetImplementation(*this).MockSetReadPosition( position );
431 Vector2 AccessibilityAdaptor::GetReadPosition() const
433 return Internal::Adaptor::GetImplementation(*this).GetReadPosition();
436 bool AccessibilityAdaptor::IsEnabled() const
438 //return Internal::Adaptor::GetImplementation(*this).IsEnabled();
442 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
444 Internal::Adaptor::GetImplementation(*this).SetActionHandler(handler);
447 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
449 Internal::Adaptor::GetImplementation(*this).SetGestureHandler(handler);
452 bool AccessibilityAdaptor::HandleActionNextEvent()
454 return Internal::Adaptor::GetImplementation(*this).HandleActionNextEvent();
457 bool AccessibilityAdaptor::HandleActionPreviousEvent()
459 return Internal::Adaptor::GetImplementation(*this).HandleActionPreviousEvent();
462 bool AccessibilityAdaptor::HandleActionActivateEvent()
464 return Internal::Adaptor::GetImplementation(*this).HandleActionActivateEvent();
467 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
469 return Internal::Adaptor::GetImplementation(*this).HandleActionReadEvent( x, y, allowReadAgain );
472 bool AccessibilityAdaptor::HandleActionReadNextEvent()
474 return Internal::Adaptor::GetImplementation(*this).HandleActionReadNextEvent();
477 bool AccessibilityAdaptor::HandleActionReadPreviousEvent()
479 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPreviousEvent();
482 bool AccessibilityAdaptor::HandleActionUpEvent()
484 return Internal::Adaptor::GetImplementation(*this).HandleActionUpEvent();
487 bool AccessibilityAdaptor::HandleActionDownEvent()
489 return Internal::Adaptor::GetImplementation(*this).HandleActionDownEvent();
492 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
494 return Internal::Adaptor::GetImplementation(*this).HandleActionClearFocusEvent();
497 bool AccessibilityAdaptor::HandleActionScrollEvent(TouchPoint& point, unsigned long timeStamp)
499 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp);
502 bool AccessibilityAdaptor::HandleActionBackEvent()
504 return Internal::Adaptor::GetImplementation(*this).HandleActionBackEvent();
507 void AccessibilityAdaptor::HandleActionEnableEvent()
509 Internal::Adaptor::GetImplementation(*this).HandleActionEnableEvent();
512 void AccessibilityAdaptor::HandleActionDisableEvent()
514 Internal::Adaptor::GetImplementation(*this).HandleActionDisableEvent();
517 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
519 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollUpEvent();
522 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
524 return Internal::Adaptor::GetImplementation(*this).HandleActionScrollDownEvent();
527 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
529 return Internal::Adaptor::GetImplementation(*this).HandleActionPageLeftEvent();
532 bool AccessibilityAdaptor::HandleActionPageRightEvent()
534 return Internal::Adaptor::GetImplementation(*this).HandleActionPageRightEvent();
537 bool AccessibilityAdaptor::HandleActionPageUpEvent()
539 return Internal::Adaptor::GetImplementation(*this).HandleActionPageUpEvent();
542 bool AccessibilityAdaptor::HandleActionPageDownEvent()
544 return Internal::Adaptor::GetImplementation(*this).HandleActionPageDownEvent();
547 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
549 return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToFirstEvent();
552 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
554 return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToLastEvent();
557 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
559 return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromTopEvent();
562 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
564 return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromNextEvent();
567 bool AccessibilityAdaptor::HandleActionZoomEvent()
569 return Internal::Adaptor::GetImplementation(*this).HandleActionZoomEvent();
572 bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
574 return Internal::Adaptor::GetImplementation(*this).HandleActionReadIndicatorInformationEvent();
577 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
579 return Internal::Adaptor::GetImplementation(*this).HandleActionReadPauseResumeEvent();
582 bool AccessibilityAdaptor::HandleActionStartStopEvent()
584 return Internal::Adaptor::GetImplementation(*this).HandleActionStartStopEvent();
587 AccessibilityAdaptor::AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor )
588 : BaseHandle( adaptor )