}
+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)
{
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();
__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;
}
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;