Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1411)

Unified Diff: chrome/browser/ui/views/find_bar_view.cc

Issue 516943003: Add textfield internal padding from FocusableBorder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update AppList's SearchBoxView and FolderHeaderView; git cl format. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/find_bar_view.cc
diff --git a/chrome/browser/ui/views/find_bar_view.cc b/chrome/browser/ui/views/find_bar_view.cc
index 7ec9e1a93d6c4e15d57bd1064a3c529d0989229e..19827157adaa3cfb9a126d24a3e81a43379aaeaa 100644
--- a/chrome/browser/ui/views/find_bar_view.cc
+++ b/chrome/browser/ui/views/find_bar_view.cc
@@ -37,12 +37,14 @@
namespace {
-// The margins around the search field, match count label, and the close button.
+// The margins around the UI controls, derived from assets and design specs.
const int kMarginLeftOfCloseButton = 3;
Peter Kasting 2014/09/05 22:56:48 Nit: Should we collapse this and kMarginLeftOfMatc
msw 2014/09/05 23:46:55 That might be reasonable for follow-up, but I'm no
const int kMarginRightOfCloseButton = 7;
-const int kMarginLeftOfMatchCountLabel = 2;
+const int kMarginLeftOfMatchCountLabel = 3;
const int kMarginRightOfMatchCountLabel = 1;
const int kMarginLeftOfFindTextfield = 12;
+const int kMarginAboveFindTextfield = 6;
Peter Kasting 2014/09/05 22:56:48 Nit: Maybe this and the next constant should just
msw 2014/09/05 23:46:55 Done. I'm not entirely sure that these values are
+const int kMarginBelowFindTextfield = 6;
// The margins around the match count label (We add extra space so that the
// background highlight extends beyond just the text).
@@ -318,17 +320,21 @@ void FindBarView::Layout() {
sz.SetToMax(gfx::Size(kMatchCountMinWidth, 0));
int match_count_x =
find_previous_button_->x() - kMarginRightOfMatchCountLabel - sz.width();
- int find_text_y = (height() - find_text_->GetPreferredSize().height()) / 2;
+ int find_text_y = kMarginAboveFindTextfield;
Peter Kasting 2014/09/05 22:56:49 Interesting, is it no longer possible to use the p
msw 2014/09/05 23:46:55 This approach is preferable to the current code fo
match_count_text_->SetBounds(match_count_x,
find_text_y + find_text_->GetBaseline() -
match_count_text_->GetBaseline(),
sz.width(), sz.height());
- // And whatever space is left in between, gets filled up by the find edit box.
- int find_text_width = std::max(0, match_count_x -
- kMarginLeftOfMatchCountLabel - kMarginLeftOfFindTextfield);
- find_text_->SetBounds(kMarginLeftOfFindTextfield, find_text_y,
- find_text_width, find_text_->GetPreferredSize().height());
+ // Fill the remaining width and available height with the textfield.
+ int margin_a = kMarginLeftOfFindTextfield - views::Textfield::kTextPadding;
+ int margin_b = kMarginLeftOfMatchCountLabel - views::Textfield::kTextPadding;
Peter Kasting 2014/09/05 22:56:48 Nit: I'm not in love with "margin_a" and "margin_b
msw 2014/09/05 23:46:55 Done.
+ int find_text_width = std::max(0, match_count_x - margin_a - margin_b);
+ find_text_->SetBounds(
+ margin_a,
+ find_text_y,
+ find_text_width,
+ height() - kMarginAboveFindTextfield - kMarginBelowFindTextfield);
// The focus forwarder view is a hidden view that should cover the area
// between the find text box and the find button so that when the user clicks
@@ -346,7 +352,8 @@ gfx::Size FindBarView::GetPreferredSize() const {
// Add up all the preferred sizes and margins of the rest of the controls.
prefsize.Enlarge(kMarginLeftOfCloseButton + kMarginRightOfCloseButton +
- kMarginLeftOfFindTextfield,
+ kMarginLeftOfFindTextfield -
+ 2 * views::Textfield::kTextPadding,
0);
prefsize.Enlarge(find_previous_button_->GetPreferredSize().width(), 0);
prefsize.Enlarge(find_next_button_->GetPreferredSize().width(), 0);

Powered by Google App Engine
This is Rietveld 408576698