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

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

Issue 2959363002: Add ripple effect to new-style notification header. (Closed)
Patch Set: 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 | « ui/message_center/views/notification_header_view.h ('k') | 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_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..e469f8694772c1811dab86865915e0a184292894 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;
+// Highlight (hover) ink drop opacity of action buttons.
+const float kInkDropHighlightVisibleOpacity = 0.08f;
+
} // 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() {
+ return InkDropHostView::CreateDefaultFloodFillInkDropImpl();
+}
+
+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 =
+ base::MakeUnique<views::InkDropHighlight>(
+ size(), kInkDropSmallCornerRadius,
+ gfx::RectF(GetLocalBounds()).CenterPoint(), GetInkDropBaseColor());
+ highlight->set_visible_opacity(kInkDropHighlightVisibleOpacity);
+ return highlight;
+}
+
+void NotificationHeaderView::OnMouseEvent(ui::MouseEvent* event) {
+ // Prevent updating SetHovered in InkDropHostView.
+ View::OnMouseEvent(event);
fukino 2017/06/29 04:30:42 This looks hacky (and scary)... In ash system menu
tetsui 2017/06/29 07:49:14 Done.
+}
+
void NotificationHeaderView::UpdateControlButtonsVisibility() {
settings_button_->SetVisible(settings_button_enabled_ &&
is_control_buttons_visible_);
« no previous file with comments | « ui/message_center/views/notification_header_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698