Float changes and button Clipping for SB
authorAyush <ayush.sriv@samsung.com>
Sat, 16 Mar 2013 09:13:37 +0000 (14:43 +0530)
committerAyush <ayush.sriv@samsung.com>
Sat, 16 Mar 2013 09:54:12 +0000 (15:24 +0530)
Change-Id: I7ca9943a5295f33ab7a843677c40c347cc7ed89f
Signed-off-by: Ayush <ayush.sriv@samsung.com>
src/ui/controls/FUiCtrl_SearchBar.cpp
src/ui/controls/FUiCtrl_SearchBarPresenter.cpp

index 18cec54..7af5fb3 100644 (file)
@@ -272,14 +272,14 @@ _SearchBar::CreateSearchField(void)
        result r = E_SUCCESS;
 
        FloatRectangle editBounds;
-       int horizontalMargin = 0;
-       int verticalMargin = 0;
-       int iconHorizontalMargin = 0;
-       int textHorizontalMargin = 0;
-       int iconWidth = 0;
-       int textSize = 0;
-       int searchFieldMinWidth = 0;
-       int searchBarMinHeight = 0;
+       float horizontalMargin = 0.0f;
+       float verticalMargin = 0.0f;
+       float iconHorizontalMargin = 0.0f;
+       float textHorizontalMargin = 0.0f;
+       float iconWidth = 0.0f;
+       float textSize = 0.0f;
+       float searchFieldMinWidth = 0.0f;
+       float searchBarMinHeight = 0.0f;
 
        FloatRectangle searchBarBounds = GetBoundsF();
        _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
@@ -293,10 +293,10 @@ _SearchBar::CreateSearchField(void)
        GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
        GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
 
-       int searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2);
+       float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
 
-       editBounds.x = _CoordinateSystemUtils::ConvertToFloat(horizontalMargin);
-       editBounds.y = _CoordinateSystemUtils::ConvertToFloat(verticalMargin);
+       editBounds.x = horizontalMargin;
+       editBounds.y = verticalMargin;
        editBounds.width = searchBarBounds.width - (editBounds.x * 2.0f);
        editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
 
