Fixes for N_SE-56099, N_SE-56155, N_SE-56171
authormoinuddin.s <moinuddin.s@samsung.com>
Fri, 25 Oct 2013 15:36:20 +0000 (21:06 +0530)
committermoinuddin.s <moinuddin.s@samsung.com>
Mon, 28 Oct 2013 06:54:48 +0000 (12:24 +0530)
Signed-off-by: moinuddin.s <moinuddin.s@samsung.com>
Change-Id: I3fef30acbf5d9d416d5e827d95c7b86913151b0c
Signed-off-by: moinuddin.s <moinuddin.s@samsung.com>
src/ui/controls/FUiCtrl_Toolbar.cpp
src/ui/inc/FUiCtrl_Toolbar.h

index 32ad0c8..77fad5c 100644 (file)
@@ -1266,6 +1266,11 @@ _Toolbar::InsertItemAt(int itemIndex, _Button* pButton)
 
        AddAccessibilityElement(pButton);
 
+       if (__highlightedItemIndex != -1 && itemIndex <= __highlightedItemIndex)
+       {
+               __highlightedItemIndex++;
+       }
+
        return E_SUCCESS;
 }
 
@@ -1393,41 +1398,13 @@ _Toolbar::RemoveAllButtons(void)
 {
        for (int i = 0; i < BUTTON_MAX; i++)
        {
-               _Button* pButtonItem = __pButtonItems[i];
-
-               if (pButtonItem != null)
+               if (i == LEFT_BUTTON)
                {
-                        if (i == LEFT_BUTTON)
-                       {
-                               if (__pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT] != null)
-                               {
-                                       StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT);
-                               }
-                       }
-                       else if (i == RIGHT_BUTTON)
-                       {
-                               if (__pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT] != null)
-                               {
-                                       StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT);
-                               }
-                       }
-
-                       if (pButtonItem->GetChildCount() != 0)
-                       {
-                               _Label* pTempBadgeIcon = dynamic_cast<_Label*>(pButtonItem->GetChild(0));
-                               SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon.");
-
-                               pButtonItem->DetachChild(*pTempBadgeIcon);
-
-                               delete pTempBadgeIcon;
-                               pTempBadgeIcon = null;
-                       }
-
-                       DetachChild(*pButtonItem);
-                       delete pButtonItem;
-                       pButtonItem = null;
-
-                       __pButtonItems[i] = null;
+                       RemoveButtonAt(LEFT_BUTTON);
+               }
+               else if (i == RIGHT_BUTTON)
+               {
+                        RemoveButtonAt(RIGHT_BUTTON);
                }
        }
 
@@ -1437,39 +1414,15 @@ _Toolbar::RemoveAllButtons(void)
 result
 _Toolbar::RemoveAllItems(void)
 {
-       __itemCount = 0;
-
        int itemCount = __pItems.size();
 
-       _Button* pItem = null;
-
        // frees item nodes from the memory
        if (itemCount > 0)
        {
                for (int i = itemCount - 1; i >= 0; i--)
                {
-                       pItem = __pItems.at(i);
-
-                       if (pItem != null)
-                       {
-                               if (pItem->GetChildCount() != 0)
-                               {
-                                       _Label* pTempBadgeIcon = dynamic_cast<_Label*>(pItem->GetChild(0));
-                                       SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon.");
-
-                                       pItem->DetachChild(*pTempBadgeIcon);
-
-                                       delete pTempBadgeIcon;
-                                       pTempBadgeIcon = null;
-                               }
-
-                               DetachChild(*pItem);
-                               delete pItem;
-
-                               pItem = null;
-                       }
+                       RemoveItemAt(i);
                }
-
        }
 
        // clears vector
@@ -1516,6 +1469,65 @@ _Toolbar::RemoveButtonAt(ToolbarButton position)
                DetachChild(*__pButtonItems[position]);
                delete __pButtonItems[position];
                __pButtonItems[position] = null;
+
+               if (!__header || __style == TOOLBAR_TEXT)
+               {
+                       if (position == LEFT_BUTTON)
+                       {
+                               if (__highlightedItemIndex == 0)
+                               {
+                                       __highlightedItemIndex = -1;
+                                       __isEnterKeyPressed = false;
+                               }
+                               else if (__highlightedItemIndex > 0)
+                               {
+                                       __highlightedItemIndex--;
+                               }
+                       }
+                       else // right button
+                       {
+                               if (__pButtonItems[LEFT_BUTTON])
+                               {
+                                       if (__highlightedItemIndex == __itemCount + 1)
+                                       {
+                                               __highlightedItemIndex = -1;
+                                               __isEnterKeyPressed = false;
+                                       }
+                               }
+                               else if (__highlightedItemIndex == __itemCount)
+                               {
+                                       __highlightedItemIndex = -1;
+                                       __isEnterKeyPressed = false;
+                               }
+                       }
+               }
+               else
+               {
+                       if (position == LEFT_BUTTON)
+                       {
+                               if (__highlightedItemIndex == __itemCount)
+                               {
+                                       __highlightedItemIndex = -1;
+                                       __isEnterKeyPressed = false;
+                               }
+                       }
+                       else
+                       {
+                               if (__pButtonItems[LEFT_BUTTON])
+                               {
+                                       if (__highlightedItemIndex == __itemCount + 1)
+                                       {
+                                               __highlightedItemIndex = -1;
+                                               __isEnterKeyPressed = false;
+                                       }
+                               }
+                               else if (__highlightedItemIndex == __itemCount)
+                               {
+                                       __highlightedItemIndex = -1;
+                                       __isEnterKeyPressed = false;
+                               }
+                       }
+               }
        }
 
        if (__itemCount == 0 && __pButtonItems[LEFT_BUTTON] == null && __pButtonItems[RIGHT_BUTTON] == null)
