From: Ayush Date: Sat, 16 Mar 2013 04:34:24 +0000 (+0530) Subject: Button Resizing in SB X-Git-Tag: accepted/tizen_2.1/20130425.033138~881^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=655e8e837b161da4039f850f6cdd495f4deb7e0d;p=platform%2Fframework%2Fnative%2Fuifw.git Button Resizing in SB Change-Id: I5a4742d5ff34798ca0103a5ac78ccca63bee79f4 Signed-off-by: Ayush Signed-off-by: Syed Khaja Moinuddin --- diff --git a/src/ui/controls/FUiCtrl_SearchBar.cpp b/src/ui/controls/FUiCtrl_SearchBar.cpp index 30b0232..46c1cb3 100644 --- a/src/ui/controls/FUiCtrl_SearchBar.cpp +++ b/src/ui/controls/FUiCtrl_SearchBar.cpp @@ -2521,6 +2521,85 @@ _SearchBar::ResizeCancelButton(void) } +void +_SearchBar::RecalculateButtonBounds(void) +{ + result r = E_SUCCESS; + + Float horizontalMargin = 0; + Float verticalMargin = 0; + Float buttonLeftMargin = 0; + Float buttonRightMargin = 0; + Float buttonMinWidth = 0; + Float searchFieldMinWidth = 0; + Float buttonVerticalMargin = 0; + Float searchBarMinHeight = 0; + Float buttonWidth = 0; + Float buttonHeight = 0; + + FloatRectangle cancelButtonBounds; + FloatRectangle searchBarBounds = GetBoundsF(); + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin); + GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth); + GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth); + GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin); + GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight); + + cancelButtonBounds.height = buttonHeight ; + + FloatRectangle editBounds; + + float cancelButtonWidth = 0; + cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF(); + editBounds.x = horizontalMargin; + editBounds.y = verticalMargin; + + editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f); + editBounds.height = (editBounds.height > searchBarMinHeight) ? editBounds.height : searchBarMinHeight; + + editBounds.width = searchBarBounds.width - cancelButtonWidth - (2 * horizontalMargin) - buttonLeftMargin; + + if (editBounds.width < searchFieldMinWidth) + { + editBounds.width = searchFieldMinWidth; + } + + cancelButtonBounds.x = editBounds.width + horizontalMargin + buttonLeftMargin; + cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f; + + if (searchBarBounds.height < searchBarMinHeight) + { + cancelButtonBounds.y = buttonVerticalMargin; + } + + if (cancelButtonWidth < buttonMinWidth) + { + cancelButtonBounds.width = buttonMinWidth; + } + else + { + cancelButtonBounds.width = searchBarBounds.width - cancelButtonBounds.x - buttonRightMargin; + } + + cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f; + cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f; + + r = __pCancelButton->SetBounds(cancelButtonBounds); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __pEdit->SetBounds(editBounds); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + SearchFieldStatus _SearchBar::GetCurrentStatus(void) { diff --git a/src/ui/controls/FUiCtrl_SearchBarPresenter.cpp b/src/ui/controls/FUiCtrl_SearchBarPresenter.cpp index 6d17d86..aa2bfe1 100644 --- a/src/ui/controls/FUiCtrl_SearchBarPresenter.cpp +++ b/src/ui/controls/FUiCtrl_SearchBarPresenter.cpp @@ -469,7 +469,19 @@ _SearchBarPresenter::ChangeMode(SearchBarMode mode) if (__pEdit) { __pEdit->SetCursorDisabled(false); - __pEdit->SetBounds(__searchFieldBounds); + + float buttonWidth = 0; + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth); + + float cancelButtonWidth = 0.0f; + cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF(); + + if (cancelButtonWidth <= buttonWidth) + { + __pEdit->SetBounds(__searchFieldBounds); + } + __pEdit->ShowKeypad(); } __pSearchBar->SetContentsArea(); @@ -523,6 +535,15 @@ _SearchBarPresenter::InitializeInputModeLayout(void) __searchFieldBounds.width = (__pSearchBar->GetBoundsF().width > searchFieldMinWidth) ? __searchFieldBounds.width : searchFieldMinWidth; + float cancelButtonWidth = 0.0f; + cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF(); + + + if (cancelButtonWidth > buttonWidth) + { + __pSearchBar->RecalculateButtonBounds(); + } + return; } @@ -583,6 +604,19 @@ _SearchBarPresenter::OnBoundsChanged(void) r = __pEdit->SetBounds(__searchFieldBounds); SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.",GetErrorMessage(r)); + if (GetMode() == SEARCH_BAR_MODE_INPUT) + { + float buttonWidth = 0; + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth); + float cancelButtonWidth = 0.0f; + cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF(); + if (cancelButtonWidth > buttonWidth) + { + __pSearchBar->RecalculateButtonBounds(); + } + } + __pSearchBar->SetContentsArea(); return; diff --git a/src/ui/inc/FUiCtrl_SearchBar.h b/src/ui/inc/FUiCtrl_SearchBar.h index 508b242..c50cc81 100644 --- a/src/ui/inc/FUiCtrl_SearchBar.h +++ b/src/ui/inc/FUiCtrl_SearchBar.h @@ -226,6 +226,7 @@ public: void SetContentDimming(void); bool IsContentAttachable(const _Control* pContent); result ResizeCancelButton(void); + void RecalculateButtonBounds(void); SearchFieldStatus GetCurrentStatus(void); void SetEditTextFilter(IEditTextFilter* pFilter); void SendOpaqueCommand (const Tizen::Base::String& command);