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

Side by Side Diff: ash/common/system/tray/actionable_view.cc

Issue 2457393006: [ash-md] Added ink drop to system menu rows that inherit from ActionableView. (Closed)
Patch Set: Fixed the failing test: 'SpokenFeedbackTest.NavigateSystemTray' Created 4 years, 1 month 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 | « ash/common/system/tray/actionable_view.h ('k') | ash/common/system/tray/tray_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "ash/common/system/tray/actionable_view.h" 5 #include "ash/common/system/tray/actionable_view.h"
6 6
7 #include "ash/common/ash_constants.h" 7 #include "ash/common/ash_constants.h"
8 #include "ash/common/system/tray/system_tray.h" 8 #include "ash/common/system/tray/system_tray.h"
9 #include "ash/common/system/tray/system_tray_item.h" 9 #include "ash/common/system/tray/system_tray_item.h"
10 #include "ash/common/system/tray/tray_constants.h" 10 #include "ash/common/system/tray/tray_constants.h"
11 #include "ui/accessibility/ax_view_state.h" 11 #include "ui/accessibility/ax_view_state.h"
12 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/geometry/rect_f.h"
13 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" 14 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
14 #include "ui/views/animation/ink_drop_highlight.h" 15 #include "ui/views/animation/ink_drop_highlight.h"
15 16
16 namespace ash { 17 namespace ash {
17 18
18 // static 19 // static
19 const char ActionableView::kViewClassName[] = "tray/ActionableView"; 20 const char ActionableView::kViewClassName[] = "tray/ActionableView";
20 21
21 ActionableView::ActionableView(SystemTrayItem* owner) 22 ActionableView::ActionableView(SystemTrayItem* owner)
22 : views::CustomButton(this), destroyed_(nullptr), owner_(owner) { 23 : views::CustomButton(this), destroyed_(nullptr), owner_(owner) {
23 SetFocusBehavior(FocusBehavior::ALWAYS); 24 SetFocusBehavior(FocusBehavior::ALWAYS);
24 set_has_ink_drop_action_on_click(false); 25 set_has_ink_drop_action_on_click(false);
26 set_notify_enter_exit_on_child(true);
25 } 27 }
26 28
27 ActionableView::~ActionableView() { 29 ActionableView::~ActionableView() {
28 if (destroyed_) 30 if (destroyed_)
29 *destroyed_ = true; 31 *destroyed_ = true;
30 } 32 }
31 33
32 void ActionableView::OnPaintFocus(gfx::Canvas* canvas) { 34 void ActionableView::OnPaintFocus(gfx::Canvas* canvas) {
33 gfx::Rect rect(GetFocusBounds()); 35 gfx::Rect rect(GetFocusBounds());
34 rect.Inset(1, 1, 3, 2); 36 rect.Inset(1, 1, 3, 2);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // We render differently when focused. 73 // We render differently when focused.
72 SchedulePaint(); 74 SchedulePaint();
73 } 75 }
74 76
75 void ActionableView::OnBlur() { 77 void ActionableView::OnBlur() {
76 CustomButton::OnBlur(); 78 CustomButton::OnBlur();
77 // We render differently when focused. 79 // We render differently when focused.
78 SchedulePaint(); 80 SchedulePaint();
79 } 81 }
80 82
83 std::unique_ptr<views::InkDropRipple> ActionableView::CreateInkDropRipple()
84 const {
85 return base::MakeUnique<views::FloodFillInkDropRipple>(
86 GetLocalBounds(), GetInkDropCenterBasedOnLastEvent(),
87 kTrayPopupInkDropBaseColor, kTrayPopupInkDropRippleOpacity);
88 }
89
90 std::unique_ptr<views::InkDropHighlight>
91 ActionableView::CreateInkDropHighlight() const {
92 std::unique_ptr<views::InkDropHighlight> highlight(
93 new views::InkDropHighlight(size(), 0,
94 gfx::RectF(GetLocalBounds()).CenterPoint(),
95 kTrayPopupInkDropBaseColor));
96 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity);
97 return highlight;
98 }
99
81 void ActionableView::CloseSystemBubble() { 100 void ActionableView::CloseSystemBubble() {
82 DCHECK(owner_); 101 DCHECK(owner_);
83 owner_->system_tray()->CloseSystemBubble(); 102 owner_->system_tray()->CloseSystemBubble();
84 } 103 }
85 104
86 void ActionableView::ButtonPressed(Button* sender, const ui::Event& event) { 105 void ActionableView::ButtonPressed(Button* sender, const ui::Event& event) {
87 bool destroyed = false; 106 bool destroyed = false;
88 destroyed_ = &destroyed; 107 destroyed_ = &destroyed;
89 const bool action_performed = PerformAction(event); 108 const bool action_performed = PerformAction(event);
90 if (destroyed) 109 if (destroyed)
91 return; 110 return;
92 destroyed_ = nullptr; 111 destroyed_ = nullptr;
93 112
94 if (action_performed) { 113 if (action_performed) {
95 AnimateInkDrop(views::InkDropState::ACTION_TRIGGERED, 114 AnimateInkDrop(views::InkDropState::ACTION_TRIGGERED,
96 ui::LocatedEvent::FromIfValid(&event)); 115 ui::LocatedEvent::FromIfValid(&event));
97 } else { 116 } else {
98 AnimateInkDrop(views::InkDropState::HIDDEN, 117 AnimateInkDrop(views::InkDropState::HIDDEN,
99 ui::LocatedEvent::FromIfValid(&event)); 118 ui::LocatedEvent::FromIfValid(&event));
100 } 119 }
101 } 120 }
102 121
103 } // namespace ash 122 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/actionable_view.h ('k') | ash/common/system/tray/tray_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698