Commit 5f034182 authored by Sajad Maysam's avatar Sajad Maysam Committed by Commit Bot

Updated secondary UI to have rounded corners for material design refresh.

DialogDelegate and BubbleDialogDelegateView default drawing rounded
corners during creation of the NonClientFrameView. ExtensionPopups
do not draw rounded borders. This prevents the regression of ugly border
colors not matching the ClientView. FindBarView border manually updated
due to not being a Bubble. Also updated corner radius emphasis metrics
in LayoutProvider to match the material design updates. Increased top
and bottom margins of PageInfo to prevent corners being drawn over.

Bug: 822075
Change-Id: I7fe0a07e4cad7a84fbf54a0dc92e52d36501be9c
Reviewed-on: https://chromium-review.googlesource.com/c/1444275
Commit-Queue: Sajad Maysam <sajadm@google.com>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#631993}
parent d9de68cc
......@@ -94,6 +94,10 @@ void ExtensionPopup::OnWidgetActivationChanged(views::Widget* widget,
CloseUnlessUnderInspection();
}
bool ExtensionPopup::ShouldHaveRoundCorners() const {
return false;
}
void ExtensionPopup::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
......
......@@ -59,6 +59,7 @@ class ExtensionPopup : public views::BubbleDialogDelegateView,
// views::BubbleDialogDelegateView overrides.
int GetDialogButtons() const override;
void OnWidgetActivationChanged(views::Widget* widget, bool active) override;
bool ShouldHaveRoundCorners() const override;
// content::NotificationObserver overrides.
void Observe(int type,
......
......@@ -512,6 +512,8 @@ void FindBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
0xFF);
auto border = std::make_unique<views::BubbleBorder>(
views::BubbleBorder::NONE, views::BubbleBorder::SMALL_SHADOW, bg_color);
border->SetCornerRadius(
ChromeLayoutProvider::Get()->GetCornerRadiusMetric(views::EMPHASIS_HIGH));
SetBackground(std::make_unique<views::BubbleBackground>(border.get()));
SetBorder(std::move(border));
......
......@@ -362,9 +362,13 @@ ProfileChooserView::ProfileChooserView(views::Button* anchor_button,
browser->profile())),
menu_width_(dice_enabled_ ? kFixedMenuWidthDice
: kFixedMenuWidthPreDice) {
// The sign in webview will be clipped on the bottom corners without these
// margins, see related bug <http://crbug.com/593203>.
set_margins(gfx::Insets(0, views::GridLayout::kFixedSize, 2, 0));
// Because the contents are in a ScrollView (see ShowView) they won't be
// clipped by the rounded corners like normal. To work around this, we add
// extra margins on the top and bottom so the scroll view is entirely
// inside the rectangular area of the bubble.
const int corner_radius =
ChromeLayoutProvider::Get()->GetCornerRadiusMetric(views::EMPHASIS_HIGH);
set_margins(gfx::Insets(corner_radius, 0, corner_radius, 0));
ResetView();
chrome::RecordDialogCreation(chrome::DialogIdentifier::PROFILE_CHOOSER);
}
......@@ -1598,7 +1602,10 @@ int ProfileChooserView::GetMaxHeight() const {
display::Screen::GetScreen()
->GetDisplayNearestPoint(anchor_rect.CenterPoint())
.work_area();
int available_space = screen_space.bottom() - anchor_rect.bottom();
const int top_margin =
ChromeLayoutProvider::Get()->GetCornerRadiusMetric(views::EMPHASIS_HIGH);
int available_space =
screen_space.bottom() - anchor_rect.bottom() - top_margin;
#if defined(OS_WIN)
// On Windows the bubble can also be show to the top of the anchor.
available_space =
......
......@@ -425,7 +425,7 @@ class EVENTS_EXPORT LocatedEvent : public Event {
gfx::PointF location_;
// Location of the event. What coordinate system this is in depends upon the
// phase of event dispatch. For client code (meaning EventHanalders) it is
// phase of event dispatch. For client code (meaning EventHandlers) it is
// generally in screen coordinates, but early on it may be in pixels and
// relative to a display. Native events may generate float values with
// sub-pixel precision.
......
......@@ -206,8 +206,7 @@ gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& anchor_rect,
}
int BubbleBorder::GetBorderCornerRadius() const {
constexpr int kCornerRadius = 2;
return corner_radius_.value_or(kCornerRadius);
return corner_radius_.value_or(0);
}
void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) {
......
......@@ -140,8 +140,8 @@ ClientView* BubbleDialogDelegateView::CreateClientView(Widget* widget) {
NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView(
Widget* widget) {
BubbleFrameView* frame = new BubbleDialogFrameView(title_margins_);
LayoutProvider* provider = LayoutProvider::Get();
frame->set_footnote_margins(
provider->GetInsetsMetric(INSETS_DIALOG_SUBSECTION));
frame->SetFootnoteView(CreateFootnoteView());
......@@ -151,10 +151,11 @@ NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView(
adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow);
std::unique_ptr<BubbleBorder> border =
std::make_unique<BubbleBorder>(adjusted_arrow, GetShadow(), color());
// If custom shadows aren't supported we fall back to an OS provided square
// shadow.
if (!CustomShadowsSupported())
border->SetCornerRadius(0);
if (CustomShadowsSupported() && ShouldHaveRoundCorners()) {
const int corner_radius = provider->GetCornerRadiusMetric(EMPHASIS_HIGH);
border->SetCornerRadius(corner_radius);
}
frame->SetBubbleBorder(std::move(border));
return frame;
}
......
......@@ -150,11 +150,11 @@ int LayoutProvider::GetCornerRadiusMetric(EmphasisMetric emphasis_metric,
return 0;
case EMPHASIS_LOW:
case EMPHASIS_MEDIUM:
return touch_ui ? 4 : 2;
return 4;
case EMPHASIS_HIGH:
return touch_ui ? 8 : 4;
return 8;
case EMPHASIS_MAXIMUM:
return touch_ui ? std::min(size.width(), size.height()) / 2 : 4;
return touch_ui ? std::min(size.width(), size.height()) / 2 : 16;
}
}
......
......@@ -169,6 +169,10 @@ bool DialogDelegate::ShouldSnapFrameWidth() const {
return GetDialogButtons() != ui::DIALOG_BUTTON_NONE;
}
bool DialogDelegate::ShouldHaveRoundCorners() const {
return true;
}
View* DialogDelegate::GetInitiallyFocusedView() {
// Focus the default button if any.
const DialogClientView* dcv = GetDialogClientView();
......@@ -208,14 +212,20 @@ NonClientFrameView* DialogDelegate::CreateDialogFrameView(Widget* widget) {
LayoutProvider* provider = LayoutProvider::Get();
BubbleFrameView* frame = new BubbleFrameView(
provider->GetInsetsMetric(INSETS_DIALOG_TITLE), gfx::Insets());
const BubbleBorder::Shadow kShadow = BubbleBorder::DIALOG_SHADOW;
std::unique_ptr<BubbleBorder> border = std::make_unique<BubbleBorder>(
BubbleBorder::FLOAT, kShadow, gfx::kPlaceholderColor);
border->set_use_theme_background_color(true);
frame->SetBubbleBorder(std::move(border));
DialogDelegate* delegate = widget->widget_delegate()->AsDialogDelegate();
if (delegate)
if (delegate) {
if (delegate->ShouldHaveRoundCorners()) {
const int corner_radius = provider->GetCornerRadiusMetric(EMPHASIS_HIGH);
border->SetCornerRadius(corner_radius);
}
frame->SetFootnoteView(delegate->CreateFootnoteView());
}
frame->SetBubbleBorder(std::move(border));
return frame;
}
......
......@@ -110,6 +110,9 @@ class VIEWS_EXPORT DialogDelegate : public WidgetDelegate {
// LayoutProvider's snapping.
virtual bool ShouldSnapFrameWidth() const;
// Returns whether the dialog should have round corners
virtual bool ShouldHaveRoundCorners() const;
// Overridden from WidgetDelegate:
View* GetInitiallyFocusedView() override;
DialogDelegate* AsDialogDelegate() override;
......
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