Focus Ui SearchBar
authorAyush <ayush.sriv@samsung.com>
Wed, 22 May 2013 05:16:16 +0000 (10:46 +0530)
committerAyush <ayush.sriv@samsung.com>
Thu, 30 May 2013 13:59:33 +0000 (19:29 +0530)
Change-Id: Icd27255b4419375b21bf2ac6b4ee398fda900522
Signed-off-by: Ayush <ayush.sriv@samsung.com>
17 files changed:
inc/FUiUiConfigurationTypes.h
res/common/usr/share/osp/bitmaps/480x800/00_search_edit_field_focus.#.png [new file with mode: 0644]
res/common/usr/share/osp/bitmaps/720x1280/00_search_edit_field_focus.#.png [new file with mode: 0644]
src/ui/FUiUiConfiguration.cpp
src/ui/FUi_ControlImpl.cpp
src/ui/controls/FUiCtrl_Edit.cpp
src/ui/controls/FUiCtrl_EditPresenter.cpp
src/ui/controls/FUiCtrl_SearchBar.cpp
src/ui/controls/FUiCtrl_SearchBarImpl.cpp
src/ui/controls/FUiCtrl_SearchBarPresenter.cpp
src/ui/inc/FUiCtrl_Edit.h
src/ui/inc/FUiCtrl_SearchBar.h
src/ui/inc/FUiCtrl_SearchBarImpl.h
src/ui/inc/FUi_ControlImpl.h
src/ui/inc/FUi_ResourceSearchBarConfig.h
src/ui/resource/FUi_ResourceConfigParser.cpp
src/ui/resource/FUi_ResourceSearchBarConfig.cpp

