Commit 8521f642 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Round notification's action buttons row.

This CL implements UpdateCornersRadius in NotificationViewMD to round
corners of the action buttons row.

It also moves UpdateCornerRadius call done in MessageView by checking
NewStyleNotifications flag check to subclasses (NotificationViewMD and
ArcNotificationView).

TEST=manual
BUG=879072

Change-Id: I43932927263ff7cc87d173c27a728d3cc0bc9888
Reviewed-on: https://chromium-review.googlesource.com/1195247
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587971}
parent f6cc0c81
......@@ -55,6 +55,9 @@ ArcNotificationView::ArcNotificationView(
focus_painter_ = views::Painter::CreateSolidFocusPainter(
message_center::kFocusBorderColor, gfx::Insets(0, 1, 3, 2));
UpdateCornerRadius(message_center::kNotificationCornerRadius,
message_center::kNotificationCornerRadius);
}
ArcNotificationView::~ArcNotificationView() {
......
......@@ -53,10 +53,6 @@ base::string16 CreateAccessibleName(const Notification& notification) {
return base::JoinString(accessible_lines, base::ASCIIToUTF16("\n"));
}
bool ShouldRoundMessageViewCorners() {
return base::FeatureList::IsEnabled(message_center::kNewStyleNotifications);
}
} // namespace
// static
......@@ -72,20 +68,14 @@ MessageView::MessageView(const Notification& notification)
// Create the opaque background that's above the view's shadow.
background_view_ = new views::View();
// ChromeOS rounds the corners of the message view. TODO(estade): should we do
// this for all platforms?
if (ShouldRoundMessageViewCorners())
UpdateCornerRadius(kNotificationCornerRadius, kNotificationCornerRadius);
else
UpdateCornerRadius(0, 0);
AddChildView(background_view_);
focus_painter_ = views::Painter::CreateSolidFocusPainter(
kFocusBorderColor, gfx::Insets(0, 0, 1, 1));
UpdateWithNotification(notification);
UpdateCornerRadius(0, 0);
}
MessageView::~MessageView() {}
......
......@@ -9,14 +9,15 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/skia_util.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
namespace message_center {
NotificationBackgroundPainter::NotificationBackgroundPainter(int top_radius,
int bottom_radius)
int bottom_radius,
SkColor color)
: top_radius_(SkIntToScalar(top_radius)),
bottom_radius_(SkIntToScalar(bottom_radius)) {}
bottom_radius_(SkIntToScalar(bottom_radius)),
color_(color) {}
NotificationBackgroundPainter::~NotificationBackgroundPainter() = default;
......@@ -35,7 +36,7 @@ void NotificationBackgroundPainter::Paint(gfx::Canvas* canvas,
cc::PaintFlags flags;
flags.setAntiAlias(true);
flags.setStyle(cc::PaintFlags::kFill_Style);
flags.setColor(kNotificationBackgroundColor);
flags.setColor(color_);
canvas->DrawPath(path, flags);
}
......
......@@ -6,6 +6,7 @@
#define UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_BACKGROUND_PAINTER_H_
#include "ui/message_center/message_center_export.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/views/painter.h"
namespace message_center {
......@@ -16,17 +17,19 @@ namespace message_center {
class MESSAGE_CENTER_EXPORT NotificationBackgroundPainter
: public views::Painter {
public:
NotificationBackgroundPainter(int top_radius, int bottom_radius);
NotificationBackgroundPainter(int top_radius,
int bottom_radius,
SkColor color = kNotificationBackgroundColor);
~NotificationBackgroundPainter() override;
// views::Painter
gfx::Size GetMinimumSize() const override;
void Paint(gfx::Canvas* canvas, const gfx::Size& size) override;
private:
const SkScalar top_radius_;
const SkScalar bottom_radius_;
const SkColor color_;
DISALLOW_COPY_AND_ASSIGN(NotificationBackgroundPainter);
};
......
......@@ -28,6 +28,7 @@
#include "ui/message_center/public/cpp/notification_types.h"
#include "ui/message_center/vector_icons.h"
#include "ui/message_center/views/bounded_label.h"
#include "ui/message_center/views/notification_background_painter.h"
#include "ui/message_center/views/notification_control_buttons_view.h"
#include "ui/message_center/views/notification_header_view.h"
#include "ui/message_center/views/padded_button.h"
......@@ -549,8 +550,6 @@ NotificationViewMD::NotificationViewMD(const Notification& notification)
action_buttons_row_->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::kHorizontal, kActionsRowPadding,
kActionsRowHorizontalSpacing));
action_buttons_row_->SetBackground(
views::CreateSolidBackground(kActionsRowBackgroundColor));
action_buttons_row_->SetVisible(false);
actions_row_->AddChildView(action_buttons_row_);
......@@ -570,6 +569,8 @@ NotificationViewMD::NotificationViewMD(const Notification& notification)
// textfield click in native notification.
// - To make it look similar to ArcNotificationContentView::EventForwarder.
AddPreTargetHandler(click_activator_.get());
UpdateCornerRadius(kNotificationCornerRadius, kNotificationCornerRadius);
}
NotificationViewMD::~NotificationViewMD() {
......@@ -1231,6 +1232,13 @@ void NotificationViewMD::UpdateControlButtonsVisibility() {
control_buttons_view_->SetVisible(target_visibility);
}
void NotificationViewMD::UpdateCornerRadius(int top_radius, int bottom_radius) {
MessageView::UpdateCornerRadius(top_radius, bottom_radius);
action_buttons_row_->SetBackground(views::CreateBackgroundFromPainter(
std::make_unique<NotificationBackgroundPainter>(
0, bottom_radius, kActionsRowBackgroundColor)));
}
NotificationControlButtonsView* NotificationViewMD::GetControlButtonsView()
const {
return control_buttons_view_.get();
......
......@@ -188,6 +188,7 @@ class MESSAGE_CENTER_EXPORT NotificationViewMD
void UpdateWithNotification(const Notification& notification) override;
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
void UpdateControlButtonsVisibility() override;
void UpdateCornerRadius(int top_radius, int bottom_radius) override;
NotificationControlButtonsView* GetControlButtonsView() const override;
bool IsExpanded() const override;
void SetExpanded(bool expanded) 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