add patch
[framework/osp/uifw.git] / src / ui / FUi_AccessibilityManager.cpp
index eb32e60..8e27a38 100644 (file)
@@ -115,7 +115,7 @@ public:
                }
                if (__start)
                {
-                       return;
+                       Stop();
                }
                __start = true;
                __mode = mode;
@@ -336,7 +336,6 @@ _AccessibilityManager::Initialize(void)
 
        if (IsScreenReaderActivated())
        {
-               __pTtsPlayer->SetLocale(__pSettingLoader->GetLocale());
                __pTtsPlayer->Activate();
        }
        pGuidePopupTimer = new (std::nothrow) GuidePopupTimer;
@@ -371,7 +370,7 @@ _AccessibilityManager::ReadContent(const Tizen::Base::String& content)
 {
        if (__pTtsPlayer)
        {
-               //ShowPopup(content);
+//             ShowPopup(content);
                __pTtsPlayer->ReadGrammar(content);
        }
        return E_SUCCESS;
@@ -394,6 +393,10 @@ _AccessibilityManager::ReadElement(_AccessibilityAutoReadingMode mode)
        }
        else if (mode == _ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM_OF_CONTENTS)
        {
+               if(__pTitleElement && __pTitleElement->IsUpdated())
+               {
+                       return;
+               }
                for (int i = 0 ; i < count ; i++)
                {
                        r = __candidateList.GetAt(i, pElement);
@@ -451,7 +454,7 @@ _AccessibilityManager::ReadElement(const _AccessibilityElement& element)
                        delete pList;
                        pList = null;
                }
-               //ShowPopup();
+//             ShowPopup();
                __pTtsPlayer->ReadGrammar(element.GetReadingContents());
        }
        return E_SUCCESS;
@@ -1223,6 +1226,10 @@ _AccessibilityManager::RemoveContainer(const _AccessibilityContainer& container)
        }
        if (__pTargetContainer == &container)
        {
+               if(__pTargetContainer)
+               {
+                       __pTargetContainer->SetCurrentFocusedElement(null);
+               }
                __pTargetContainer = null;
                __pTargetElement = null;
        }