@@ -369,7 +369,7 @@ _SearchBar::CreateCancelButton(void)
 {
        result r = E_SUCCESS;
 
-       int textSize = 0;
+       float textSize = 0.0f;
        String cancelButtonText;
 
        _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
@@ -2463,15 +2463,15 @@ _SearchBar::ResizeCancelButton(void)
 {
        result r = E_SUCCESS;
 
-       int horizontalMargin = 0;
-       int buttonLeftMargin = 0;
-       int buttonRightMargin = 0;
-       int buttonMinWidth = 0;
-       int searchFieldMinWidth = 0;
-       int buttonVerticalMargin = 0;
-       int searchBarMinHeight = 0;
-       int buttonWidth = 0;
-       int buttonHeight = 0;
+       float horizontalMargin = 0.0f;
+       float buttonLeftMargin = 0.0f;
+       float buttonRightMargin = 0.0f;
+       float buttonMinWidth = 0.0f;
+       float searchFieldMinWidth = 0.0f;
+       float buttonVerticalMargin = 0.0f;
+       float searchBarMinHeight = 0.0f;
+       float buttonWidth = 0.0f;
+       float buttonHeight = 0.0f;
 
        FloatRectangle cancelButtonBounds;
        FloatRectangle searchBarBounds = GetBoundsF();
@@ -2488,8 +2488,8 @@ _SearchBar::ResizeCancelButton(void)
        GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
        GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
 
-       cancelButtonBounds.width = _CoordinateSystemUtils::ConvertToFloat(buttonWidth);
-       cancelButtonBounds.height = _CoordinateSystemUtils::ConvertToFloat(buttonHeight);
+       cancelButtonBounds.width = buttonWidth;
+       cancelButtonBounds.height = buttonHeight;
 
        float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
                                             cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
@@ -2518,7 +2518,6 @@ _SearchBar::ResizeCancelButton(void)
        r = __pCancelButton->SetBounds(cancelButtonBounds);
 
        return r;
-
 }
 
 void
@@ -2526,16 +2525,16 @@ _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;
+       float horizontalMargin = 0.0f;
+       float verticalMargin = 0.0f;
+       float buttonLeftMargin = 0.0f;
+       float buttonRightMargin = 0.0f;
+       float buttonMinWidth = 0.0f;
+       float searchFieldMinWidth = 0.0f;
+       float buttonVerticalMargin = 0.0f;
+       float searchBarMinHeight = 0.0f;
+       float buttonWidth = 0.0f;
+       float buttonHeight = 0.0f;
 
        FloatRectangle cancelButtonBounds;
        FloatRectangle searchBarBounds = GetBoundsF();
@@ -2553,7 +2552,7 @@ _SearchBar::RecalculateButtonBounds(void)
        GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
        GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
 
-       cancelButtonBounds.height = buttonHeight        ;
+       cancelButtonBounds.height = buttonHeight;
 
        FloatRectangle editBounds;
 
@@ -2565,7 +2564,7 @@ _SearchBar::RecalculateButtonBounds(void)
        editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
        editBounds.height = (editBounds.height > searchBarMinHeight) ? editBounds.height : searchBarMinHeight;
 
-       editBounds.width = searchBarBounds.width - cancelButtonWidth - (2 * horizontalMargin) - buttonLeftMargin;
+       editBounds.width = searchBarBounds.width - cancelButtonWidth - horizontalMargin - buttonLeftMargin - buttonRightMargin;
 
        if (editBounds.width < searchFieldMinWidth)
        {
@@ -2580,7 +2579,9 @@ _SearchBar::RecalculateButtonBounds(void)
                cancelButtonBounds.y = buttonVerticalMargin;
        }
 
-       if (cancelButtonWidth < buttonMinWidth)
+       float remainingWidth = searchBarBounds.width - editBounds.width - horizontalMargin - buttonLeftMargin - buttonRightMargin;
+
+       if (remainingWidth < buttonMinWidth)
        {
                cancelButtonBounds.width = buttonMinWidth;
        }
index aa2bfe1..eeb266e 100644 (file)
@@ -364,23 +364,23 @@ _SearchBarPresenter::DrawIcon(void)
 
        isCustomBitmap = IS_CUSTOM_BITMAP(SEARCHBAR::ICON_NORMAL);
 
-       int iconMarginH = 0;
-       int iconWidth = 0;
-       int iconHeight = 0;
+       float iconMarginH = 0.0f;
+       float iconWidth = 0.0f;
+       float iconHeight = 0.0f;
        _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
 
        GET_SHAPE_CONFIG(SEARCHBAR::ICON_HORIZONTAL_MARGIN, orientation, iconMarginH);
        GET_SHAPE_CONFIG(SEARCHBAR::ICON_WIDTH, orientation, iconWidth);
        GET_SHAPE_CONFIG(SEARCHBAR::ICON_HEIGHT, orientation, iconHeight);
 
-       iconBounds.x = _CoordinateSystemUtils::ConvertToFloat(iconMarginH);
+       iconBounds.x = iconMarginH;
        iconBounds.y = (__pEdit->GetBoundsF().height - iconWidth) / 2.0f;
-       iconBounds.width = _CoordinateSystemUtils::ConvertToFloat(iconWidth);
-       iconBounds.height = _CoordinateSystemUtils::ConvertToFloat(iconHeight);
+       iconBounds.width = iconWidth;
+       iconBounds.height = iconHeight;
 
        __pIconElement->SetBounds(FloatRectangle(iconBounds.x, iconBounds.y, iconBounds.width, iconBounds.height));
 
-       pIconCanvas = __pIconElement->GetCanvasN(FloatRectangle(0, 0, iconBounds.width, iconBounds.height));
+       pIconCanvas = __pIconElement->GetCanvasN(FloatRectangle(0.0f, 0.0f, iconBounds.width, iconBounds.height));
        SysTryReturnResult(NID_UI_CTRL, pIconCanvas != null, GetLastResult(), "Propagating.");
 
        pIconCanvas->SetBackgroundColor(Color(0));
@@ -470,7 +470,7 @@ _SearchBarPresenter::ChangeMode(SearchBarMode mode)
                {
                        __pEdit->SetCursorDisabled(false);
 
-                       float buttonWidth = 0;
+                       float buttonWidth = 0.0f;
                        _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
                        GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
 
@@ -507,11 +507,11 @@ _SearchBarPresenter::InitializeInputModeLayout(void)
                return;
        }
 
-       int horizontalMargin = 0;
-       int buttonRightMargin = 0;
-       int buttonLeftMargin = 0;
-       int buttonWidth = 0;
-       int searchFieldMinWidth = 0;
+       float horizontalMargin = 0.0f;
+       float buttonRightMargin = 0.0f;
+       float buttonLeftMargin = 0.0f;
+       float buttonWidth = 0.0f;
+       float searchFieldMinWidth = 0.0f;
        _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
 
        GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
@@ -519,7 +519,7 @@ _SearchBarPresenter::InitializeInputModeLayout(void)
        GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
        GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
        GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
-       int buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
+       float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
                                             buttonWidth + buttonLeftMargin + buttonRightMargin);
 
        if (__pSearchBar->GetBoundsF().width < buttonResizableSearchBarWidth)
