OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/ui/views/bar_control_button.h" | 5 #include "chrome/browser/ui/views/bar_control_button.h" |
6 | 6 |
7 #include "ui/gfx/color_utils.h" | 7 #include "ui/gfx/color_utils.h" |
8 #include "ui/gfx/paint_vector_icon.h" | 8 #include "ui/gfx/paint_vector_icon.h" |
9 #include "ui/gfx/vector_icons_public.h" | 9 #include "ui/gfx/vector_icons_public.h" |
10 #include "ui/views/animation/ink_drop_animation_controller.h" | 10 #include "ui/views/animation/ink_drop_animation_controller.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 SetImage(views::CustomButton::STATE_DISABLED, &image); | 59 SetImage(views::CustomButton::STATE_DISABLED, &image); |
60 } | 60 } |
61 | 61 |
62 void BarControlButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 62 void BarControlButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
63 OnThemeChanged(); | 63 OnThemeChanged(); |
64 } | 64 } |
65 | 65 |
66 void BarControlButton::Layout() { | 66 void BarControlButton::Layout() { |
67 ImageButton::Layout(); | 67 ImageButton::Layout(); |
68 | 68 |
69 ink_drop_animation_controller_->SetInkDropCenter( | 69 ink_drop_animation_controller_->SetInkDropCenter(CalculateInkDropCenter()); |
70 GetLocalBounds().CenterPoint()); | |
71 } | 70 } |
72 | 71 |
73 void BarControlButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 72 void BarControlButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
74 // TODO(estade|tdanderson): The ink drop layer should be positioned behind | 73 // TODO(estade|tdanderson): The ink drop layer should be positioned behind |
75 // the button's image. | 74 // the button's image. |
76 SetPaintToLayer(true); | 75 SetPaintToLayer(true); |
77 SetFillsBoundsOpaquely(false); | 76 SetFillsBoundsOpaquely(false); |
78 layer()->Add(ink_drop_layer); | 77 layer()->Add(ink_drop_layer); |
79 layer()->StackAtBottom(ink_drop_layer); | 78 layer()->StackAtBottom(ink_drop_layer); |
80 } | 79 } |
81 | 80 |
82 void BarControlButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 81 void BarControlButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
83 layer()->Remove(ink_drop_layer); | 82 layer()->Remove(ink_drop_layer); |
84 SetFillsBoundsOpaquely(true); | 83 SetFillsBoundsOpaquely(true); |
85 SetPaintToLayer(false); | 84 SetPaintToLayer(false); |
86 } | 85 } |
87 | 86 |
| 87 gfx::Point BarControlButton::CalculateInkDropCenter() const { |
| 88 return GetLocalBounds().CenterPoint(); |
| 89 } |
| 90 |
88 bool BarControlButton::OnMousePressed(const ui::MouseEvent& event) { | 91 bool BarControlButton::OnMousePressed(const ui::MouseEvent& event) { |
89 if (IsTriggerableEvent(event)) { | 92 if (IsTriggerableEvent(event)) { |
90 ink_drop_animation_controller_->AnimateToState( | 93 ink_drop_animation_controller_->AnimateToState( |
91 views::InkDropState::ACTION_PENDING); | 94 views::InkDropState::ACTION_PENDING); |
92 } | 95 } |
93 | 96 |
94 return ImageButton::OnMousePressed(event); | 97 return ImageButton::OnMousePressed(event); |
95 } | 98 } |
96 | 99 |
97 void BarControlButton::OnGestureEvent(ui::GestureEvent* event) { | 100 void BarControlButton::OnGestureEvent(ui::GestureEvent* event) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 133 |
131 ImageButton::OnMouseReleased(event); | 134 ImageButton::OnMouseReleased(event); |
132 } | 135 } |
133 | 136 |
134 void BarControlButton::NotifyClick(const ui::Event& event) { | 137 void BarControlButton::NotifyClick(const ui::Event& event) { |
135 ink_drop_animation_controller_->AnimateToState( | 138 ink_drop_animation_controller_->AnimateToState( |
136 views::InkDropState::QUICK_ACTION); | 139 views::InkDropState::QUICK_ACTION); |
137 | 140 |
138 ImageButton::NotifyClick(event); | 141 ImageButton::NotifyClick(event); |
139 } | 142 } |
OLD | NEW |