@@ -1554,6 +1566,15 @@ _Toolbar::RemoveItemAt(int itemIndex)
        delete pItem;
        pItem = null;
 
+       if (itemIndex == __highlightedItemIndex)
+       {
+               __highlightedItemIndex = -1;
+               __isEnterKeyPressed = false;
+       }
+       else if (itemIndex < __highlightedItemIndex)
+       {
+               __highlightedItemIndex--;
+       }
        __itemCount--;
 
        if (__itemCount == 0 && __pButtonItems[LEFT_BUTTON] == null && __pButtonItems[RIGHT_BUTTON] == null)
@@ -1754,6 +1775,45 @@ _Toolbar::SetButtonColor(_ButtonStatus status, const Color& color)
        }
 }
 
+void
+_Toolbar::SetHighlightedState(ToolbarButton position)
+{
+       if (__highlightedItemIndex == __itemCount)
+       {
+               if (__pButtonItems[LEFT_BUTTON])
+               {
+                       if (position == LEFT_BUTTON)
+                       {
+                               __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED, false);
+                       }
+                       else
+                       {
+                               __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL);
+                       }
+               }
+               else // Right button case
+               {
+                       __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED, false);
+               }
+       }
+       else if (__highlightedItemIndex == __itemCount + 1 )
+       {
+               if (position == RIGHT_BUTTON)
+               {
+                       __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED, false);
+               }
+               else
+               {
+                       __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL);
+               }
+       }
+       else
+       {
+               __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL);
+       }
+
+}
+
 result
 _Toolbar::SetButtonEnabled(ToolbarButton position, bool enabled)
 {
@@ -1762,7 +1822,27 @@ _Toolbar::SetButtonEnabled(ToolbarButton position, bool enabled)
 
        if (enabled)
        {
-               __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL);
+               if (_ControlManager::GetInstance() != null && _ControlManager::GetInstance()->GetFocusControl() != this)
+               {
+                       __highlightedItemIndex = -1;
+                       __isEnterKeyPressed = false;
+               }
+
+               if (__itemCount != 0)
+               {
+                       if (__highlightedItemIndex >= __itemCount)
+                       {
+                               SetHighlightedState(position);
+                       }
+                       else
+                       {
+                               __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL);
+                       }
+               }
+               else
+               {
+                       SetHighlightedState(position);
+               }
 
                SetFocusNavigateEnabled(true);
 
@@ -3930,7 +4010,7 @@ _Toolbar::OnHeaderFocusGained(const _Control& source)
        }
        else // itemCount != 0
        {
-               if (__highlightedItemIndex != -1 && __pItems.at(__highlightedItemIndex))
+               if (__highlightedItemIndex != -1 && (__highlightedItemIndex < __itemCount) && __pItems.at(__highlightedItemIndex))
                {
                        if (__pItems.at(__highlightedItemIndex)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
                        {
index c702b14..9f97889 100644 (file)
@@ -277,6 +277,8 @@ public:
 
        result SetButtonColor(_ButtonStatus status, const Tizen::Graphics::Color& color);
 
+       void SetHighlightedState(ToolbarButton position);
+
        result SetButtonEnabled(ToolbarButton position, bool enabled);
 
        result SetButtonTextColor(_ButtonStatus status, const Tizen::Graphics::Color& color);