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.
19 #include <dali/internal/accessibility/common/accessibility-adaptor-impl.h>
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/integration-api/events/hover-event-integ.h>
28 #include <dali/internal/adaptor/common/adaptor-impl.h>
29 #include <dali/internal/system/common/system-settings.h>
40 namespace // unnamed namespace
43 #if defined(DEBUG_ENABLED)
44 Debug::Filter* gAccessibilityAdaptorLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_ADAPTOR");
47 } // unnamed namespace
49 AccessibilityAdaptor::AccessibilityAdaptor()
51 mActionHandler( NULL ),
54 mAccessibilityGestureDetector = new AccessibilityGestureDetector();
57 void AccessibilityAdaptor::EnableAccessibility()
59 if(mIsEnabled == false)
65 mActionHandler->ChangeAccessibilityStatus();
70 void AccessibilityAdaptor::DisableAccessibility()
72 if(mIsEnabled == true)
78 mActionHandler->ChangeAccessibilityStatus();
81 // Destroy the TtsPlayer if exists.
82 if ( Adaptor::IsAvailable() )
84 Dali::Adaptor& adaptor = Dali::Adaptor::Get();
85 Adaptor& adaptorImpl = Adaptor::GetImplementation( adaptor );
86 adaptorImpl.DestroyTtsPlayer( Dali::TtsPlayer::SCREEN_READER );
91 bool AccessibilityAdaptor::IsEnabled() const
96 Vector2 AccessibilityAdaptor::GetReadPosition() const
101 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
103 mActionHandler = &handler;
106 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
108 if( mAccessibilityGestureDetector )
110 mAccessibilityGestureDetector->SetGestureHandler(handler);
114 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
120 ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
123 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
128 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
134 ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
137 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
142 bool AccessibilityAdaptor::HandleActionActivateEvent()
148 ret = mActionHandler->AccessibilityActionActivate();
151 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
156 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
160 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
162 mReadPosition.x = static_cast< float > (x);
163 mReadPosition.y = static_cast< float > (y);
167 ret = mActionHandler->AccessibilityActionRead( allowReadAgain );
168 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
174 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
180 ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
183 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
188 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
194 ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
197 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
202 bool AccessibilityAdaptor::HandleActionUpEvent()
208 ret = mActionHandler->AccessibilityActionUp();
211 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
216 bool AccessibilityAdaptor::HandleActionDownEvent()
222 ret = mActionHandler->AccessibilityActionDown();
225 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
230 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
236 ret = mActionHandler->ClearAccessibilityFocus();
239 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
244 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, uint32_t timeStamp)
248 // We always need to emit a scroll signal, whether it's only a hover or not,
249 // so always send the action to the action handler.
252 Dali::TouchEvent event(timeStamp);
253 event.points.push_back(point);
254 ret = mActionHandler->AccessibilityActionScroll( event );
257 Integration::TouchEvent touchEvent;
258 Integration::HoverEvent hoverEvent;
259 Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent( Integration::Point( point ), timeStamp, touchEvent, hoverEvent );
260 if( type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth ) // hover event is ignored
262 // Process the touch event in accessibility gesture detector
263 if( mAccessibilityGestureDetector )
265 mAccessibilityGestureDetector->SendEvent( touchEvent );
273 bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, uint32_t timeStamp)
277 Dali::TouchEvent touchEvent(timeStamp);
278 touchEvent.points.push_back(point);
282 ret = mActionHandler->AccessibilityActionTouch(touchEvent);
287 bool AccessibilityAdaptor::HandleActionBackEvent()
293 ret = mActionHandler->AccessibilityActionBack();
296 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
301 void AccessibilityAdaptor::HandleActionEnableEvent()
303 EnableAccessibility();
306 void AccessibilityAdaptor::HandleActionDisableEvent()
308 DisableAccessibility();
311 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
317 ret = mActionHandler->AccessibilityActionScrollUp();
320 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
326 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
332 ret = mActionHandler->AccessibilityActionScrollDown();
335 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
340 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
346 ret = mActionHandler->AccessibilityActionPageLeft();
349 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
354 bool AccessibilityAdaptor::HandleActionPageRightEvent()
360 ret = mActionHandler->AccessibilityActionPageRight();
363 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
368 bool AccessibilityAdaptor::HandleActionPageUpEvent()
374 ret = mActionHandler->AccessibilityActionPageUp();
377 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
382 bool AccessibilityAdaptor::HandleActionPageDownEvent()
388 ret = mActionHandler->AccessibilityActionPageDown();
391 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
396 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
402 ret = mActionHandler->AccessibilityActionMoveToFirst();
405 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
410 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
416 ret = mActionHandler->AccessibilityActionMoveToLast();
419 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
424 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
430 ret = mActionHandler->AccessibilityActionReadFromTop();
433 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
438 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
444 ret = mActionHandler->AccessibilityActionReadFromNext();
447 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
452 bool AccessibilityAdaptor::HandleActionZoomEvent()
458 ret = mActionHandler->AccessibilityActionZoom();
461 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
466 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
472 ret = mActionHandler->AccessibilityActionReadPauseResume();
475 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
480 bool AccessibilityAdaptor::HandleActionStartStopEvent()
486 ret = mActionHandler->AccessibilityActionStartStop();
489 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
494 AccessibilityAdaptor::~AccessibilityAdaptor()
496 // Do any platform specific clean-up in OnDestroy()
500 } // namespace Adaptor
502 } // namespace Internal