Commit 7f81b390 authored by Tommy Li's avatar Tommy Li Committed by Commit Bot

[omnibox] Align header and icon horizontally aligned with matches

This CL makes sure the header text is programmatically aligned with the
small icons on the left.

It also makes sure the collapse button is aligned with the remove
suggestion button.

Bug: 1052522
Change-Id: I4ee9e107bc92e32951a85714c90c3bc9dcfbc968
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2165722
Commit-Queue: Tommy Li <tommycli@chromium.org>
Reviewed-by: default avatarmanuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762518}
parent 13d4d413
......@@ -264,8 +264,8 @@ const char* OmniboxMatchCellView::GetClassName() const {
gfx::Insets OmniboxMatchCellView::GetInsets() const {
const bool single_line = layout_style_ == LayoutStyle::ONE_LINE_SUGGESTION;
const int vertical_margin = single_line ? 8 : 4;
return gfx::Insets(vertical_margin, 4, vertical_margin,
OmniboxMatchCellView::kMarginRight);
return gfx::Insets(vertical_margin, OmniboxMatchCellView::kMarginLeft,
vertical_margin, OmniboxMatchCellView::kMarginRight);
}
void OmniboxMatchCellView::Layout() {
......@@ -278,7 +278,8 @@ void OmniboxMatchCellView::Layout() {
const int row_height = child_area.height();
views::ImageView* const image_view =
(two_line && is_rich_suggestion_) ? answer_image_view_ : icon_view_;
image_view->SetBounds(x, y, 40, row_height);
image_view->SetBounds(x, y, OmniboxMatchCellView::kImageBoundsWidth,
row_height);
const int text_indent = GetTextIndent() + tail_suggest_common_prefix_width_;
x += text_indent;
......
......@@ -17,8 +17,10 @@ class OmniboxTextView;
class OmniboxMatchCellView : public views::View {
public:
// The right-hand margin used for rows.
// Constants used in layout. Exposed so other views can coordinate margins.
static constexpr int kMarginLeft = 4;
static constexpr int kMarginRight = 8;
static constexpr int kImageBoundsWidth = 40;
explicit OmniboxMatchCellView(OmniboxResultView* result_view);
~OmniboxMatchCellView() override;
......
......@@ -8,6 +8,7 @@
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/omnibox/omnibox_theme.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/ui/views/omnibox/omnibox_match_cell_view.h"
#include "chrome/browser/ui/views/omnibox/omnibox_result_view.h"
#include "components/omnibox/browser/omnibox_prefs.h"
#include "components/omnibox/browser/vector_icons.h"
......@@ -60,7 +61,21 @@ class OmniboxRowView::HeaderView : public views::View,
}
// views::View:
gfx::Insets GetInsets() const override { return gfx::Insets(8, 16); }
gfx::Insets GetInsets() const override {
constexpr int vertical = 8;
// Aligns the header text with the icons of ordinary matches. The assumed
// small icon width here is lame, but necessary, since it's not explicitly
// defined anywhere else in the code.
constexpr int assumed_match_cell_icon_width = 16;
constexpr int left_inset = OmniboxMatchCellView::kMarginLeft +
(OmniboxMatchCellView::kImageBoundsWidth -
assumed_match_cell_icon_width) /
2;
return gfx::Insets(vertical, left_inset, vertical,
OmniboxMatchCellView::kMarginRight);
}
void OnMouseEntered(const ui::MouseEvent& event) override {
UpdateUIForHoverState();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment