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 ),
55 mAccessibilityGestureDetector = new AccessibilityGestureDetector();
58 void AccessibilityAdaptor::EnableAccessibility()
60 if(mIsEnabled == false)
66 mActionHandler->ChangeAccessibilityStatus();
71 void AccessibilityAdaptor::DisableAccessibility()
73 if(mIsEnabled == true)
79 mActionHandler->ChangeAccessibilityStatus();
82 // Destroy the TtsPlayer if exists.
83 if ( Adaptor::IsAvailable() )
85 Dali::Adaptor& adaptor = Dali::Adaptor::Get();
86 Adaptor& adaptorImpl = Adaptor::GetImplementation( adaptor );
87 adaptorImpl.DestroyTtsPlayer( Dali::TtsPlayer::SCREEN_READER );
92 bool AccessibilityAdaptor::IsEnabled() const
97 Vector2 AccessibilityAdaptor::GetReadPosition() const
102 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
104 mActionHandler = &handler;
107 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
109 if( mAccessibilityGestureDetector )
111 mAccessibilityGestureDetector->SetGestureHandler(handler);
115 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
121 ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
124 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
129 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
135 ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
138 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
143 bool AccessibilityAdaptor::HandleActionActivateEvent()
149 ret = mActionHandler->AccessibilityActionActivate();
152 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
157 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
161 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
163 mReadPosition.x = static_cast< float > (x);
164 mReadPosition.y = static_cast< float > (y);
168 ret = mActionHandler->AccessibilityActionRead( allowReadAgain );
169 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
175 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
181 ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
184 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
189 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
195 ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
198 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
203 bool AccessibilityAdaptor::HandleActionUpEvent()
209 ret = mActionHandler->AccessibilityActionUp();
212 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
217 bool AccessibilityAdaptor::HandleActionDownEvent()
223 ret = mActionHandler->AccessibilityActionDown();
226 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
231 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
237 ret = mActionHandler->ClearAccessibilityFocus();
240 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
245 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, uint32_t timeStamp)
249 // We always need to emit a scroll signal, whether it's only a hover or not,
250 // so always send the action to the action handler.
253 Dali::TouchEvent touch = Integration::NewTouchEvent( timeStamp, point );
254 ret = mActionHandler->AccessibilityActionScroll( touch );
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::HandleActionBackEvent()
279 ret = mActionHandler->AccessibilityActionBack();
282 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
287 void AccessibilityAdaptor::HandleActionEnableEvent()
289 EnableAccessibility();
292 void AccessibilityAdaptor::HandleActionDisableEvent()
294 DisableAccessibility();
297 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
303 ret = mActionHandler->AccessibilityActionScrollUp();
306 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
312 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
318 ret = mActionHandler->AccessibilityActionScrollDown();
321 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
326 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
332 ret = mActionHandler->AccessibilityActionPageLeft();
335 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
340 bool AccessibilityAdaptor::HandleActionPageRightEvent()
346 ret = mActionHandler->AccessibilityActionPageRight();
349 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
354 bool AccessibilityAdaptor::HandleActionPageUpEvent()
360 ret = mActionHandler->AccessibilityActionPageUp();
363 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
368 bool AccessibilityAdaptor::HandleActionPageDownEvent()
374 ret = mActionHandler->AccessibilityActionPageDown();
377 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
382 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
388 ret = mActionHandler->AccessibilityActionMoveToFirst();
391 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
396 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
402 ret = mActionHandler->AccessibilityActionMoveToLast();
405 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
410 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
416 ret = mActionHandler->AccessibilityActionReadFromTop();
419 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
424 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
430 ret = mActionHandler->AccessibilityActionReadFromNext();
433 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
438 bool AccessibilityAdaptor::HandleActionZoomEvent()
444 ret = mActionHandler->AccessibilityActionZoom();
447 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
452 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
458 ret = mActionHandler->AccessibilityActionReadPauseResume();
461 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
466 bool AccessibilityAdaptor::HandleActionStartStopEvent()
472 ret = mActionHandler->AccessibilityActionStartStop();
475 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
480 AccessibilityAdaptor::~AccessibilityAdaptor()
482 // Do any platform specific clean-up in OnDestroy()
486 } // namespace Adaptor
488 } // namespace Internal