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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Final feedback addressed Created 3 years, 8 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
« no previous file with comments | « ui/views/bubble/bubble_frame_view.cc ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "ui/views/controls/button/image_button_factory.h" 5 #include "ui/views/controls/button/image_button_factory.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_icon_types.h" 9 #include "ui/gfx/vector_icon_types.h"
10 #include "ui/views/border.h" 10 #include "ui/views/border.h"
11 #include "ui/views/controls/button/custom_button.h" 11 #include "ui/views/controls/button/custom_button.h"
12 #include "ui/views/controls/button/image_button.h" 12 #include "ui/views/controls/button/image_button.h"
13 #include "ui/views/layout/layout_provider.h"
13 #include "ui/views/painter.h" 14 #include "ui/views/painter.h"
14 #include "ui/views/views_delegate.h"
15 15
16 namespace views { 16 namespace views {
17 17
18 ImageButton* CreateVectorImageButton(ButtonListener* listener) { 18 ImageButton* CreateVectorImageButton(ButtonListener* listener) {
19 ImageButton* button = new ImageButton(listener); 19 ImageButton* button = new ImageButton(listener);
20 button->SetInkDropMode(CustomButton::InkDropMode::ON); 20 button->SetInkDropMode(CustomButton::InkDropMode::ON);
21 button->set_has_ink_drop_action_on_click(true); 21 button->set_has_ink_drop_action_on_click(true);
22 button->SetImageAlignment(ImageButton::ALIGN_CENTER, 22 button->SetImageAlignment(ImageButton::ALIGN_CENTER,
23 ImageButton::ALIGN_MIDDLE); 23 ImageButton::ALIGN_MIDDLE);
24 button->SetFocusPainter(nullptr); 24 button->SetFocusPainter(nullptr);
25 button->SetBorder( 25 button->SetBorder(CreateEmptyBorder(
26 CreateEmptyBorder(ViewsDelegate::GetInstance()->GetInsetsMetric( 26 LayoutProvider::Get()->GetInsetsMetric(INSETS_VECTOR_IMAGE_BUTTON)));
27 InsetsMetric::VECTOR_IMAGE_BUTTON_PADDING)));
28 return button; 27 return button;
29 } 28 }
30 29
31 void SetImageFromVectorIcon(ImageButton* button, 30 void SetImageFromVectorIcon(ImageButton* button,
32 const gfx::VectorIcon& icon, 31 const gfx::VectorIcon& icon,
33 SkColor related_text_color) { 32 SkColor related_text_color) {
34 const SkColor icon_color = 33 const SkColor icon_color =
35 color_utils::DeriveDefaultIconColor(related_text_color); 34 color_utils::DeriveDefaultIconColor(related_text_color);
36 const SkColor disabled_color = SkColorSetA(icon_color, 0xff / 2); 35 const SkColor disabled_color = SkColorSetA(icon_color, 0xff / 2);
37 button->SetImage(CustomButton::STATE_NORMAL, 36 button->SetImage(CustomButton::STATE_NORMAL,
38 gfx::CreateVectorIcon(icon, icon_color)); 37 gfx::CreateVectorIcon(icon, icon_color));
39 button->SetImage(CustomButton::STATE_DISABLED, 38 button->SetImage(CustomButton::STATE_DISABLED,
40 gfx::CreateVectorIcon(icon, disabled_color)); 39 gfx::CreateVectorIcon(icon, disabled_color));
41 button->set_ink_drop_base_color(icon_color); 40 button->set_ink_drop_base_color(icon_color);
42 } 41 }
43 42
44 } // views 43 } // views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_frame_view.cc ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698