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 49627d798f76cf6dbe42eead2924251379554333..4fa06646759193a76565934e9a0bbdece96f53ed 100644 |
--- a/chrome/browser/ui/views/find_bar_view.cc |
+++ b/chrome/browser/ui/views/find_bar_view.cc |
@@ -21,6 +21,7 @@ |
#include "chrome/browser/ui/view_ids.h" |
#include "chrome/browser/ui/views/find_bar_host.h" |
#include "chrome/browser/ui/views/frame/browser_view.h" |
+#include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
#include "chrome/grit/generated_resources.h" |
#include "components/strings/grit/components_strings.h" |
#include "ui/base/ime/input_method.h" |
@@ -42,20 +43,12 @@ |
#include "ui/views/controls/separator.h" |
#include "ui/views/layout/box_layout.h" |
#include "ui/views/painter.h" |
+#include "ui/views/view_properties.h" |
#include "ui/views/view_targeter.h" |
#include "ui/views/widget/widget.h" |
namespace { |
-// These layout constants are all in dp. |
-// The horizontal and vertical insets for the bar. |
-const int kInteriorPadding = 8; |
-// Default spacing between child views. |
-const int kInterChildSpacing = 4; |
-// Additional spacing around the separator. |
-const int kSeparatorLeftSpacing = 12 - kInterChildSpacing; |
-const int kSeparatorRightSpacing = 8 - kInterChildSpacing; |
- |
// The default number of average characters that the text box will be. |
const int kDefaultCharWidth = 30; |
@@ -161,15 +154,38 @@ FindBarView::FindBarView(FindBarHost* host) |
base::MakeUnique<views::ViewTargeter>(this)); |
AddChildViewAt(match_count_text_, 1); |
- separator_->SetBorder(views::CreateEmptyBorder(0, kSeparatorLeftSpacing, 0, |
- kSeparatorRightSpacing)); |
+ ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
+ |
+ // We use the same border as the image button for the separator to make it |
+ // equidistant from the match count text on the left and the image button on |
+ // the right. |
+ gfx::Insets image_button_insets = provider->GetInsetsMetric( |
+ views::INSETS_VECTOR_IMAGE_BUTTON); |
+ separator_->SetBorder(views::CreateEmptyBorder(0, image_button_insets.left(), |
+ 0, image_button_insets.right())); |
Peter Kasting
2017/07/14 00:40:12
This won't make things equidistant (as is visible
ananta
2017/07/14 01:04:29
ok. thanks. The patch came out wrong though. I was
|
+ |
AddChildViewAt(separator_, 2); |
+ find_previous_button_->SetProperty(views::kMarginsKey, new gfx::Insets( |
+ provider->GetDistanceMetric(DISTANCE_TOAST_CONTROL_VERTICAL), 0)); |
+ find_next_button_->SetProperty(views::kMarginsKey, new gfx::Insets( |
+ provider->GetDistanceMetric(DISTANCE_TOAST_CONTROL_VERTICAL), 0)); |
+ close_button_->SetProperty(views::kMarginsKey, new gfx::Insets( |
+ provider->GetDistanceMetric(DISTANCE_TOAST_CONTROL_VERTICAL), 0)); |
+ find_text_->SetProperty(views::kMarginsKey, new gfx::Insets( |
+ provider->GetDistanceMetric(DISTANCE_TOAST_CONTROL_VERTICAL), 0)); |
+ match_count_text_->SetProperty(views::kMarginsKey, new gfx::Insets( |
+ provider->GetDistanceMetric(DISTANCE_TOAST_LABEL_VERTICAL), 0)); |
+ separator_->SetProperty(views::kMarginsKey, new gfx::Insets( |
+ provider->GetDistanceMetric(DISTANCE_TOAST_LABEL_VERTICAL), 0)); |
+ |
find_text_->SetBorder(views::NullBorder()); |
views::BoxLayout* manager = |
new views::BoxLayout(views::BoxLayout::kHorizontal, |
- gfx::Insets(kInteriorPadding), kInterChildSpacing); |
+ provider->GetInsetsMetric(views::INSETS_TOAST), |
+ provider->GetDistanceMetric( |
+ views::DISTANCE_RELATED_CONTROL_HORIZONTAL)); |
SetLayoutManager(manager); |
manager->SetFlexForView(find_text_, 1); |
} |
@@ -220,8 +236,8 @@ void FindBarView::UpdateForResult(const FindNotificationDetails& result, |
return; |
} |
- match_count_text_->SetText(l10n_util::GetStringFUTF16( |
- IDS_FIND_IN_PAGE_COUNT, base::FormatNumber(result.active_match_ordinal()), |
+ match_count_text_->SetText(l10n_util::GetStringFUTF16(IDS_FIND_IN_PAGE_COUNT, |
+ base::FormatNumber(result.active_match_ordinal()), |
base::FormatNumber(result.number_of_matches()))); |
UpdateMatchCountAppearance(result.number_of_matches() == 0 && |