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/touch-data-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::TouchData touchData = Integration::NewTouchData( timeStamp, point );
254 ret = mActionHandler->AccessibilityActionScroll( touchData );
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::TouchData touchData = Integration::NewTouchData( timeStamp, point );
281 ret = mActionHandler->AccessibilityActionTouch( touchData );
286 bool AccessibilityAdaptor::HandleActionBackEvent()
292 ret = mActionHandler->AccessibilityActionBack();
295 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
300 void AccessibilityAdaptor::HandleActionEnableEvent()
302 EnableAccessibility();
305 void AccessibilityAdaptor::HandleActionDisableEvent()
307 DisableAccessibility();
310 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
316 ret = mActionHandler->AccessibilityActionScrollUp();
319 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
325 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
331 ret = mActionHandler->AccessibilityActionScrollDown();
334 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
339 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
345 ret = mActionHandler->AccessibilityActionPageLeft();
348 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
353 bool AccessibilityAdaptor::HandleActionPageRightEvent()
359 ret = mActionHandler->AccessibilityActionPageRight();
362 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
367 bool AccessibilityAdaptor::HandleActionPageUpEvent()
373 ret = mActionHandler->AccessibilityActionPageUp();
376 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
381 bool AccessibilityAdaptor::HandleActionPageDownEvent()
387 ret = mActionHandler->AccessibilityActionPageDown();
390 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
395 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
401 ret = mActionHandler->AccessibilityActionMoveToFirst();
404 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
409 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
415 ret = mActionHandler->AccessibilityActionMoveToLast();
418 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
423 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
429 ret = mActionHandler->AccessibilityActionReadFromTop();
432 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
437 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
443 ret = mActionHandler->AccessibilityActionReadFromNext();
446 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
451 bool AccessibilityAdaptor::HandleActionZoomEvent()
457 ret = mActionHandler->AccessibilityActionZoom();
460 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
465 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
471 ret = mActionHandler->AccessibilityActionReadPauseResume();
474 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
479 bool AccessibilityAdaptor::HandleActionStartStopEvent()
485 ret = mActionHandler->AccessibilityActionStartStop();
488 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
493 AccessibilityAdaptor::~AccessibilityAdaptor()
495 // Do any platform specific clean-up in OnDestroy()
499 } // namespace Adaptor
501 } // namespace Internal