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.
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/touch-integ.h>
26 #include <dali/integration-api/events/hover-event-integ.h>
29 #include <dali/internal/adaptor/common/adaptor-impl.h>
30 #include <dali/internal/system/common/system-settings.h>
41 namespace // unnamed namespace
44 #if defined(DEBUG_ENABLED)
45 Debug::Filter* gAccessibilityAdaptorLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_ADAPTOR");
48 } // unnamed namespace
50 AccessibilityAdaptor::AccessibilityAdaptor()
52 mActionHandler( NULL ),
56 mAccessibilityGestureDetector = new AccessibilityGestureDetector();
59 void AccessibilityAdaptor::EnableAccessibility()
61 if(mIsEnabled == false)
67 mActionHandler->ChangeAccessibilityStatus();
72 void AccessibilityAdaptor::DisableAccessibility()
74 if(mIsEnabled == true)
80 mActionHandler->ChangeAccessibilityStatus();
83 // Destroy the TtsPlayer if exists.
84 if ( Adaptor::IsAvailable() )
86 Dali::Adaptor& adaptor = Dali::Adaptor::Get();
87 Adaptor& adaptorImpl = Adaptor::GetImplementation( adaptor );
88 adaptorImpl.DestroyTtsPlayer( Dali::TtsPlayer::SCREEN_READER );
93 bool AccessibilityAdaptor::IsEnabled() const
98 void AccessibilityAdaptor::SetForcedEnable( bool forced )
103 bool AccessibilityAdaptor::IsForcedEnable() const
108 Vector2 AccessibilityAdaptor::GetReadPosition() const
110 return mReadPosition;
113 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
115 mActionHandler = &handler;
118 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
120 if( mAccessibilityGestureDetector )
122 mAccessibilityGestureDetector->SetGestureHandler(handler);
126 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
132 ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
135 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
140 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
146 ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
149 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
154 bool AccessibilityAdaptor::HandleActionActivateEvent()
160 ret = mActionHandler->AccessibilityActionActivate();
163 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
168 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
172 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
174 mReadPosition.x = static_cast< float > (x);
175 mReadPosition.y = static_cast< float > (y);
179 ret = mActionHandler->AccessibilityActionRead( allowReadAgain );
180 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
186 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
192 ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
195 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
200 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
206 ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
209 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
214 bool AccessibilityAdaptor::HandleActionUpEvent()
220 ret = mActionHandler->AccessibilityActionUp();
223 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
228 bool AccessibilityAdaptor::HandleActionDownEvent()
234 ret = mActionHandler->AccessibilityActionDown();
237 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
242 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
248 ret = mActionHandler->ClearAccessibilityFocus();
251 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
256 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, uint32_t timeStamp)
260 // We always need to emit a scroll signal, whether it's only a hover or not,
261 // so always send the action to the action handler.
264 Dali::TouchEvent touch = Integration::NewTouchEvent( timeStamp, point );
265 ret = mActionHandler->AccessibilityActionScroll( touch );
268 Integration::TouchEvent touchEvent;
269 Integration::HoverEvent hoverEvent;
270 Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent( Integration::Point( point ), timeStamp, touchEvent, hoverEvent );
271 if( type == Integration::TouchEventCombiner::DISPATCH_TOUCH || type == Integration::TouchEventCombiner::DISPATCH_BOTH ) // hover event is ignored
273 // Process the touch event in accessibility gesture detector
274 if( mAccessibilityGestureDetector )
276 mAccessibilityGestureDetector->SendEvent( touchEvent );
284 bool AccessibilityAdaptor::HandleActionBackEvent()
290 ret = mActionHandler->AccessibilityActionBack();
293 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
298 void AccessibilityAdaptor::HandleActionEnableEvent()
300 EnableAccessibility();
303 void AccessibilityAdaptor::HandleActionDisableEvent()
305 DisableAccessibility();
308 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
314 ret = mActionHandler->AccessibilityActionScrollUp();
317 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
323 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
329 ret = mActionHandler->AccessibilityActionScrollDown();
332 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
337 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
343 ret = mActionHandler->AccessibilityActionPageLeft();
346 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
351 bool AccessibilityAdaptor::HandleActionPageRightEvent()
357 ret = mActionHandler->AccessibilityActionPageRight();
360 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
365 bool AccessibilityAdaptor::HandleActionPageUpEvent()
371 ret = mActionHandler->AccessibilityActionPageUp();
374 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
379 bool AccessibilityAdaptor::HandleActionPageDownEvent()
385 ret = mActionHandler->AccessibilityActionPageDown();
388 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
393 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
399 ret = mActionHandler->AccessibilityActionMoveToFirst();
402 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
407 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
413 ret = mActionHandler->AccessibilityActionMoveToLast();
416 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
421 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
427 ret = mActionHandler->AccessibilityActionReadFromTop();
430 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
435 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
441 ret = mActionHandler->AccessibilityActionReadFromNext();
444 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
449 bool AccessibilityAdaptor::HandleActionZoomEvent()
455 ret = mActionHandler->AccessibilityActionZoom();
458 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
463 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
469 ret = mActionHandler->AccessibilityActionReadPauseResume();
472 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
477 bool AccessibilityAdaptor::HandleActionStartStopEvent()
483 ret = mActionHandler->AccessibilityActionStartStop();
486 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
491 AccessibilityAdaptor::~AccessibilityAdaptor()
493 // Do any platform specific clean-up in OnDestroy()
497 } // namespace Adaptor
499 } // namespace Internal