@@ -1298,7 +1305,7 @@ _AccessibilityManager::MakeList(void)
        {
                if (controlList.GetAt(i, pControl) == E_SUCCESS)
                {
-                       FloatRectangle rect = pControl->GetAbsoluteBoundsF();
+                       FloatRectangle rect = pControl->GetAbsoluteBoundsF(true);
                        if (rect.x + rect.width <= 0.0f || (rect.x) >= margin)
                        {
                                bool inside = false;
@@ -1414,7 +1421,7 @@ _AccessibilityManager::MakeList(void)
                        pControl = &(pPositionByControlListElement->GetParent()->GetOwner());
                        while (pControl)
                        {
-                               rect = pControl->GetAbsoluteBounds();
+                               rect = pControl->GetAbsoluteBounds(true);
                                if (rect.y >0)
                                {
                                        break;
@@ -1470,8 +1477,6 @@ _AccessibilityManager::MakeList(void)
                                        __candidateList.Add(pElement);
                                        elementPositionByControlList.Remove(pElement);
                                        elementPositionByControlList.InsertAt(pElement, index);
-                                       elementPositionList.Remove(pElement);
-                                       elementPositionList.InsertAt(pElement, index);
                                        index++;
                                }
                        }
@@ -1480,6 +1485,8 @@ _AccessibilityManager::MakeList(void)
                {
                        elementPositionList.Remove(pPositionByControlListElement);
                        elementPositionList.InsertAt(pPositionByControlListElement, index);
+                       elementPositionByControlList.Remove(pPositionByControlListElement);
+                       elementPositionByControlList.InsertAt(pPositionByControlListElement, index);
                        __candidateList.Add(pPositionByControlListElement);
                        index++;
                        continue;
@@ -1492,21 +1499,95 @@ _AccessibilityManager::MakeList(void)
        {
                return;
        }
-
        _AccessibilityElement* pElement = null;
+       _AccessibilityElement* pElement2 = null;
+       int selectedHeader = -1;
+       int startHeader = -1;
+       int endHeader = -1;
+       int selectedFooter = -1;
+       int startFooter = -1;
+       int endFooter = -1;
        for (int i = 0 ; i < count ; i++)
        {
                r = __candidateList.GetAt(i, pElement);
-               if (r != E_SUCCESS)
+               if(pElement->GetParent()->GetPriority() == ACCESSIBILITY_PRIORITY_TOP)
                {
-                       continue;
+                       if (startHeader == -1)
+                       {
+                               startHeader=i;
+                       }
+                       endHeader = i;
+               }
+               if(pElement->GetParent()->GetPriority() == ACCESSIBILITY_PRIORITY_BOTTOM)
+               {
+                       if (startFooter == -1)
+                       {
+                               startFooter=i;
+                       }
+                       endFooter = i;
+               }
+       }
+       if(startHeader != -1 && endHeader - startHeader > 0)
+       {
+               for(int i = startHeader; i <= endHeader ; i++)
+               {
+                       r = __candidateList.GetAt(i, pElement);
+                       if (r != E_SUCCESS)
+                       {
+                               continue;
+                       }
+                       selectedHeader = i;
+                       for(int j = i +1 ; j <= endHeader; j++)
+                       {
+                               r = __candidateList.GetAt(j, pElement2);
+                               if (r != E_SUCCESS)
+                               {
+                                       continue;
+                               }
+                               if(pElement->GetAbsoluteBounds().x > pElement2->GetAbsoluteBounds().x)
+                               {
+                                       pElement = pElement2;
+                                       selectedHeader = j;
+                               }
+                       }
+                       if(selectedHeader != i)
+                       {
+                               __candidateList.Remove(pElement);
+                               __candidateList.InsertAt(pElement, i);
+                       }
                }
-               if (pElement->GetName() == "HeaderTitleText")
+       }
+       if(startFooter != -1 && endFooter - startFooter > 0)
+       {
+               for(int i = startFooter; i <= endFooter ; i++)
                {
-                       __candidateList.Remove(pElement);
-                       __candidateList.InsertAt(pElement, 0);
+                       r = __candidateList.GetAt(i, pElement);
+                       if (r != E_SUCCESS)
+                       {
+                               continue;
+                       }
+                       selectedFooter = i;
+                       for(int j = i +1 ; j <= endFooter; j++)
+                       {
+                               r = __candidateList.GetAt(j, pElement2);
+                               if (r != E_SUCCESS)
+                               {
+                                       continue;
+                               }
+                               if(pElement->GetAbsoluteBounds().x > pElement2->GetAbsoluteBounds().x)
+                               {
+                                       pElement = pElement2;
+                                       selectedFooter = j;
+                               }
+                       }
+                       if(selectedFooter != i)
+                       {
+                               __candidateList.Remove(pElement);
+                               __candidateList.InsertAt(pElement, i);
+                       }
                }
        }
+
        return;
 }
 void
@@ -1559,7 +1640,12 @@ _AccessibilityManager::MoveFocus(_AccessibilityFocusDirection direction)
                {
                        pElement = null;
                        __pTargetElement = null;
+                       if(__pTargetContainer)
+                       {
+                               __pTargetContainer->SetCurrentFocusedElement(null);
+                       }
                        __pTargetContainer = null;
+                       
                }
                else
                {
@@ -1697,7 +1783,7 @@ _AccessibilityManager::MoveFocus(_AccessibilityFocusDirection direction)
 void
 _AccessibilityManager::RequestToDrawFocusUi()
 {
-       if (__pTargetContainer)
+       if (__targetControlHandle.IsValid() && __pTargetContainer->IsContains(*__pTargetElement))
        {
                //HidePopup();
                DrawFocusUi(*__pTargetElement);
@@ -1813,7 +1899,7 @@ _AccessibilityManager::DrawFocusUi(const _AccessibilityElement& element)
                                SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error");
                        }
                }
-               
+
                __pFocusVe->SetShowState(true);
                delete pCanvas;
        }
@@ -1866,34 +1952,35 @@ _AccessibilityManager::ProcessGesture(_AccessibilityGestureType type, const Floa
                        _Window* pWindow = _ControlManager::GetInstance()->GetTopVisibleWindow();
                        if (!(pWindow->IsLayoutChangable()))
                        {
-                               Rectangle topWindowAbsBounds = pWindow->GetAbsoluteBounds();
+                               Rectangle topWindowAbsBounds = pWindow->GetAbsoluteBounds(true);
                                pt.x = pt.x + topWindowAbsBounds.x;
                                pt.y = pt.y + topWindowAbsBounds.y;
                        }
                        pControl = _ControlManager::GetInstance()->GetTopmostTouchedControl(pt);
-                       if (pControl == null || !(pControl->GetAbsoluteBounds().Contains(pt)))
+                       if (pControl == null || !(pControl->GetAbsoluteBounds(true).Contains(pt)))
                        {
                                return false;
                        }
                        _AccessibilityContainer* pAccContainer = pControl->GetAccessibilityContainer();
-                       while(!(pAccContainer->IsActivated()))
+                       _AccessibilityElement* pElement = null;
+                       while(pElement == null)
                        {
+                               pElement = pAccContainer->Hit(pt);
+                               if(pElement)
+                               {
+                                       break;
+                               }
                                _Control* _pControl = pAccContainer->GetOwner().GetParent();
                                if (_pControl == null)
                                {
                                        return false;
                                }
                                pAccContainer = _pControl->GetAccessibilityContainer();
-                               if (pAccContainer == null)
+                               if(pAccContainer == null)
                                {
                                        return false;
                                }
                        }
-                       _AccessibilityElement* pElement = pAccContainer->Hit(pt);
-                       if (pElement == null)
-                       {
-                               return false;
-                       }
 
                        if (__pTargetElement == pElement)
                        {
@@ -2054,16 +2141,14 @@ _AccessibilityManager::ProcessGesture(_AccessibilityGestureType type, const Floa
                        {
                                if (!IsContainerValid(__pTargetContainer))
                                {
-                                       return false;
-                               }
-
-                               _Control* pControl = &(__pTargetContainer->GetOwner());
-                               if (pControl->GetEnableState() == false)
-                               {
-                                       ReadContent(L"Unavailable");
-                                       return true;
+                                       if (MoveFocus(_ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS))
+                                       {
+                                               SetGestureMode(MODE_FOCUS_MOVE);
+                                       }
+                                       break;
                                }
 
+                               bool returnValue = false;
                                LinkedListT<_IAccessibilityListener*>* pList = static_cast<LinkedListT<_IAccessibilityListener*>*>(__pTargetContainer->GetListenerListN());
                                if (pList != null)
                                {
@@ -2073,27 +2158,44 @@ _AccessibilityManager::ProcessGesture(_AccessibilityGestureType type, const Floa
                                                _IAccessibilityListener* pListener = null;
                                                if (pList->GetAt(i, pListener) == E_SUCCESS)
                                                {
-                                                       pListener->OnAccessibilityValueIncreased(*__pTargetContainer, *__pTargetElement);
+                                                       if(pListener->OnAccessibilityValueIncreased(*__pTargetContainer, *__pTargetElement) && returnValue == false)
+                                                       {
+                                                               returnValue = true;
+                                                       }
                                                }
                                        }
                                        delete pList;
                                }
+
+                               if (returnValue)
+                               {
+                                       _Control* pControl = &(__pTargetContainer->GetOwner());
+                                       if (pControl->GetEnableState() == false)
+                                       {
+                                               ReadContent(L"Unavailable");
+                                               return true;
+                                       }
+                               }
+                               else
+                               {
+                                       if (MoveFocus(_ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS))
+                                       {
+                                               SetGestureMode(MODE_FOCUS_MOVE);
+                                       }
+                               }
                        }
                        break;
                case _ACCESSIBILITY_GESTURE_TYPE_VALUE_DECREASED:
                        {
                                if (!IsContainerValid(__pTargetContainer))
                                {
-                                       return false;
-                               }
-
-                               _Control* pControl = &(__pTargetContainer->GetOwner());
-                               if (pControl->GetEnableState() == false)
-                               {
-                                       ReadContent(L"Unavailable");
-                                       return true;
+                                       if (MoveFocus(_ACCESSIBILITY_FOCUS_DIRECTION_NEXT))
+                                       {
+                                               SetGestureMode(MODE_FOCUS_MOVE);
+                                       }
+                                       break;
                                }
-
+                               bool returnValue = false;
                                LinkedListT<_IAccessibilityListener*>* pList = static_cast<LinkedListT<_IAccessibilityListener*>*>(__pTargetContainer->GetListenerListN());
                                if (pList != null)
                                {
@@ -2103,11 +2205,30 @@ _AccessibilityManager::ProcessGesture(_AccessibilityGestureType type, const Floa
                                                _IAccessibilityListener* pListener = null;
                                                if (pList->GetAt(i, pListener) == E_SUCCESS)
                                                {
-                                                       pListener->OnAccessibilityValueDecreased(*__pTargetContainer, *__pTargetElement);
+                                                       if(pListener->OnAccessibilityValueDecreased(*__pTargetContainer, *__pTargetElement) && returnValue == false)
+                                                       {
+                                                               returnValue = true;
+                                                       }
                                                }
                                        }
                                        delete pList;
                                }
+                               if (returnValue)
+                               {
+                                       _Control* pControl = &(__pTargetContainer->GetOwner());
+                                       if (pControl->GetEnableState() == false)
+                                       {
+                                               ReadContent(L"Unavailable");
+                                               return true;
+                                       }
+                               }
+                               else
+                               {
+                                       if (MoveFocus(_ACCESSIBILITY_FOCUS_DIRECTION_NEXT))
+                                       {
+                                               SetGestureMode(MODE_FOCUS_MOVE);
+                                       }
+                               }
                        }
                        break;
                case _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_STARTED:
@@ -2203,10 +2324,6 @@ _AccessibilityManager::Unregister(Tizen::Base::_HandleT <_AccessibilityContainer
 void
 _AccessibilityManager::OnChangedLocale(void)
 {
-       if (__pTtsPlayer && __pSettingLoader)
-       {
-               __pTtsPlayer->SetLocale(__pSettingLoader->GetLocale());
-       }
 }
 
 void
@@ -2224,7 +2341,6 @@ _AccessibilityManager::OnAccessibilityScreenReaderIsActivated(bool set)
                {
                        if (__pTtsPlayer)
                        {
-                               __pTtsPlayer->SetLocale(__pSettingLoader->GetLocale());
                                __pTtsPlayer->Activate();
                                RequestAutoReading(_ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM);
                        }
@@ -2233,6 +2349,10 @@ _AccessibilityManager::OnAccessibilityScreenReaderIsActivated(bool set)
                {
                        __pTtsPlayer->Deactivate();
                        EraseFocusUi();
+                       if(__pTargetContainer)
+                       {
+                               __pTargetContainer->SetCurrentFocusedElement(null);
+                       }
                        __pTargetContainer = null;
                        __pTargetElement = null;
                        __pTitleElement = null;
@@ -2345,6 +2465,22 @@ _AccessibilityManager::IsLastElementGainedFocus(void)
        }
        return false;
 }
+void
+_AccessibilityManager::ResetFocusInformation(void)
+{
+       EraseFocusUi();
+       if(__pTargetContainer)
+       {
+               __pTargetContainer->SetCurrentFocusedElement(null);
+       }
+       __pTargetContainer = null;
+       __pTargetElement = null;
+       __pTitleElement = null;
+       __mode = MODE_TAP;
+       __targetControlHandle = _ControlHandle();
+       __focusedControlHandle = _ControlHandle();
+       __readingPopupParentHandle = _ControlHandle();
+}
 bool
 _AccessibilityManager::IsVisible(_AccessibilityElement* pElement)
 {