Searchbar Focus Ui
authorAyush <ayush.sriv@samsung.com>
Tue, 11 Jun 2013 11:04:35 +0000 (16:34 +0530)
committerAyush <ayush.sriv@samsung.com>
Tue, 11 Jun 2013 13:35:02 +0000 (19:05 +0530)
Change-Id: Ife4cb8270c9bd035ed1d41684ef504e7be674832
Signed-off-by: Ayush <ayush.sriv@samsung.com>
src/ui/controls/FUiCtrl_SearchBar.cpp
src/ui/controls/FUiCtrl_SearchBarImpl.cpp
src/ui/inc/FUiCtrl_SearchBar.h

index 47d8df2..70e2d14 100644 (file)
@@ -75,9 +75,9 @@ _SearchBar::_SearchBar(void)
        , __isUserGuideTextColor(false)
        , __isKeypadOpening(false)
        , __isupdateContentBounds(false)
-       , __isKeyPressed(false)
        , __isFocusCallbackToBeFired(true)
        , __isButtonTextChangedByApp(false)
+       , __contentVisibilitySetByApp(true)
        , __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
        , __pBackgroundBitmap(null)
        , __backgroundColor(Color())
@@ -524,7 +524,7 @@ _SearchBar::UpdateContentArea(bool invalidate)
 }
 
 result
-_SearchBar::SetContentAreaVisible(bool visible)
+_SearchBar::SetContentAreaVisible(bool visible, bool isCalledByApp)
 {
        SysTryReturn(NID_UI_CTRL, __pContainer, E_SYSTEM, E_SYSTEM,
                     "[E_SYSTEM] A system error has occurred. The instance of parent to content is null.");
@@ -535,6 +535,11 @@ _SearchBar::SetContentAreaVisible(bool visible)
                __pContainer->SetVisibleState(visible);
        }
 
+       if (isCalledByApp)
+       {
+               __contentVisibilitySetByApp = visible;
+       }
+
        return __pSearchBarPresenter->SetContentAreaVisible(visible);
 }
 
@@ -1585,10 +1590,10 @@ _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& tou
                return _UI_TOUCH_EVENT_DELIVERY_YES;
        }
 
-       if (GetMode() == SEARCH_BAR_MODE_INPUT)
-       {
-               return _UI_TOUCH_EVENT_DELIVERY_YES;
-       }
+       __pEdit->SetSearchFieldFocus(false);
+       SetContentAreaVisible(__contentVisibilitySetByApp);     //When a touch happens on SearchField
+       SetFocusCallbackParameter(true);
+       SetMode(SEARCH_BAR_MODE_INPUT);
 
        return _UI_TOUCH_EVENT_DELIVERY_YES;
 }
@@ -1599,8 +1604,11 @@ _SearchBar::OnActionPerformed(const _Control& source, int actionId)
        if (__actionId == actionId)
        {
                __isCancelActionInProgress = true;
+               SetFocusCallbackParameter(true);
                SetMode(SEARCH_BAR_MODE_NORMAL);
 
+               SetFocused();
+
                if (__pActionEvent)
                {
                        IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
@@ -1718,6 +1726,11 @@ _SearchBar::OnTextBlockSelected(_Control& source, int start, int end)
 void
 _SearchBar::OnTextValueChanged(const _Control& source)
 {
+       if (GetTextLength())
+       {
+               SetContentAreaVisible(__contentVisibilitySetByApp);
+       }
+
        if (!__isCancelActionInProgress)
        {
                SetContentDimming();
@@ -1774,28 +1787,59 @@ _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
 bool
 _SearchBar::OnFocusGained(const _Control& source)
 {
-       if (__isKeyPressed)
-       {
-               __isKeyPressed = false;
-               _Control::OnDrawFocus();
+       return _Control::OnFocusGained(source);
+}
 
-               return true;
-       }
+bool
+_SearchBar::OnFocusLost(const _Control &source)
+{
+       return _Control::OnFocusLost(source);
+}
 
-       if (GetVisibleState() == true)
-       {
-               __pEdit->SetFocused();
-       }
+void
+_SearchBar::OnDrawFocus(void)
+{
+       __pEdit->SetSearchFieldFocus(true);
+       _Control::OnDrawFocus();
+
+       return;
+}
 
-       return true;
+void
+_SearchBar::OnFocusModeStateChanged(void)
+{
+       return;
 }
 
 bool
-_SearchBar::OnFocusLost(const _Control &source)
+_SearchBar::OnPreviewKeyPressed(const _Control &source, const _KeyInfo &keyInfo)
 {
-       __pEdit->SetSearchFieldFocus(false);
-       _Control::OnFocusLost(source);
-       return true;
+       if (!__pEdit->IsUsbKeyboardConnected())
+       {
+                       return false;
+       }
+
+       if (!__pEdit->IsSearchFieldFocused())
+       {
+                       return false;
+       }
+
+       _KeyCode keyCode = keyInfo.GetKeyCode();
+
+       switch (keyCode)
+       {
+               case _KEY_TAB:
+                       SetFocusCallbackParameter(true);
+                       if ((__pContentControl && __pContentControl->IsVisible() == false) || !__pContentControl)
+                       {
+                               SetContentAreaVisible(false);
+                       }
+
+                       break;
+               default:
+                       break;
+       }
+       return false;
 }
 
 bool
@@ -1816,10 +1860,18 @@ _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
        switch (keyCode)
        {
                case _KEY_RIGHT:
+                       if (&source == this)
+                       {
+                               SetFocusCallbackParameter(true);
+                               SetMode(SEARCH_BAR_MODE_INPUT);
+                               __pEdit->SetFocused();
+                       }
+
                        SetFocusCallbackParameter(false);
+
                        if (&source == __pEdit)
                        {
-                               if ((!__isButtonEnabled || !__isUsableCancelButton) && __pContentControl && __pContentControl->GetVisibleState() && __pContentControl->GetEnableState())
+                               if ((!__isButtonEnabled || !__isUsableCancelButton) && __pContentControl && __pContentControl->IsVisible() && __pContentControl->GetEnableState())
                                {
                                        __pContentControl->SetFocused();
                                        __pContentControl->OnDrawFocus();
@@ -1834,7 +1886,7 @@ _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                                return true;
                        }
 
-                       if (&source == __pCancelButton && __pContentControl && __pContentControl->GetVisibleState() && __pContentControl->GetEnableState())
+                       if (&source == __pCancelButton && __pContentControl && __pContentControl->IsVisible() && __pContentControl->GetEnableState())
                        {
                                __pContentControl->SetFocused();
                                __pContentControl->OnDrawFocus();
@@ -1869,8 +1921,8 @@ _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                case _KEY_ENTER:
                        if (&source == __pCancelButton)
                        {
+                               SetFocusCallbackParameter(true);
                                SetMode(SEARCH_BAR_MODE_NORMAL);
-                               __isKeyPressed = true;
                                SetFocused();
                                _Control::OnDrawFocus();
 
@@ -2564,13 +2616,6 @@ _SearchBar::SetContentDimming(void)
        return;
 }
 
-void
-_SearchBar::OnDrawFocus(void)
-{
-       __pEdit->SetSearchFieldFocus(true);
-       return;
-}
-
 bool
 _SearchBar::IsContentAttachable(const _Control* pContent)
 {
index 311628e..415925f 100644 (file)
@@ -413,7 +413,7 @@ _SearchBarImpl::SetContentAreaVisible(bool visible)
 {
        ClearLastResult();
 
-       return __pSearchBar->SetContentAreaVisible(visible);
+       return __pSearchBar->SetContentAreaVisible(visible, true);
 }
 
 bool
@@ -1488,14 +1488,13 @@ _SearchBarImpl::OnFocusEventListenerRemoved(IFocusEventListener& listener)
 void
 _SearchBarImpl::OnFocusGained(const Tizen::Ui::Control& source)
 {
-       SetMode(SEARCH_BAR_MODE_INPUT);
-
        if (!__pSearchBar->IsFocusCallbackToBeFired())
        {
                return;
        }
 
        IEnumeratorT<IEventListener*>* pEnumerator = __pPublicFocusEventListeners->GetEnumeratorN();
+
        if (pEnumerator)
        {
                while (pEnumerator->MoveNext() == E_SUCCESS)
index 774b93f..4393620 100644 (file)
@@ -138,7 +138,7 @@ public:
        Tizen::Ui::_Control* GetContent(void) const;
        result SetContent(const Tizen::Ui::_Control* pContent);
        result UpdateContentArea(bool invalidate = true);
-       result SetContentAreaVisible(bool visible);
+       result SetContentAreaVisible(bool visible, bool isCalledByApp = false);
        bool IsContentAreaVisible(void) const;
        result SetContentAreaSize(const Tizen::Graphics::Dimension& size);
        Tizen::Graphics::Dimension GetContentAreaSize(void) const;
@@ -256,7 +256,10 @@ public:
        virtual void OnFontInfoRequested(unsigned long& style, int& size);
        virtual bool OnFocusGained(const _Control& source);
        virtual bool OnFocusLost(const _Control& source);
+       virtual void OnDrawFocus(void);
+       virtual void OnFocusModeStateChanged(void);
 
+       virtual bool OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
        virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
 
        virtual void OnSettingChanged(Tizen::Base::String& key);
@@ -277,7 +280,6 @@ private:
        result CreateContentsArea(void);
        result CreateClippedGroupControl(void);
        void CreateAccessibilityElement(void);
-       virtual void OnDrawFocus(void);
 
        Tizen::Ui::_Control* GetParentForm(void) const;
 
@@ -299,9 +301,9 @@ private:
        bool __isUserGuideTextColor;
        bool __isKeypadOpening;
        bool __isupdateContentBounds;
-       bool __isKeyPressed;
        bool __isFocusCallbackToBeFired;
        bool __isButtonTextChangedByApp;
+       bool __contentVisibilitySetByApp;
 
        CoreKeypadAction __keypadAction;