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

Side by Side Diff: ui/views/controls/button/vector_icon_button.cc

Issue 2305933002: Update dialog close buttons to use vector icons and ripples. (Closed)
Patch Set: always good to compile Created 4 years, 3 months 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
OLDNEW
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 "ui/views/controls/button/vector_icon_button.h"
6 6
7 #include "ui/base/material_design/material_design_controller.h" 7 #include "ui/base/material_design/material_design_controller.h"
8 #include "ui/gfx/color_palette.h"
8 #include "ui/gfx/color_utils.h" 9 #include "ui/gfx/color_utils.h"
9 #include "ui/gfx/paint_vector_icon.h" 10 #include "ui/gfx/paint_vector_icon.h"
10 #include "ui/gfx/vector_icons_public.h" 11 #include "ui/gfx/vector_icons_public.h"
11 #include "ui/views/border.h" 12 #include "ui/views/border.h"
13 #include "ui/views/controls/button/vector_icon_button_delegate.h"
12 #include "ui/views/painter.h" 14 #include "ui/views/painter.h"
13 15
16 namespace views {
17
14 namespace { 18 namespace {
15 19
16 // Extra space around the buttons to increase their event target size. 20 // Extra space around the buttons to increase their event target size.
17 const int kButtonExtraTouchSize = 4; 21 const int kButtonExtraTouchSize = 4;
18 22
19 } // namespace 23 } // namespace
20 24
21 BarControlButton::BarControlButton(views::ButtonListener* listener) 25 VectorIconButton::VectorIconButton(VectorIconButtonDelegate* delegate)
22 : views::ImageButton(listener), id_(gfx::VectorIconId::VECTOR_ICON_NONE) { 26 : views::ImageButton(delegate),
27 delegate_(delegate),
28 id_(gfx::VectorIconId::VECTOR_ICON_NONE) {
23 if (ui::MaterialDesignController::IsModeMaterial()) 29 if (ui::MaterialDesignController::IsModeMaterial())
24 SetInkDropMode(InkDropMode::ON); 30 SetInkDropMode(InkDropMode::ON);
25 set_has_ink_drop_action_on_click(true); 31 set_has_ink_drop_action_on_click(true);
26 SetImageAlignment(views::ImageButton::ALIGN_CENTER, 32 SetImageAlignment(views::ImageButton::ALIGN_CENTER,
27 views::ImageButton::ALIGN_MIDDLE); 33 views::ImageButton::ALIGN_MIDDLE);
28 SetFocusPainter(nullptr); 34 SetFocusPainter(nullptr);
29 } 35 }
30 36
31 BarControlButton::~BarControlButton() {} 37 VectorIconButton::~VectorIconButton() {}
32 38
33 void BarControlButton::SetIcon( 39 void VectorIconButton::SetIcon(gfx::VectorIconId id) {
34 gfx::VectorIconId id,
35 const base::Callback<SkColor(void)>& get_text_color_callback) {
36 id_ = id; 40 id_ = id;
37 get_text_color_callback_ = get_text_color_callback;
38 41
39 if (!border()) { 42 if (!border()) {
40 SetBorder(views::Border::CreateEmptyBorder( 43 SetBorder(views::Border::CreateEmptyBorder(
41 kButtonExtraTouchSize, kButtonExtraTouchSize, kButtonExtraTouchSize, 44 kButtonExtraTouchSize, kButtonExtraTouchSize, kButtonExtraTouchSize,
42 kButtonExtraTouchSize)); 45 kButtonExtraTouchSize));
43 } 46 }
44 } 47 }
45 48
46 void BarControlButton::OnThemeChanged() { 49 void VectorIconButton::OnEnabledChanged() {
50 OnThemeChanged();
51 }
52
53 void VectorIconButton::OnThemeChanged() {
47 SkColor icon_color = 54 SkColor icon_color =
48 color_utils::DeriveDefaultIconColor(get_text_color_callback_.Run()); 55 color_utils::DeriveDefaultIconColor(delegate_->GetVectorIconBaseColor());
49 gfx::ImageSkia image = gfx::CreateVectorIcon(id_, icon_color); 56 gfx::ImageSkia image = gfx::CreateVectorIcon(id_, icon_color);
50 SetImage(views::CustomButton::STATE_NORMAL, &image); 57 SetImage(views::CustomButton::STATE_NORMAL, &image);
51 image = gfx::CreateVectorIcon(id_, SkColorSetA(icon_color, 0xff / 2)); 58 image = gfx::CreateVectorIcon(id_, SkColorSetA(icon_color, 0xff / 2));
52 SetImage(views::CustomButton::STATE_DISABLED, &image); 59 SetImage(views::CustomButton::STATE_DISABLED, &image);
53 set_ink_drop_base_color(icon_color); 60 set_ink_drop_base_color(icon_color);
54 } 61 }
55 62
56 void BarControlButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { 63 void VectorIconButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
57 OnThemeChanged(); 64 OnThemeChanged();
58 } 65 }
66
67 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/vector_icon_button.h ('k') | ui/views/controls/button/vector_icon_button_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698