index 4d22668..2bceb50 100644 (file)
@@ -2533,6 +2533,20 @@ struct _OSP_EXPORT_ ColorKey
                _OSP_EXPORT_ static const int EDIT_BG_NORMAL;
 
                /**
+               * The property key to get the pressed background color of the edit of search bar.
+               *
+               * @since                2.1
+               */
+               _OSP_EXPORT_ static const int EDIT_BG_PRESSED;
+
+               /**
+               * The property key to get the highlighted background color of the edit of search bar.
+               *
+               * @since                2.1
+               */
+               _OSP_EXPORT_ static const int EDIT_BG_HIGHLIGHTED;
+
+               /**
                * The property key to get the disabled background color of the edit of search bar.
                *
                * @since                2.1
@@ -2540,6 +2554,13 @@ struct _OSP_EXPORT_ ColorKey
                _OSP_EXPORT_ static const int EDIT_BG_DISABLED;
 
                /**
+               * The property key to get the focus color of the edit of search bar.
+               *
+               * @since                2.1
+               */
+               _OSP_EXPORT_ static const int EDIT_BG_FOCUS;
+
+               /**
                * The property key to get the normal text color of the edit of search bar.
                *
                * @since                2.1
diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_search_edit_field_focus.#.png b/res/common/usr/share/osp/bitmaps/480x800/00_search_edit_field_focus.#.png
new file mode 100644 (file)
index 0000000..924b51b
Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_search_edit_field_focus.#.png differ
diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_search_edit_field_focus.#.png b/res/common/usr/share/osp/bitmaps/720x1280/00_search_edit_field_focus.#.png
new file mode 100644 (file)
index 0000000..924b51b
Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_search_edit_field_focus.#.png differ
index a60cca6..fae5c76 100644 (file)
@@ -374,7 +374,10 @@ const int ColorKey::SearchBar::BUTTON_TEXT_PRESSED = _SEARCHBAR::BUTTON_TEXT_PRE
 const int ColorKey::SearchBar::BUTTON_TEXT_DISABLED = _SEARCHBAR::BUTTON_TEXT_DISABLED_COLOR;
 const int ColorKey::SearchBar::BUTTON_TEXT_HIGHLIGHTED = _SEARCHBAR::BUTTON_TEXT_HIGHLIGHTED_COLOR;
 const int ColorKey::SearchBar::EDIT_BG_NORMAL = _SEARCHBAR::EDIT_BG_NORMAL_COLOR;
+const int ColorKey::SearchBar::EDIT_BG_PRESSED = _SEARCHBAR::EDIT_BG_PRESSED_COLOR;
+const int ColorKey::SearchBar::EDIT_BG_HIGHLIGHTED = _SEARCHBAR::EDIT_BG_HIGHLIGHTED_COLOR;
 const int ColorKey::SearchBar::EDIT_BG_DISABLED = _SEARCHBAR::EDIT_BG_DISABLED_COLOR;
+const int ColorKey::SearchBar::EDIT_BG_FOCUS = _SEARCHBAR::EDIT_BG_FOCUS_COLOR;
 const int ColorKey::SearchBar::EDIT_TEXT_NORMAL = _SEARCHBAR::EDIT_TEXT_NORMAL_COLOR;
 const int ColorKey::SearchBar::EDIT_TEXT_DISABLED = _SEARCHBAR::EDIT_TEXT_DISABLED_COLOR;
 const int ColorKey::SearchBar::EDIT_TEXT_HIGHLIGHTED = _SEARCHBAR::EDIT_TEXT_HIGHLIGHTED_COLOR;
index fb1cf93..bf25396 100644 (file)
@@ -2170,6 +2170,12 @@ _ControlImpl::GetTouchEventListener(void) const
        return __pPublicTouchEventListeners;
 }
 
+Tizen::Base::Collection::LinkedListT <Tizen::Base::Runtime::IEventListener*>*
+_ControlImpl::GetKeyEventListener(void) const
+{
+       return __pPublicKeyEventListeners;
+}
+
 result
 _ControlImpl::AddDragDropEventListener(IDragDropEventListener& listener)
 {
index 5171511..1ea4935 100644 (file)
@@ -228,6 +228,7 @@ _Edit::_Edit(void)
        , __pressedGuideTextColor(Color())
        , __isSettingGuideTextColor(false)
        , __pDefaultBackgroundEffectBitmap(null)
+       , __pDefaultFocusBitmap(null)
        , __pGestureFlick(null)
        , __pGestureLongPress(null)
        , __pGestureTap(null)
@@ -249,6 +250,7 @@ _Edit::_Edit(void)
        , __pTextFilter(null)
        , __previousBounds()
        , __isTouchMoving(false)
+       , __isSearchFieldFocused(false)
 {
        for (int status = 0; status < EDIT_COLOR_MAX; status++)
        {
@@ -290,6 +292,12 @@ _Edit::~_Edit(void)
                __pDefaultBackgroundEffectBitmap = null;
        }
 
+       if (__pDefaultFocusBitmap)
+       {
+               delete __pDefaultFocusBitmap;
+               __pDefaultFocusBitmap = null;
+       }
+
        if (__pTextBlockEvent)
        {
                delete __pTextBlockEvent;
@@ -2365,6 +2373,8 @@ _Edit::ReplaceDefaultBackgroundBitmapForSearchBar(void)
        SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap");
        r = GET_BITMAP_CONFIG_N(SEARCHBAR::EDIT_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap);
        SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap");
+       r = GET_BITMAP_CONFIG_N(SEARCHBAR::EDIT_BG_FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultFocusBitmap);
+       SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap");
 
        _pEditPresenter->SetSearchBarFlag(true);
 
@@ -2386,6 +2396,19 @@ CATCH:
        return r;
 }
 
+void
+_Edit::SetSearchFieldFocus(bool state)
+{
+       __isSearchFieldFocused = state;
+       return;
+}
+
+bool
+_Edit::IsSearchFieldFocused(void) const
+{
+       return __isSearchFieldFocused;
+}
+
 Bitmap*
 _Edit::GetDefaultBackgroundBitmap(EditStatus status) const
 {
@@ -2423,7 +2446,12 @@ Bitmap*
 _Edit::GetDefaultBackgroundEffectBitmap(void) const
 {
        return __pDefaultBackgroundEffectBitmap;
+}
 
+Bitmap*
+_Edit::GetDefaultFocusBitmap(void) const
+{
+       return __pDefaultFocusBitmap;
 }
 
 bool
index 85ab198..a7b41c9 100644 (file)
@@ -1573,6 +1573,35 @@ _EditPresenter::DrawChangeableBackground(Canvas& canvas, bool focused, int bitma
                }
        }
 
+       if (GetSearchBarFlag() && __pEdit->IsFocused() && __pEdit->IsSearchFieldFocused())
+       {
+               Bitmap* pFocusBitmap = null;
+               Bitmap* pReplacementColorFocusBitmap = null;
+
+               Color focusColor;
+               GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_FOCUS, focusColor);
+
+               pFocusBitmap = __pEdit->GetDefaultFocusBitmap();
+
+               pReplacementColorFocusBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pFocusBitmap, Color::GetColor(COLOR_ID_MAGENTA), focusColor);
+
+               if (pReplacementColorFocusBitmap)
+               {
+                       if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReplacementColorFocusBitmap))
+                       {
+                               canvas.DrawNinePatchedBitmap(editRect, *pReplacementColorFocusBitmap);
+                       }
+                       else
+                       {
+                               canvas.DrawBitmap(editRect, *pReplacementColorFocusBitmap);
+                       }
+               }
+
+               delete pReplacementColorFocusBitmap;
+               pReplacementColorFocusBitmap = null;
+       }
+
+
        if (borderRoundEnable)
        {
                if (pEditBgBitmap)
index ae45a68..624d43f 100644 (file)
@@ -40,6 +40,9 @@
 #include "FUi_AccessibilityElement.h"
 #include "FUi_AccessibilityManager.h"
 #include "FUi_CoordinateSystemUtils.h"
+#include "FUiCtrl_SearchBarImpl.h"
+#include "FUiCtrl_EditFieldImpl.h"
+#include "FUiCtrl_ButtonImpl.h"
 
 using namespace Tizen::Graphics;
 using namespace Tizen::Ui;
@@ -69,6 +72,8 @@ _SearchBar::_SearchBar(void)
        , __isUserGuideTextColor(false)
        , __isKeypadOpening(false)
        , __isupdateContentBounds(false)
+       , __isKeyPressed(false)
+       , __isFocusCallbackToBeFired(true)
        , __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
        , __pBackgroundBitmap(null)
        , __backgroundColor(Color())
@@ -103,28 +108,9 @@ _SearchBar::_SearchBar(void)
 
 _SearchBar::~_SearchBar(void)
 {
-
        delete __pSearchBarPresenter;
        __pSearchBarPresenter = null;
 
-       if (__pEdit)
-       {
-               __pEdit->HideKeypad();
-
-               __pClippedGroupControl->DetachChild(*__pEdit);
-
-               delete __pEdit;
-               __pEdit = null;
-       }
-
-       if (__pCancelButton)
-       {
-               __pClippedGroupControl->DetachChild(*__pCancelButton);
-
-               delete __pCancelButton;
-               __pCancelButton = null;
-       }
-
        if (__pClippedGroupControl)
        {
                DetachChild(*__pClippedGroupControl);
@@ -328,13 +314,11 @@ _SearchBar::CreateSearchField(void)
        editBounds.width = (editBounds.width > searchBarMinWidthModeNormal) ? editBounds.width : searchBarMinWidthModeNormal;
        editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
 
-       __pEdit = _Edit::CreateEditN();
-       r = GetLastResult();
-       SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
+       _SearchBarImpl* pSearchBarImpl = static_cast<_SearchBarImpl*>(GetUserData());
+       __pEdit = &(pSearchBarImpl->GetEditFieldImpl()->GetCore());
 
-       r = __pEdit->Initialize(EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_CLEAR | EDIT_STYLE_NOSCROLL, INPUT_STYLE_OVERLAY,
-                                                       SEARCHBAR_TEXT_LENGTH_MAX);
-       SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturnResult(NID_UI_CTRL, __pEdit != null, E_SYSTEM,
+                          "[E_SYSTEM] A system error has occured. Failed to get _Edit instance");
 
        __pEdit->SetKeypadCommandButtonVisible(false);
        __pEdit->SetBounds(editBounds);
@@ -386,7 +370,12 @@ _SearchBar::CreateCancelButton(void)
 
        _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
 
-       __pCancelButton = _Button::CreateButtonN();
+       _SearchBarImpl* pSearchBarImpl = static_cast<_SearchBarImpl*>(GetUserData());
+       __pCancelButton = &(pSearchBarImpl->GetButtonImpl()->GetCore());
+
+       SysTryReturnResult(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM,
+                          "[E_SYSTEM] A system error has occured. Failed to get _Edit instance");
+
        r = GetLastResult();
        SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
 
@@ -1589,8 +1578,6 @@ _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& tou
                return _UI_TOUCH_EVENT_DELIVERY_YES;
        }
 
-       SetMode(SEARCH_BAR_MODE_INPUT);
-
        return _UI_TOUCH_EVENT_DELIVERY_YES;
 }
 
@@ -1773,41 +1760,53 @@ _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
 bool
 _SearchBar::OnFocusGained(const _Control& source)
 {
+       if (__isKeyPressed)
+       {
+               __isKeyPressed = false;
+               _Control::OnDrawFocus();
+
+               return true;
+       }
+
        if (GetVisibleState() == true)
        {
-               SetMode(SEARCH_BAR_MODE_INPUT);
                __pEdit->SetFocused();
        }
 
-       return false;
+       return true;
 }
 
 bool
-_SearchBar::OnFocusLost(const _Controlsource)
+_SearchBar::OnFocusLost(const _Control &source)
 {
-       return false;
+       __pEdit->SetSearchFieldFocus(false);
+       _Control::OnFocusLost(source);
+       return true;
 }
 
 bool
 _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
 {
-       if (!__pEdit->IsUsbKeyboardConnected())
-       {
-               return false;
-       }
-
        _KeyCode keyCode = keyInfo.GetKeyCode();
 
        if (keyCode == _KEY_RIGHT)
        {
-               if (__isButtonEnabled)
+               if (GetMode() == SEARCH_BAR_MODE_NORMAL)
                {
-                       __pEdit->SetFocused(false);
-                       __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
-                       __pCancelButton->SetFocused();
-                       __pCancelButton->Invalidate(true);
+                       __pEdit->SetFocused();
+                       return true;
                }
 
+               if (!__isButtonEnabled || __pCancelButton->IsFocused() || !__isUsableCancelButton)
+               {
+                       return true;
+               }
+
+               __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
+               SetFocusCallBackParameter(false);
+               __pCancelButton->SetFocused();
+               __pCancelButton->Invalidate(true);
+
                return true;
        }
 
@@ -1816,28 +1815,34 @@ _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
                {
                        __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
-                       __pCancelButton->SetFocused(false);
                        __pCancelButton->Invalidate();
-
+                       __pEdit->SetFocused();
                }
 
                if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED)      //Searchbar Button is disabled, left arrow key is pressed
                {
                        __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
                        SetButtonEnabled(false);
+                       __pEdit->SetFocused();
                }
 
-               __pEdit->SetFocused();
-
                return true;
        }
 
-       return false;
-}
+       if (keyCode == _KEY_ENTER || keyCode == _KEY_TAB)
+       {
+               if (GetMode() == SEARCH_BAR_MODE_NORMAL)
+               {
+                       return false;
+               }
+
+               SetMode(SEARCH_BAR_MODE_NORMAL);
+               __isKeyPressed = true;
+               SetFocused();
+
+               return true;
+       }
 
-bool
-_SearchBar::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
-{
        return false;
 }
 
@@ -2477,7 +2482,7 @@ _SearchBar::CreateAccessibilityElement(void)
                __pAccessibilitySearchBarElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
                __pAccessibilitySearchBarElement->SetName("SearchBar");
                pContainer->AddElement(*__pAccessibilitySearchBarElement);
-        }
+       }
 
        return;
 }
@@ -2500,6 +2505,13 @@ _SearchBar::SetContentDimming(void)
        return;
 }
 
+void
+_SearchBar::OnDrawFocus(void)
+{
+       __pEdit->SetSearchFieldFocus(true);
+       return;
+}
+
 bool
 _SearchBar::IsContentAttachable(const _Control* pContent)
 {
@@ -2705,4 +2717,16 @@ _SearchBar::SendOpaqueCommand(const String& command)
        return;
 }
 
+void
+_SearchBar::SetFocusCallBackParameter(bool state)
+{
+       __isFocusCallbackToBeFired = state;
+       return;
+}
+
+bool
+_SearchBar::IsFocusCallBackToBeFired(void) const
+{
+       return __isFocusCallbackToBeFired;
+}
 }}} // Tizen::Ui::Controls
index 4d887b4..e501ddf 100644 (file)
@@ -33,6 +33,8 @@
 #include "FUiCtrl_PublicTextEvent.h"
 #include "FUiCtrl_SearchBarImpl.h"
 #include "FUi_CoordinateSystemUtils.h"
+#include "FUiCtrl_EditFieldImpl.h"
+#include "FUiCtrl_ButtonImpl.h"
 
 using namespace Tizen::App;
 using namespace Tizen::Base;
@@ -47,6 +49,8 @@ namespace Tizen { namespace Ui { namespace Controls
 _SearchBarImpl::_SearchBarImpl(SearchBar* pPublic, _SearchBar* pCore)
        : _ControlImpl(pPublic, pCore)
        , __pSearchBar(pCore)
+       , __pEditField(null)
+       , __pButton(null)
        , __pContentControl(null)
        , __pPublicActionEvent(null)
        , __pPublicKeypadEvent(null)
@@ -54,6 +58,7 @@ _SearchBarImpl::_SearchBarImpl(SearchBar* pPublic, _SearchBar* pCore)
        , __pPublicTextEvent(null)
        , __pPublicSearchBarEvent(null)
        , __pPublicLanguageEvent(null)
+       , __pPublicFocusEventListeners(null)
 {
        ClearLastResult();
 }
@@ -94,6 +99,24 @@ _SearchBarImpl::~_SearchBarImpl(void)
                delete __pPublicSearchBarEvent;
                __pPublicSearchBarEvent = null;
        }
+
+       if (__pEditField)
+       {
+               delete __pEditField;
+               __pEditField = null;
+       }
+
+       if (__pButton)
+       {
+               delete __pButton;
+               __pButton = null;
+       }
+
+       if (__pPublicFocusEventListeners)
+       {
+               delete __pPublicFocusEventListeners;
+               __pPublicFocusEventListeners = null;
+       }
 }
 
 _SearchBarImpl*
@@ -251,6 +274,38 @@ _SearchBarImpl::Initialize(bool enableSearchBarButton, KeypadAction keypadAction
                break;
        }
 
+       __pEditField = new (std::nothrow) EditField();
+       SysTryReturnResult(NID_UI_CTRL, __pEditField, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+       r = __pEditField->Construct(GetBoundsF(), EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, EDIT_FIELD_TITLE_STYLE_NONE, true);
+       SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pEditField->AddFocusEventListener(*this);
+       SysTryReturnResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       __pEditField->AddKeyEventListener(*this);
+       SysTryReturnResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       __pEditFieldImpl = _EditFieldImpl::GetInstance(*__pEditField);
+       SysTryReturnResult(NID_UI_CTRL, __pEditFieldImpl != null, E_SYSTEM,
+                          "[E_SYSTEM] A system error has occured. Failed to EditFieldImpl instance");
+
+       String cancelButtonText;
+       GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelButtonText);
+
+       __pButton = new (std::nothrow) Button();
+       SysTryReturnResult(NID_UI_CTRL, __pButton, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+       r = __pButton->Construct(GetBoundsF(), cancelButtonText);
+       SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pButton->AddFocusEventListener(*this);
+       SysTryReturnResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       __pButtonImpl = _ButtonImpl::GetInstance(*__pButton);
+       SysTryReturnResult(NID_UI_CTRL, __pButtonImpl != null, E_SYSTEM,
+                          "[E_SYSTEM] A system error has occured. Failed to ButtonImpl instance");
+
        r = __pSearchBar->Initialize(enableSearchBarButton, coreKeypadAction);
        SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
 
@@ -296,6 +351,10 @@ _SearchBarImpl::Initialize(bool enableSearchBarButton, KeypadAction keypadAction
        r = __pSearchBar->AddLanguageEventListener(*this);
        SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
+       __pPublicFocusEventListeners = CreatePublicEventListenerListN();
+       r = GetLastResult();
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
        return r;
 }
 
@@ -1400,6 +1459,175 @@ _SearchBarImpl::OnLanguageChanged(LanguageCode oldLanguage, LanguageCode newLang
        return;
 }
 
+void
+_SearchBarImpl::OnFocusEventListenerAdded(IFocusEventListener& listener)
+{
+       ClearLastResult();
+       SysTryReturnVoidResult(NID_UI,
+                               __pPublicFocusEventListeners->Add(const_cast <IFocusEventListener*>(&listener)) == E_SUCCESS, E_SYSTEM,
+                               "[E_SYSTEM] A system error has occured. Failed to add listener.");
+}
+
+void
+_SearchBarImpl::OnFocusEventListenerRemoved(IFocusEventListener& listener)
+{
+       ClearLastResult();
+       SysTryReturnVoidResult(NID_UI,
+                               __pPublicFocusEventListeners->Remove(&listener) == E_SUCCESS, E_SYSTEM,
+                               "[E_SYSTEM] A system error has occured. Failed to remove 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)
+               {
+                       IEventListener* pListener = null;
+                       pEnumerator->GetCurrent(pListener);
+
+                       IFocusEventListener* pFocusEventListener = dynamic_cast <IFocusEventListener*>(pListener);
+
+                       if (pFocusEventListener != null )
+                       {
+                               pFocusEventListener->OnFocusGained(GetPublic());
+                       }
+               }
+
+               delete pEnumerator;
+       }
+
+       return;
+}
+
+void
+_SearchBarImpl::OnFocusLost(const Tizen::Ui::Control& source)
+{
+       if (&source == __pEditField && __pButtonImpl->GetCore().GetButtonStatus() != _BUTTON_STATUS_HIGHLIGHTED)        //Focus is lost from Edit, and button state is not Highlighted
+       {
+               SetMode(SEARCH_BAR_MODE_NORMAL);
+       }
+
+       if (&source == __pButton)       //Button is highlighted and a touch is performed on Edit.
+       {
+               if (__pButtonImpl->GetCore().GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
+               {
+                       __pButtonImpl->GetCore().SetButtonStatus(_BUTTON_STATUS_NORMAL);
+                       __pButtonImpl->GetCore().Invalidate();
+               }
+       }
+
+       if (!__pSearchBar->IsFocusCallBackToBeFired())
+       {
+               return;
+       }
+
+       IEnumeratorT<IEventListener*>* pEnumerator = __pPublicFocusEventListeners->GetEnumeratorN();
+       if (pEnumerator)
+       {
+               while (pEnumerator->MoveNext() == E_SUCCESS)
+               {
+                       IEventListener* pListener = null;
+                       pEnumerator->GetCurrent(pListener);
+
+                       IFocusEventListener* pFocusEventListener = dynamic_cast <IFocusEventListener*>(pListener);
+
+                       if (pFocusEventListener != null )
+                       {
+                               pFocusEventListener->OnFocusLost(GetPublic());
+                       }
+               }
+
+               delete pEnumerator;
+       }
+
+       return;
+}
+
+void
+_SearchBarImpl::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
+{
+       IEnumeratorT<IEventListener*>* pEnumerator = GetKeyEventListener()->GetEnumeratorN();
+       if (pEnumerator)
+       {
+               while (pEnumerator->MoveNext() == E_SUCCESS)
+               {
+                       IEventListener* pListener = null;
+                       pEnumerator->GetCurrent(pListener);
+
+                       IKeyEventListener* pKeyEventListener = dynamic_cast <IKeyEventListener*>(pListener);
+
+                       if (pKeyEventListener != null )
+                       {
+                               pKeyEventListener->OnKeyPressed(GetPublic(), keyCode);
+                       }
+               }
+
+               delete pEnumerator;
+       }
+
+       return;
+}
+
+void
+_SearchBarImpl::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
+{
+       IEnumeratorT<IEventListener*>* pEnumerator = GetKeyEventListener()->GetEnumeratorN();
+       if (pEnumerator)
+       {
+               while (pEnumerator->MoveNext() == E_SUCCESS)
+               {
+                       IEventListener* pListener = null;
+                       pEnumerator->GetCurrent(pListener);
+
+                       IKeyEventListener* pKeyEventListener = dynamic_cast <IKeyEventListener*>(pListener);
+
+                       if (pKeyEventListener != null )
+                       {
+                               pKeyEventListener->OnKeyReleased(GetPublic(), keyCode);
+                       }
+               }
+
+               delete pEnumerator;
+       }
+
+       return;
+}
+
+void
+_SearchBarImpl::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
+{
+       IEnumeratorT<IEventListener*>* pEnumerator = GetKeyEventListener()->GetEnumeratorN();
+       if (pEnumerator)
+       {
+               while (pEnumerator->MoveNext() == E_SUCCESS)
+               {
+                       IEventListener* pListener = null;
+                       pEnumerator->GetCurrent(pListener);
+
+                       IKeyEventListener* pKeyEventListener = dynamic_cast <IKeyEventListener*>(pListener);
+
+                       if (pKeyEventListener != null )
+                       {
+                               pKeyEventListener->OnKeyLongPressed(GetPublic(), keyCode);
+                       }
+               }
+
+               delete pEnumerator;
+       }
+
+       return;
+}
+
 KeypadAction
 _SearchBarImpl::ConvertKeypadAction(CoreKeypadAction keypadAction) const
 {
@@ -1449,6 +1677,18 @@ _SearchBarImpl::ConvertKeypadAction(CoreKeypadAction keypadAction) const
        return publicKeypadAction;
 }
 
+_EditFieldImpl*
+_SearchBarImpl::GetEditFieldImpl(void) const
+{
+       return __pEditFieldImpl;
+}
+
+_ButtonImpl*
+_SearchBarImpl::GetButtonImpl(void) const
+{
+       return __pButtonImpl;
+}
+
 class _SearchBarMaker
        : public _UiBuilderControlMaker
 {
index 2ff26e4..5cfb375 100644 (file)
@@ -59,12 +59,6 @@ _SearchBarPresenter::~_SearchBarPresenter(void)
        delete __pSearchBarModel;
        __pSearchBarModel = null;
 
-       if (__pIconElement)
-       {
-               __pIconElement->Destroy();
-               __pIconElement = null;
-       }
-
        if (__pReplacedSearchFieldNormalBitmap)
        {
                delete __pReplacedSearchFieldNormalBitmap;
@@ -462,6 +456,7 @@ _SearchBarPresenter::ChangeMode(SearchBarMode mode)
 
        if (mode == SEARCH_BAR_MODE_NORMAL)
        {
+               __pSearchBar->SetFocusCallBackParameter(true);
                InitializeViewModeLayout();
                SetCancelButtonVisible(false);
                SetContainerVisible(false);
@@ -470,7 +465,10 @@ _SearchBarPresenter::ChangeMode(SearchBarMode mode)
                {
                        __pEdit->ClearText();
                        __pEdit->SetBounds(__searchFieldBounds);
-                       __pEdit->HideKeypad();
+                       if (__pEdit->IsFocused())
+                       {
+                               __pEdit->HideKeypad();
+                       }
                }
 
                r = __pSearchBar->SendSearchBarEvent(_SEARCH_BAR_EVENT_MODE_CHANGE);
index 2813577..c754a42 100644 (file)
@@ -335,9 +335,12 @@ public:
        Tizen::Graphics::Bitmap* GetBackgroundBitmap(EditStatus status) const;
        result LoadDefaultBackgroundBitmap(GroupStyle groupStyle);
        result ReplaceDefaultBackgroundBitmapForSearchBar(void);
+       void SetSearchFieldFocus(bool state);
+       bool IsSearchFieldFocused(void) const;
        Tizen::Graphics::Bitmap* GetDefaultBackgroundBitmap(EditStatus status) const;
        bool IsCustomDefaultBackgroundBitmap(EditStatus status) const;
        Tizen::Graphics::Bitmap* GetDefaultBackgroundEffectBitmap(void) const;
+       Tizen::Graphics::Bitmap* GetDefaultFocusBitmap(void) const;
        void GetBlockRange(int& start, int& end) const;
        Tizen::Graphics::Color GetBlockTextColor(void) const;
        Tizen::Graphics::Color GetColor(EditStatus status) const;
@@ -533,6 +536,7 @@ private:
 //Default Bitmap
        Tizen::Graphics::Bitmap* __pDefaultBackgroundBitmap[EDIT_COLOR_MAX];
        Tizen::Graphics::Bitmap* __pDefaultBackgroundEffectBitmap;
+       Tizen::Graphics::Bitmap* __pDefaultFocusBitmap;
 
        Tizen::Ui::_TouchFlickGestureDetector* __pGestureFlick;
        Tizen::Ui::_TouchLongPressGestureDetector* __pGestureLongPress;
@@ -556,6 +560,7 @@ private:
        IEditTextFilter* __pTextFilter;
        Tizen::Graphics::FloatRectangle __previousBounds;
        bool __isTouchMoving;
+       bool __isSearchFieldFocused;
 }; // _Edit
 
 }}} // Tizen::Ui::Controls
index 56c3015..27d3382 100644 (file)
@@ -230,6 +230,8 @@ public:
        SearchFieldStatus GetCurrentStatus(void);
        void  SetEditTextFilter(IEditTextFilter* pFilter);
        void SendOpaqueCommand (const Tizen::Base::String& command);
+       void SetFocusCallBackParameter(bool state);
+       bool IsFocusCallBackToBeFired(void) const;
 
        virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
 
@@ -255,7 +257,6 @@ public:
        virtual bool OnFocusLost(const _Control& source);
 
        virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
-       virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
 
 protected:
        virtual void OnDraw(void);
@@ -273,7 +274,7 @@ private:
        result CreateContentsArea(void);
        result CreateClippedGroupControl(void);
        void CreateAccessibilityElement(void);
-       //Tizen::Graphics::Font* CreateEditFontN(const Tizen::Graphics::Font* pFont);
+       virtual void OnDrawFocus(void);
 
        Tizen::Ui::_Control* GetParentForm(void) const;
 
@@ -295,6 +296,9 @@ private:
        bool __isUserGuideTextColor;
        bool __isKeypadOpening;
        bool __isupdateContentBounds;
+       bool __isKeyPressed;
+       bool __isFocusCallbackToBeFired;
+
        CoreKeypadAction __keypadAction;
 
        Tizen::Graphics::Bitmap* __pBackgroundBitmap;
index 4dd4ef6..6c79ac1 100644 (file)
@@ -44,6 +44,9 @@ namespace Tizen { namespace Ui { namespace Controls
 class _PublicActionEvent;
 class _PublicTextEvent;
 class _PublicTextBlockEvent;
+class EditField;
+class _EditFieldImpl;
+class _ButtonImpl;
 
 class _SearchBarImpl
        : public _ControlImpl
@@ -53,7 +56,8 @@ class _SearchBarImpl
        , public _ITextBlockEventListener
        , public _ITextEventListener
        , public _ISearchBarEventListener
-       , virtual public Tizen::Base::Runtime::IEventListener
+       , public IKeyEventListener
+       , public IFocusEventListener
 {
 public:
        static _SearchBarImpl* CreateSearchBarImplN(SearchBar* pCore, const Tizen::Graphics::Rectangle& bounds, bool enableSearchBarButton = true, KeypadAction keypadAction = KEYPAD_ACTION_SEARCH);
@@ -170,9 +174,24 @@ public:
 
        virtual void OnLanguageChanged(Tizen::Locales::LanguageCode oldLanguage, Tizen::Locales::LanguageCode newLanguage);
 
+       void OnFocusEventListenerAdded(IFocusEventListener& listener);
+       void OnFocusEventListenerRemoved(IFocusEventListener& listener);
+
+       //Focus Callbacks
+       virtual void OnFocusGained(const Tizen::Ui::Control& source);
+       virtual void OnFocusLost(const Tizen::Ui::Control& source);
+
+       //Key event Callbacks
+       virtual void OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode);
+       virtual void OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode);
+       virtual void OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode);
+
        static _SearchBarImpl* GetInstance(SearchBar& searchBar);
        static const _SearchBarImpl* GetInstance(const SearchBar& searchBar);
 
+       _EditFieldImpl* GetEditFieldImpl(void) const;
+       _ButtonImpl* GetButtonImpl(void) const;
+
 private:
        _SearchBarImpl(const _SearchBarImpl&);
        _SearchBarImpl& operator =(const _SearchBarImpl&);
@@ -183,6 +202,11 @@ private:
 
        _SearchBar* __pSearchBar;
 
+       EditField* __pEditField;
+       Button* __pButton;
+       _EditFieldImpl* __pEditFieldImpl;
+       _ButtonImpl* __pButtonImpl;
+
        Control* __pContentControl;
 
        _PublicActionEvent* __pPublicActionEvent;
@@ -192,6 +216,8 @@ private:
        _PublicSearchBarEvent* __pPublicSearchBarEvent;
        _PublicLanguageEvent* __pPublicLanguageEvent;
 
+       PublicEventListenerList* __pPublicFocusEventListeners;
+
 }; // _SearchBarImpl
 
 }}} // Tizen::Ui::Controls
index c4aa614..a61bd7f 100644 (file)
@@ -121,6 +121,7 @@ public:
 
        // [ToDo] Rename API: These APIs return collection.
        Tizen::Base::Collection::LinkedListT <Tizen::Base::Runtime::IEventListener*>* GetTouchEventListener(void) const;
+       Tizen::Base::Collection::LinkedListT <Tizen::Base::Runtime::IEventListener*>* GetKeyEventListener(void) const;
        Tizen::Base::Collection::LinkedListT <Tizen::Base::Runtime::IEventListener*>* GetDragDropEventListener(void) const;
 
 // Queries
index e76b5a9..0591c92 100644 (file)
@@ -44,14 +44,18 @@ DECLARE_UI_CONFIG(SEARCHBAR);
        DECLARE_COLOR_CONFIG(EDIT_TEXT_NORMAL, 17);
        DECLARE_COLOR_CONFIG(EDIT_TEXT_DISABLED, 18);
        DECLARE_COLOR_CONFIG(EDIT_TEXT_HIGHLIGHTED, 19);
+       DECLARE_COLOR_CONFIG(EDIT_BG_FOCUS, 20);
+       DECLARE_COLOR_CONFIG(EDIT_BG_PRESSED, 21);
+       DECLARE_COLOR_CONFIG(EDIT_BG_HIGHLIGHTED, 22);
        DECLARE_IMAGE_CONFIG(EDIT_BG_NORMAL, 1);
        DECLARE_IMAGE_CONFIG(EDIT_BG_DISABLED, 2);
        DECLARE_IMAGE_CONFIG(EDIT_BG_HIGHLIGHTED, 3);
        DECLARE_IMAGE_CONFIG(EDIT_BG_PRESSED, 4);
-       DECLARE_IMAGE_CONFIG(EDIT_BG_EFFECT, 5);
-       DECLARE_IMAGE_CONFIG(ICON_NORMAL, 6);
-       DECLARE_IMAGE_CONFIG(ICON_EFFECT_NORMAL, 7);
-       DECLARE_IMAGE_CONFIG(ICON_DISABLED, 8);
+       DECLARE_IMAGE_CONFIG(EDIT_BG_FOCUS, 5);
+       DECLARE_IMAGE_CONFIG(EDIT_BG_EFFECT, 6);
+       DECLARE_IMAGE_CONFIG(ICON_NORMAL, 7);
+       DECLARE_IMAGE_CONFIG(ICON_EFFECT_NORMAL, 8);
+       DECLARE_IMAGE_CONFIG(ICON_DISABLED, 9);
        DECLARE_SHAPE_CONFIG(HORIZONTAL_MARGIN, 1);
        DECLARE_SHAPE_CONFIG(VERTICAL_MARGIN, 2);
        DECLARE_SHAPE_CONFIG(TEXT_HORIZONTAL_MARGIN, 3);
index 05089ca..c50739e 100644 (file)
@@ -1872,6 +1872,10 @@ ConfigParser::GetImageKeyTable(void)
                        __pImageKeyTable->Add(ResourceKey(key), _SEARCHBAR::EDIT_BG_PRESSED_IMAGE);
                }
                {
+                       const char* key ="SEARCHBAR::EDIT_BG_FOCUS";
+                       __pImageKeyTable->Add(ResourceKey(key), _SEARCHBAR::EDIT_BG_FOCUS_IMAGE);
+               }
+               {
                        const char* key ="SEARCHBAR::ICON_NORMAL";
                        __pImageKeyTable->Add(ResourceKey(key), _SEARCHBAR::ICON_NORMAL_IMAGE);
                }
@@ -3724,6 +3728,18 @@ ConfigParser::GetColorKeyTable(void)
                        __pColorKeyTable->Add(ResourceKey(key), _SEARCHBAR::EDIT_BG_NORMAL_COLOR);
                }
                {
+                       const char* key ="SEARCHBAR::EDIT_BG_PRESSED";
+                       __pColorKeyTable->Add(ResourceKey(key), _SEARCHBAR::EDIT_BG_PRESSED_COLOR);
+               }
+               {
+                       const char* key ="SEARCHBAR::EDIT_BG_HIGHLIGHTED";
+                       __pColorKeyTable->Add(ResourceKey(key), _SEARCHBAR::EDIT_BG_HIGHLIGHTED_COLOR);
+               }
+               {
+                       const char* key ="SEARCHBAR::EDIT_BG_FOCUS";
+                       __pColorKeyTable->Add(ResourceKey(key), _SEARCHBAR::EDIT_BG_FOCUS_COLOR);
+               }
+               {
                        const char* key ="SEARCHBAR::EDIT_BG_DISABLED";
                        __pColorKeyTable->Add(ResourceKey(key), _SEARCHBAR::EDIT_BG_DISABLED_COLOR);
                }
index c0714c1..bfa152b 100644 (file)
@@ -34,7 +34,10 @@ START_UI_CONFIG(SEARCHBAR);
        ADD_COLOR_CONFIG(BUTTON_TEXT_HIGHLIGHTED, $F032L2P);
 
        ADD_COLOR_CONFIG(EDIT_BG_NORMAL, $W031);
+       ADD_COLOR_CONFIG(EDIT_BG_PRESSED, $B0217);
+       ADD_COLOR_CONFIG(EDIT_BG_HIGHLIGHTED, $W031);
        ADD_COLOR_CONFIG(EDIT_BG_DISABLED, $W031D);
+       ADD_COLOR_CONFIG(EDIT_BG_FOCUS, $W161);
        ADD_COLOR_CONFIG(GUIDE_TEXT_NORMAL, $W032);
        ADD_COLOR_CONFIG(GUIDE_TEXT_DISABLED, $W032D);
        ADD_COLOR_CONFIG(GUIDE_TEXT_HIGHLIGHTED, $W032);
@@ -50,6 +53,7 @@ START_UI_CONFIG(SEARCHBAR);
        ADD_IMAGE_CONFIG(EDIT_BG_HIGHLIGHTED, #00_search_edit_field_bg.#.png);
        ADD_IMAGE_CONFIG(EDIT_BG_PRESSED, #00_search_edit_field_bg.#.png);
        ADD_IMAGE_CONFIG(EDIT_BG_EFFECT, #00_search_edit_field_bg_ef.#.png);
+       ADD_IMAGE_CONFIG(EDIT_BG_FOCUS, #00_search_edit_field_focus.#.png);
 
        ADD_IMAGE_CONFIG(ICON_NORMAL, #00_search_icon.png);
        ADD_IMAGE_CONFIG(ICON_DISABLED, #00_search_icon.png);