Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Unified Diff: ui/message_center/views/notification_view_md.cc

Issue 2958963002: Add ripple effect to action buttons in new-style notification. (Closed)
Patch Set: Resolve review comments. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/views/notification_view_md.cc
diff --git a/ui/message_center/views/notification_view_md.cc b/ui/message_center/views/notification_view_md.cc
index 66e70fd5d2a6b06926314a4a680dc5d7b419b8d9..79eb1da8c6e98ccb53742bfd003be2e166726c37 100644
--- a/ui/message_center/views/notification_view_md.cc
+++ b/ui/message_center/views/notification_view_md.cc
@@ -27,6 +27,7 @@
#include "ui/message_center/views/padded_button.h"
#include "ui/message_center/views/proportional_image_view.h"
#include "ui/strings/grit/ui_strings.h"
+#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/label_button.h"
@@ -49,6 +50,8 @@ constexpr gfx::Insets kContentRowPadding(4, 12, 12, 12);
constexpr gfx::Insets kActionsRowPadding(8, 8, 8, 8);
constexpr int kActionsRowHorizontalSpacing = 8;
constexpr gfx::Insets kImageContainerPadding(0, 12, 12, 12);
+constexpr gfx::Insets kActionButtonPadding(0, 12, 0, 12);
+constexpr gfx::Size kActionButtonMinSize(88, 32);
// Foreground of small icon image.
constexpr SkColor kSmallImageBackgroundColor = SK_ColorWHITE;
@@ -56,6 +59,14 @@ constexpr SkColor kSmallImageBackgroundColor = SK_ColorWHITE;
const SkColor kSmallImageColor = SkColorSetRGB(0x43, 0x43, 0x43);
// Background of inline actions area.
const SkColor kActionsRowBackgroundColor = SkColorSetRGB(0xee, 0xee, 0xee);
+// Base ink drop color of action buttons.
+const SkColor kActionButtonInkDropBaseColor = SkColorSetRGB(0x0, 0x0, 0x0);
+// Ripple ink drop opacity of action buttons.
+const float kActionButtonInkDropRippleVisibleOpacity = 0.08f;
+// Highlight (hover) ink drop opacity of action buttons.
+const float kActionButtonInkDropHighlightVisibleOpacity = 0.08f;
+// Text color of action button.
+const SkColor kActionButtonTextColor = SkColorSetRGB(0x33, 0x67, 0xD6);
// Max number of lines for message_view_.
constexpr int kMaxLinesForMessageView = 1;
@@ -261,6 +272,46 @@ void CompactTitleMessageView::OnPaint(gfx::Canvas* canvas) {
views::View::OnPaint(canvas);
}
+// NotificationButtonMD ////////////////////////////////////////////////////////
+
+// This class is needed in addition to LabelButton mainly becuase we want to set
+// visible_opacity of InkDropHighlight.
+class NotificationButtonMD : public views::LabelButton {
+ public:
+ NotificationButtonMD(views::ButtonListener* listener,
+ const base::string16& text);
+ ~NotificationButtonMD() override;
+
+ std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
+ const override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NotificationButtonMD);
+};
+
+NotificationButtonMD::NotificationButtonMD(views::ButtonListener* listener,
+ const base::string16& text)
+ : views::LabelButton(listener, text, views::style::CONTEXT_BUTTON_MD) {
+ SetInkDropMode(views::LabelButton::InkDropMode::ON);
+ set_has_ink_drop_action_on_click(true);
+ set_ink_drop_base_color(kActionButtonInkDropBaseColor);
+ set_ink_drop_visible_opacity(kActionButtonInkDropRippleVisibleOpacity);
+ SetEnabledTextColors(kActionButtonTextColor);
+ SetBorder(views::CreateEmptyBorder(kActionButtonPadding));
+ SetMinSize(kActionButtonMinSize);
+ SetFocusForPlatform();
+}
+
+NotificationButtonMD::~NotificationButtonMD() = default;
+
+std::unique_ptr<views::InkDropHighlight>
+NotificationButtonMD::CreateInkDropHighlight() const {
+ std::unique_ptr<views::InkDropHighlight> highlight =
+ views::LabelButton::CreateInkDropHighlight();
+ highlight->set_visible_opacity(kActionButtonInkDropHighlightVisibleOpacity);
+ return highlight;
+}
+
} // anonymous namespace
// ////////////////////////////////////////////////////////////
@@ -677,9 +728,8 @@ void NotificationViewMD::CreateOrUpdateActionButtonViews(
for (size_t i = 0; i < buttons.size(); ++i) {
ButtonInfo button_info = buttons[i];
if (new_buttons) {
- views::LabelButton* button = new views::LabelButton(
- this, button_info.title, views::style::CONTEXT_BUTTON_MD);
- button->SetFocusForPlatform();
+ NotificationButtonMD* button =
+ new NotificationButtonMD(this, button_info.title);
action_buttons_.push_back(button);
actions_row_->AddChildView(button);
} else {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698