| 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" |
| 11 #include "ui/views/border.h" | 11 #include "ui/views/border.h" |
| 12 #include "ui/views/painter.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 // Extra space around the buttons to increase their event target size. | 16 // Extra space around the buttons to increase their event target size. |
| 16 const int kButtonExtraTouchSize = 4; | 17 const int kButtonExtraTouchSize = 4; |
| 17 | 18 |
| 18 } // namespace | 19 } // namespace |
| 19 | 20 |
| 20 BarControlButton::BarControlButton(views::ButtonListener* listener) | 21 BarControlButton::BarControlButton(views::ButtonListener* listener) |
| 21 : views::ImageButton(listener), | 22 : views::ImageButton(listener), |
| 22 id_(gfx::VectorIconId::VECTOR_ICON_NONE), | 23 id_(gfx::VectorIconId::VECTOR_ICON_NONE), |
| 23 ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)) { | 24 ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)) { |
| 24 set_ink_drop_delegate(ink_drop_delegate_.get()); | 25 set_ink_drop_delegate(ink_drop_delegate_.get()); |
| 25 set_has_ink_drop_action_on_click(true); | 26 set_has_ink_drop_action_on_click(true); |
| 26 SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 27 SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
| 27 views::ImageButton::ALIGN_MIDDLE); | 28 views::ImageButton::ALIGN_MIDDLE); |
| 29 SetFocusPainter(nullptr); |
| 30 UseMdFocusRing(); |
| 28 } | 31 } |
| 29 | 32 |
| 30 BarControlButton::~BarControlButton() {} | 33 BarControlButton::~BarControlButton() {} |
| 31 | 34 |
| 32 void BarControlButton::SetIcon( | 35 void BarControlButton::SetIcon( |
| 33 gfx::VectorIconId id, | 36 gfx::VectorIconId id, |
| 34 const base::Callback<SkColor(void)>& get_text_color_callback) { | 37 const base::Callback<SkColor(void)>& get_text_color_callback) { |
| 35 id_ = id; | 38 id_ = id; |
| 36 get_text_color_callback_ = get_text_color_callback; | 39 get_text_color_callback_ = get_text_color_callback; |
| 37 | 40 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 48 gfx::ImageSkia image = gfx::CreateVectorIcon(id_, 16, icon_color); | 51 gfx::ImageSkia image = gfx::CreateVectorIcon(id_, 16, icon_color); |
| 49 SetImage(views::CustomButton::STATE_NORMAL, &image); | 52 SetImage(views::CustomButton::STATE_NORMAL, &image); |
| 50 image = gfx::CreateVectorIcon(id_, 16, SkColorSetA(icon_color, 0xff / 2)); | 53 image = gfx::CreateVectorIcon(id_, 16, SkColorSetA(icon_color, 0xff / 2)); |
| 51 SetImage(views::CustomButton::STATE_DISABLED, &image); | 54 SetImage(views::CustomButton::STATE_DISABLED, &image); |
| 52 set_ink_drop_base_color(icon_color); | 55 set_ink_drop_base_color(icon_color); |
| 53 } | 56 } |
| 54 | 57 |
| 55 void BarControlButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 58 void BarControlButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 56 OnThemeChanged(); | 59 OnThemeChanged(); |
| 57 } | 60 } |
| OLD | NEW |