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

Side by Side Diff: ui/message_center/views/notification_header_view.cc

Issue 2959363002: Add ripple effect to new-style notification header. (Closed)
Patch Set: Rebased. Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « ui/message_center/views/notification_header_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/message_center/views/notification_header_view.h" 5 #include "ui/message_center/views/notification_header_view.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/gfx/color_palette.h" 10 #include "ui/gfx/color_palette.h"
11 #include "ui/gfx/font_list.h" 11 #include "ui/gfx/font_list.h"
12 #include "ui/gfx/paint_vector_icon.h" 12 #include "ui/gfx/paint_vector_icon.h"
13 #include "ui/message_center/message_center_style.h" 13 #include "ui/message_center/message_center_style.h"
14 #include "ui/message_center/vector_icons.h" 14 #include "ui/message_center/vector_icons.h"
15 #include "ui/message_center/views/padded_button.h" 15 #include "ui/message_center/views/padded_button.h"
16 #include "ui/strings/grit/ui_strings.h" 16 #include "ui/strings/grit/ui_strings.h"
17 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
18 #include "ui/views/animation/ink_drop_highlight.h"
19 #include "ui/views/animation/ink_drop_impl.h"
17 #include "ui/views/controls/button/image_button.h" 20 #include "ui/views/controls/button/image_button.h"
18 #include "ui/views/controls/image_view.h" 21 #include "ui/views/controls/image_view.h"
19 #include "ui/views/controls/label.h" 22 #include "ui/views/controls/label.h"
20 #include "ui/views/layout/box_layout.h" 23 #include "ui/views/layout/box_layout.h"
21 #include "ui/views/painter.h" 24 #include "ui/views/painter.h"
22 25
23 namespace message_center { 26 namespace message_center {
24 27
25 namespace { 28 namespace {
26 29
27 constexpr int kHeaderHeight = 28; 30 constexpr int kHeaderHeight = 28;
28 constexpr int kAppIconSize = 12; 31 constexpr int kAppIconSize = 12;
29 constexpr int kExpandIconSize = 12; 32 constexpr int kExpandIconSize = 12;
30 constexpr gfx::Insets kHeaderPadding(0, 12, 0, 2); 33 constexpr gfx::Insets kHeaderPadding(0, 12, 0, 2);
31 constexpr int kHeaderHorizontalSpacing = 2; 34 constexpr int kHeaderHorizontalSpacing = 2;
32 constexpr int kAppInfoConatainerTopPadding = 12; 35 constexpr int kAppInfoConatainerTopPadding = 12;
33 // Bullet character. The divider symbol between different parts of the header. 36 // Bullet character. The divider symbol between different parts of the header.
34 constexpr base::char16 kNotificationHeaderDividerSymbol = 0x2022; 37 constexpr base::char16 kNotificationHeaderDividerSymbol = 0x2022;
35 38
39 // Base ink drop color of action buttons.
40 const SkColor kInkDropBaseColor = SkColorSetRGB(0x0, 0x0, 0x0);
41 // Ripple ink drop opacity of action buttons.
42 constexpr float kInkDropRippleVisibleOpacity = 0.08f;
43 // Highlight (hover) ink drop opacity of action buttons.
44 constexpr float kInkDropHighlightVisibleOpacity = 0.08f;
45
36 } // namespace 46 } // namespace
37 47
38 NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener) 48 NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener)
39 : views::CustomButton(listener) { 49 : views::CustomButton(listener) {
50 SetInkDropMode(InkDropMode::ON);
51 set_has_ink_drop_action_on_click(true);
52 set_animate_on_state_change(true);
53 set_notify_enter_exit_on_child(true);
54 set_ink_drop_base_color(kInkDropBaseColor);
55 set_ink_drop_visible_opacity(kInkDropRippleVisibleOpacity);
56
40 views::BoxLayout* layout = new views::BoxLayout( 57 views::BoxLayout* layout = new views::BoxLayout(
41 views::BoxLayout::kHorizontal, kHeaderPadding, kHeaderHorizontalSpacing); 58 views::BoxLayout::kHorizontal, kHeaderPadding, kHeaderHorizontalSpacing);
42 layout->set_cross_axis_alignment( 59 layout->set_cross_axis_alignment(
43 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 60 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
44 SetLayoutManager(layout); 61 SetLayoutManager(layout);
45 62
46 views::View* app_info_container = new views::View(); 63 views::View* app_info_container = new views::View();
47 views::BoxLayout* app_info_layout = 64 views::BoxLayout* app_info_layout =
48 new views::BoxLayout(views::BoxLayout::kHorizontal, 65 new views::BoxLayout(views::BoxLayout::kHorizontal,
49 gfx::Insets(kAppInfoConatainerTopPadding, 0, 0, 0), 66 gfx::Insets(kAppInfoConatainerTopPadding, 0, 0, 0),
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 194 }
178 195
179 bool NotificationHeaderView::IsSettingsButtonEnabled() { 196 bool NotificationHeaderView::IsSettingsButtonEnabled() {
180 return settings_button_enabled_; 197 return settings_button_enabled_;
181 } 198 }
182 199
183 bool NotificationHeaderView::IsCloseButtonEnabled() { 200 bool NotificationHeaderView::IsCloseButtonEnabled() {
184 return close_button_enabled_; 201 return close_button_enabled_;
185 } 202 }
186 203
204 std::unique_ptr<views::InkDrop> NotificationHeaderView::CreateInkDrop() {
205 auto ink_drop = base::MakeUnique<views::InkDropImpl>(this, size());
206 ink_drop->SetAutoHighlightMode(
207 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE);
208 ink_drop->SetShowHighlightOnHover(false);
209 return ink_drop;
210 }
211
212 std::unique_ptr<views::InkDropRipple>
213 NotificationHeaderView::CreateInkDropRipple() const {
214 return base::MakeUnique<views::FloodFillInkDropRipple>(
215 size(), GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(),
216 ink_drop_visible_opacity());
217 }
218
219 std::unique_ptr<views::InkDropHighlight>
220 NotificationHeaderView::CreateInkDropHighlight() const {
221 auto highlight = base::MakeUnique<views::InkDropHighlight>(
222 size(), kInkDropSmallCornerRadius,
223 gfx::RectF(GetLocalBounds()).CenterPoint(), GetInkDropBaseColor());
224 highlight->set_visible_opacity(kInkDropHighlightVisibleOpacity);
225 return highlight;
226 }
227
187 void NotificationHeaderView::UpdateControlButtonsVisibility() { 228 void NotificationHeaderView::UpdateControlButtonsVisibility() {
188 settings_button_->SetVisible(settings_button_enabled_ && 229 settings_button_->SetVisible(settings_button_enabled_ &&
189 is_control_buttons_visible_); 230 is_control_buttons_visible_);
190 close_button_->SetVisible(close_button_enabled_ && 231 close_button_->SetVisible(close_button_enabled_ &&
191 is_control_buttons_visible_); 232 is_control_buttons_visible_);
192 Layout(); 233 Layout();
193 } 234 }
194 235
195 void NotificationHeaderView::UpdateSummaryTextVisibility() { 236 void NotificationHeaderView::UpdateSummaryTextVisibility() {
196 summary_text_divider_->SetVisible(has_summary_text_); 237 summary_text_divider_->SetVisible(has_summary_text_);
197 summary_text_view_->SetVisible(has_summary_text_); 238 summary_text_view_->SetVisible(has_summary_text_);
198 Layout(); 239 Layout();
199 } 240 }
200 241
201 } // namespace message_center 242 } // namespace message_center
OLDNEW
« 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