Commit f83d1138 authored by Tommy C. Li's avatar Tommy C. Li Committed by Commit Bot

Omnibox Refresh UI: Touchable Refresh dimension tweaks.

Tweak the Touchable Refresh dimensions to make everything in the Omnibox
and Suggestions box line up.

Bug: 865766
Change-Id: Ibe9ec38e6b2c1c9d92e56ffff60cf32faa92c59c
Reviewed-on: https://chromium-review.googlesource.com/1157562Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579889}
parent 01191ed1
......@@ -34,10 +34,6 @@ namespace {
// The left-hand margin used for rows with the refresh UI.
static constexpr int kRefreshMarginLeft = 4;
// In the MD refresh or rich suggestions, x-offset of the content and
// description text.
static constexpr int kTextIndent = 47;
// TODO(dschuyler): Perhaps this should be based on the font size
// instead of hardcoded to 2 dp (e.g. by adding a space in an
// appropriate font to the beginning of the description, then reducing
......@@ -64,6 +60,18 @@ static constexpr int kRefreshOneLineRowMarginHeight = 8;
// The margin height of a two-line suggestion row when MD Refresh is enabled.
static constexpr int kRefreshTwoLineRowMarginHeight = 4;
// In the MD refresh or rich suggestions, x-offset of the content and
// description text.
int GetTextIndent() {
constexpr int kTextIndent = 47;
constexpr int kTouchableExtraIndent = 4;
if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled())
return kTextIndent + kTouchableExtraIndent;
else
return kTextIndent;
}
// Returns the padding width between elements.
int HorizontalPadding() {
return GetLayoutConstant(LOCATION_BAR_ELEMENT_PADDING) +
......@@ -276,7 +284,7 @@ gfx::Size OmniboxMatchCellView::CalculatePreferredSize() const {
int height = 0;
if (is_rich_suggestion_ || should_show_tab_match_) {
height = content_view_->GetLineHeight() +
description_view_->GetHeightForWidth(width() - kTextIndent);
description_view_->GetHeightForWidth(width() - GetTextIndent());
} else if (is_old_style_answer_) {
int icon_width = icon_view_->width();
int answer_image_size =
......@@ -301,7 +309,7 @@ bool OmniboxMatchCellView::CanProcessEventsWithinSubtree() const {
int OmniboxMatchCellView::IconWidthAndPadding() const {
return ui::MaterialDesignController::IsRefreshUi()
? kTextIndent
? GetTextIndent()
: icon_view_->width() + (HorizontalPadding() * 2);
}
......@@ -422,7 +430,7 @@ void OmniboxMatchCellView::Layout() {
? kRefreshImageBoxSize
: icon_view_->width();
const int text_indent = ui::MaterialDesignController::IsRefreshUi()
? kTextIndent
? GetTextIndent()
: icon_view_->width() + HorizontalPadding();
if (is_rich_suggestion_ || should_show_tab_match_) {
......@@ -472,18 +480,18 @@ void OmniboxMatchCellView::LayoutNewStyleTwoLineSuggestion() {
image_view = icon_view_;
}
image_view->SetBounds(x, y, kRefreshImageBoxSize, child_area.height());
const int text_width = child_area.width() - kTextIndent;
const int text_width = child_area.width() - GetTextIndent();
if (description_view_->text().empty()) {
// This vertically centers content in the rare case that no description is
// provided.
content_view_->SetBounds(x + kTextIndent, y, text_width,
content_view_->SetBounds(x + GetTextIndent(), y, text_width,
child_area.height());
description_view_->SetSize(gfx::Size());
} else {
const int text_height = content_view_->GetLineHeight();
content_view_->SetBounds(x + kTextIndent, y, text_width, text_height);
content_view_->SetBounds(x + GetTextIndent(), y, text_width, text_height);
description_view_->SetBounds(
x + kTextIndent, y + text_height, text_width,
x + GetTextIndent(), y + text_height, text_width,
description_view_->GetHeightForWidth(text_width));
}
}
......
......@@ -177,8 +177,15 @@ int RoundedOmniboxResultsFrame::GetNonResultSectionHeight() {
// static
gfx::Insets RoundedOmniboxResultsFrame::GetLocationBarAlignmentInsets() {
return ui::MaterialDesignController::IsRefreshUi() ? gfx::Insets(4, 6)
: gfx::Insets(4);
switch (ui::MaterialDesignController::GetMode()) {
case ui::MaterialDesignController::MATERIAL_REFRESH:
return gfx::Insets(4, 6);
case ui::MaterialDesignController::MATERIAL_TOUCH_REFRESH:
return gfx::Insets(6, 1, 5, 1);
default:
return gfx::Insets(4);
}
NOTREACHED();
}
// static
......
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