2 * Copyright (c) 2014 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 "accessibility-manager-impl.h"
24 #include <Elementary.h>
26 #include <dali/public-api/dali-core.h>
27 #include <dali/integration-api/debug.h>
28 #include <dali/integration-api/events/touch-event-integ.h>
29 #include <dali/integration-api/events/gesture-requests.h>
30 #include "system-settings.h"
42 #if defined(DEBUG_ENABLED)
43 Debug::Filter* gAccessibilityManagerLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_MANAGER");
45 } // unnamed namespace
47 bool AccessibilityManager::HandleActionNextEvent(bool allowEndFeedback)
50 Dali::AccessibilityManager handle( this );
53 * In order to application decide reading action first,
54 * emit ActionNext signal in first, AccessibilityActionNext for handler in next
56 if( !mIndicatorFocused )
58 if( !mActionNextSignalV2.Empty() )
60 mActionNextSignalV2.Emit( handle );
64 if( mIndicator && mIndicatorFocused )
66 Elm_Access_Action_Info actionInfo;
67 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
69 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
71 else if( mActionHandler )
73 ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
76 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
81 bool AccessibilityManager::HandleActionPreviousEvent(bool allowEndFeedback)
85 Dali::AccessibilityManager handle( this );
88 * In order to application decide reading action first,
89 * emit ActionPrevious signal in first, AccessibilityActionPrevious for handler in next
91 if ( !mIndicatorFocused )
93 if( !mActionPreviousSignalV2.Empty() )
95 mActionPreviousSignalV2.Emit( handle );
99 if( mIndicator && mIndicatorFocused )
101 Elm_Access_Action_Info actionInfo;
102 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
104 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
106 else if( mActionHandler )
108 ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
111 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
116 bool AccessibilityManager::HandleActionActivateEvent()
120 Dali::AccessibilityManager handle( this );
123 * In order to application decide reading action first,
124 * emit ActionActivate signal in first, AccessibilityActionActivate for handler in next
126 if ( !mIndicatorFocused )
128 if( !mActionActivateSignalV2.Empty() )
130 mActionActivateSignalV2.Emit( handle );
134 if( mIndicator && mIndicatorFocused )
136 Elm_Access_Action_Info actionInfo;
137 actionInfo.action_type = ELM_ACCESS_ACTION_ACTIVATE;
139 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
141 else if( mActionHandler )
143 ret = mActionHandler->AccessibilityActionActivate();
146 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
151 bool AccessibilityManager::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
155 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
160 Dali::AccessibilityManager handle( this );
162 bool indicatorFocused = false;
164 // Check whether the Indicator is focused
165 if( mIndicator && mIndicator->IsConnected() )
167 // Check the position and size of Indicator actor
168 Dali::Actor indicatorActor = mIndicator->GetActor();
169 Vector3 position = Vector3(0.0f, 0.0f, 0.0f);
170 Vector3 size = indicatorActor.GetCurrentSize();
172 if(mReadPosition.x >= position.x &&
173 mReadPosition.x <= position.x + size.width &&
174 mReadPosition.y >= position.y &&
175 mReadPosition.y <= position.y + size.height)
177 indicatorFocused = true;
178 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Indicator area!!!!\n", __FUNCTION__, __LINE__);
184 if( !mIndicatorFocused && indicatorFocused )
186 // If Indicator is focused, the focus should be cleared in Dali focus chain.
189 mActionHandler->ClearAccessibilityFocus();
192 else if( mIndicatorFocused && !indicatorFocused )
194 Elm_Access_Action_Info actionInfo;
195 actionInfo.action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
197 // Indicator should be unhighlighted
198 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
199 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Send unhighlight message to indicator!!!!\n", __FUNCTION__, __LINE__);
202 mIndicatorFocused = indicatorFocused;
204 // Send accessibility READ action information to Indicator
205 if( mIndicatorFocused )
207 Elm_Access_Action_Info actionInfo;
208 actionInfo.x = mReadPosition.x;
209 actionInfo.y = mReadPosition.y;
213 actionInfo.action_type = ELM_ACCESS_ACTION_READ;
217 actionInfo.action_type = static_cast<Elm_Access_Action_Type>( GetElmAccessActionOver() );
220 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
222 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Send READ message to indicator!!!!\n", __FUNCTION__, __LINE__);
229 * In order to application decide reading action first,
230 * emit ActionRead signal in first, AccessibilityActionRead for handler in next
232 if( !mIndicatorFocused )
234 if ( !mActionReadSignalV2.Empty() )
236 mActionReadSignalV2.Emit( handle );
243 * In order to application decide reading action first,
244 * emit ActionRead signal in first, AccessibilityActionRead for handler in next
246 if( !mIndicatorFocused )
248 if ( !mActionOverSignalV2.Empty() )
250 mActionOverSignalV2.Emit( handle );
255 if( mActionHandler && !mIndicatorFocused)
257 // If Indicator is not focused, the accessibility actions should be handled by the registered
258 // accessibility action handler (e.g. focus manager)
259 ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
260 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
266 bool AccessibilityManager::HandleActionReadNextEvent(bool allowEndFeedback)
270 Dali::AccessibilityManager handle( this );
273 * In order to application decide reading action first,
274 * emit ActionReadNext signal in first, AccessibilityActionReadNext for handler in next
276 if ( !mIndicatorFocused )
278 if( !mActionReadNextSignalV2.Empty() )
280 mActionReadNextSignalV2.Emit( handle );
284 if( mIndicator && mIndicatorFocused )
286 Elm_Access_Action_Info actionInfo;
287 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
289 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
291 else if( mActionHandler )
293 ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
296 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
301 bool AccessibilityManager::HandleActionReadPreviousEvent(bool allowEndFeedback)
305 Dali::AccessibilityManager handle( this );
308 * In order to application decide reading action first,
309 * emit ActionReadPrevious signal in first, AccessibilityActionReadPrevious for handler in next
311 if ( !mIndicatorFocused )
313 if( !mActionReadPreviousSignalV2.Empty() )
315 mActionReadPreviousSignalV2.Emit( handle );
319 if( mIndicator && mIndicatorFocused )
321 Elm_Access_Action_Info actionInfo;
322 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
324 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
326 else if( mActionHandler )
328 ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
331 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
336 bool AccessibilityManager::HandleActionUpEvent()
340 Dali::AccessibilityManager handle( this );
343 * In order to application decide reading action first,
344 * emit ActionUp signal in first, AccessibilityActionUp for handler in next
346 if ( !mIndicatorFocused )
348 if( !mActionUpSignalV2.Empty() )
350 mActionUpSignalV2.Emit( handle );
354 if( mIndicator && mIndicatorFocused )
356 Elm_Access_Action_Info actionInfo;
357 actionInfo.action_type = ELM_ACCESS_ACTION_UP;
359 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
361 else if( mActionHandler )
363 ret = mActionHandler->AccessibilityActionUp();
366 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
371 bool AccessibilityManager::HandleActionDownEvent()
375 Dali::AccessibilityManager handle( this );
378 * In order to application decide reading action first,
379 * emit ActionDown signal in first, AccessibilityActionDown for handler in next
381 if ( !mIndicatorFocused )
383 if( !mActionDownSignalV2.Empty() )
385 mActionDownSignalV2.Emit( handle );
389 if( mIndicator && mIndicatorFocused )
391 Elm_Access_Action_Info actionInfo;
392 actionInfo.action_type = ELM_ACCESS_ACTION_DOWN;
394 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
396 else if( mActionHandler )
398 ret = mActionHandler->AccessibilityActionDown();
401 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
406 } // namespace Adaptor
408 } // namespace Internal