@@ -538,7 +538,6 @@ _SearchBarPresenter::InitializeInputModeLayout(void)
        float cancelButtonWidth = 0.0f;
        cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
 
-
        if (cancelButtonWidth > buttonWidth)
        {
                __pSearchBar->RecalculateButtonBounds();
@@ -550,10 +549,10 @@ _SearchBarPresenter::InitializeInputModeLayout(void)
 void
 _SearchBarPresenter::InitializeViewModeLayout(void)
 {
-       int horizontalMargin = 0;
-       int verticalMargin = 0;
-       int searchFieldMinWidth = 0;
-       int searchBarMinHeight = 0;
+       float horizontalMargin = 0.0f;
+       float verticalMargin = 0.0f;
+       float searchFieldMinWidth = 0.0f;
+       float searchBarMinHeight = 0.0f;
        _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
 
        GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
@@ -561,12 +560,12 @@ _SearchBarPresenter::InitializeViewModeLayout(void)
        GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
        GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
 
-       int searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2);
+       float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
 
-       __searchFieldBounds.x = _CoordinateSystemUtils::ConvertToFloat(horizontalMargin);
-       __searchFieldBounds.y = _CoordinateSystemUtils::ConvertToFloat(verticalMargin);
-       __searchFieldBounds.width = __pSearchBar->GetBoundsF().width - (horizontalMargin * 2);
-       __searchFieldBounds.height = __pSearchBar->GetBoundsF().height - (verticalMargin * 2);
+       __searchFieldBounds.x = horizontalMargin;
+       __searchFieldBounds.y = verticalMargin;
+       __searchFieldBounds.width = __pSearchBar->GetBoundsF().width - (horizontalMargin * 2.0f);
+       __searchFieldBounds.height = __pSearchBar->GetBoundsF().height - (verticalMargin * 2.0f);
 
        __searchFieldBounds.width = (__searchFieldBounds.width > searchFieldMinWidth) ? __searchFieldBounds.width : searchFieldMinWidth;
        __searchFieldBounds.height = (__searchFieldBounds.height > searchFieldMinHeight) ? __searchFieldBounds.height : searchFieldMinHeight;
@@ -606,7 +605,7 @@ _SearchBarPresenter::OnBoundsChanged(void)
 
        if (GetMode() == SEARCH_BAR_MODE_INPUT)
        {
-               float buttonWidth = 0;
+               float buttonWidth = 0.0f;
                _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
                GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
                float cancelButtonWidth = 0.0f;