Button Resizing in SB
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_SearchBar.cpp
index 30b0232..46c1cb3 100644 (file)
@@ -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)
 {