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