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

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

Issue 2959363002: Add ripple effect to new-style notification header. (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
Index: ui/message_center/views/notification_header_view.cc
diff --git a/ui/message_center/views/notification_header_view.cc b/ui/message_center/views/notification_header_view.cc
index 97cdd3615e5f54a81311eeb736c30e2a68671d70..4df158da4b6b6ddbf0bf0895d238c699a6d2871f 100644
--- a/ui/message_center/views/notification_header_view.cc
+++ b/ui/message_center/views/notification_header_view.cc
@@ -12,6 +12,9 @@
#include "ui/message_center/vector_icons.h"
#include "ui/message_center/views/padded_button.h"
#include "ui/strings/grit/ui_strings.h"
+#include "ui/views/animation/flood_fill_ink_drop_ripple.h"
+#include "ui/views/animation/ink_drop_highlight.h"
+#include "ui/views/animation/ink_drop_impl.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
@@ -29,10 +32,25 @@ constexpr gfx::Insets kHeaderPadding(0, 12, 0, 2);
constexpr int kHeaderHorizontalSpacing = 2;
constexpr int kAppInfoConatainerTopPadding = 12;
+// Base ink drop color of action buttons.
+const SkColor kInkDropBaseColor = SkColorSetRGB(0x0, 0x0, 0x0);
+// Ripple ink drop opacity of action buttons.
+const float kInkDropRippleVisibleOpacity = 0.08f;
yoshiki 2017/06/29 08:09:06 nit: constexpr
tetsui 2017/06/29 11:35:52 Done.
+// Highlight (hover) ink drop opacity of action buttons.
+const float kInkDropHighlightVisibleOpacity = 0.08f;
yoshiki 2017/06/29 08:09:06 ditto
tetsui 2017/06/29 11:35:52 Done.
+
} // namespace
NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener)
: views::CustomButton(listener) {
+ SetFocusBehavior(FocusBehavior::ALWAYS);
+ SetInkDropMode(InkDropMode::ON);
+ set_has_ink_drop_action_on_click(true);
+ set_animate_on_state_change(true);
+ set_notify_enter_exit_on_child(true);
+ set_ink_drop_base_color(kInkDropBaseColor);
+ set_ink_drop_visible_opacity(kInkDropRippleVisibleOpacity);
+
views::BoxLayout* layout = new views::BoxLayout(
views::BoxLayout::kHorizontal, kHeaderPadding, kHeaderHorizontalSpacing);
layout->set_cross_axis_alignment(
@@ -151,6 +169,32 @@ bool NotificationHeaderView::IsCloseButtonEnabled() {
return close_button_enabled_;
}
+std::unique_ptr<views::InkDrop> NotificationHeaderView::CreateInkDrop() {
+ std::unique_ptr<views::InkDropImpl> ink_drop =
yoshiki 2017/06/29 08:09:06 optional nit: You can use "auto" for remove the re
tetsui 2017/06/29 11:35:52 Done.
+ base::MakeUnique<views::InkDropImpl>(this, size());
+ ink_drop->SetAutoHighlightMode(
+ views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE);
+ ink_drop->SetShowHighlightOnHover(false);
+ return ink_drop;
+}
+
+std::unique_ptr<views::InkDropRipple>
+NotificationHeaderView::CreateInkDropRipple() const {
+ return base::MakeUnique<views::FloodFillInkDropRipple>(
+ size(), GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(),
+ ink_drop_visible_opacity());
+}
+
+std::unique_ptr<views::InkDropHighlight>
+NotificationHeaderView::CreateInkDropHighlight() const {
+ std::unique_ptr<views::InkDropHighlight> highlight =
yoshiki 2017/06/29 08:09:06 ditto
tetsui 2017/06/29 11:35:52 Done.
+ base::MakeUnique<views::InkDropHighlight>(
+ size(), kInkDropSmallCornerRadius,
+ gfx::RectF(GetLocalBounds()).CenterPoint(), GetInkDropBaseColor());
+ highlight->set_visible_opacity(kInkDropHighlightVisibleOpacity);
+ return highlight;
+}
+
void NotificationHeaderView::UpdateControlButtonsVisibility() {
settings_button_->SetVisible(settings_button_enabled_ &&
is_control_buttons_visible_);

Powered by Google App Engine
This is Rietveld 408576698