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/button_ink_drop_delegate.h" | 10 #include "ui/views/animation/button_ink_drop_delegate.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 gfx::ImageSkia image = gfx::CreateVectorIcon(id_, 16, icon_color); | 54 gfx::ImageSkia image = gfx::CreateVectorIcon(id_, 16, icon_color); |
55 SetImage(views::CustomButton::STATE_NORMAL, &image); | 55 SetImage(views::CustomButton::STATE_NORMAL, &image); |
56 image = gfx::CreateVectorIcon(id_, 16, SkColorSetA(icon_color, 0xff / 2)); | 56 image = gfx::CreateVectorIcon(id_, 16, SkColorSetA(icon_color, 0xff / 2)); |
57 SetImage(views::CustomButton::STATE_DISABLED, &image); | 57 SetImage(views::CustomButton::STATE_DISABLED, &image); |
58 } | 58 } |
59 | 59 |
60 void BarControlButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 60 void BarControlButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
61 OnThemeChanged(); | 61 OnThemeChanged(); |
62 } | 62 } |
63 | 63 |
64 void BarControlButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { | |
65 // TODO(estade|tdanderson): The ink drop layer should be positioned behind | |
66 // the button's image. | |
67 SetPaintToLayer(true); | |
68 SetFillsBoundsOpaquely(false); | |
69 layer()->Add(ink_drop_layer); | |
70 layer()->StackAtBottom(ink_drop_layer); | |
71 } | |
72 | |
73 void BarControlButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | |
74 layer()->Remove(ink_drop_layer); | |
75 SetFillsBoundsOpaquely(true); | |
76 SetPaintToLayer(false); | |
77 } | |
78 | |
79 gfx::Point BarControlButton::CalculateInkDropCenter() const { | |
80 return GetLocalBounds().CenterPoint(); | |
81 } | |
82 | |
83 bool BarControlButton::OnMousePressed(const ui::MouseEvent& event) { | 64 bool BarControlButton::OnMousePressed(const ui::MouseEvent& event) { |
84 if (IsTriggerableEvent(event)) | 65 if (IsTriggerableEvent(event)) |
85 ink_drop_delegate()->OnAction(views::InkDropState::ACTION_PENDING); | 66 ink_drop_delegate()->OnAction(views::InkDropState::ACTION_PENDING); |
86 | 67 |
87 return ImageButton::OnMousePressed(event); | 68 return ImageButton::OnMousePressed(event); |
88 } | 69 } |
OLD | NEW |