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

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

Issue 2696263002: Refactor ViewsDelegate and MD-ify the icon-to-text spacing for checkbox and radiobutton (Closed)
Patch Set: Used ifdef instead of duplicated code for delegate initialization Created 3 years, 9 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/md_text_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/label_button.h" 5 #include "ui/views/controls/button/label_button.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "ui/gfx/animation/throb_animation.h" 15 #include "ui/gfx/animation/throb_animation.h"
16 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/color_utils.h" 17 #include "ui/gfx/color_utils.h"
18 #include "ui/gfx/font_list.h" 18 #include "ui/gfx/font_list.h"
19 #include "ui/gfx/geometry/vector2d.h" 19 #include "ui/gfx/geometry/vector2d.h"
20 #include "ui/native_theme/native_theme.h" 20 #include "ui/native_theme/native_theme.h"
21 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" 21 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
22 #include "ui/views/animation/ink_drop.h" 22 #include "ui/views/animation/ink_drop.h"
23 #include "ui/views/animation/ink_drop_highlight.h" 23 #include "ui/views/animation/ink_drop_highlight.h"
24 #include "ui/views/animation/ink_drop_impl.h" 24 #include "ui/views/animation/ink_drop_impl.h"
25 #include "ui/views/animation/square_ink_drop_ripple.h" 25 #include "ui/views/animation/square_ink_drop_ripple.h"
26 #include "ui/views/background.h" 26 #include "ui/views/background.h"
27 #include "ui/views/controls/button/label_button_border.h" 27 #include "ui/views/controls/button/label_button_border.h"
28 #include "ui/views/layout/layout_constants.h"
28 #include "ui/views/painter.h" 29 #include "ui/views/painter.h"
29 #include "ui/views/style/platform_style.h" 30 #include "ui/views/style/platform_style.h"
31 #include "ui/views/views_delegate.h"
30 #include "ui/views/window/dialog_delegate.h" 32 #include "ui/views/window/dialog_delegate.h"
31 33
32 namespace { 34 namespace {
33 35
34 // The default spacing between the icon and text.
35 const int kSpacing = 5;
36
37 gfx::Font::Weight GetValueBolderThan(gfx::Font::Weight weight) { 36 gfx::Font::Weight GetValueBolderThan(gfx::Font::Weight weight) {
38 if (weight < gfx::Font::Weight::BOLD) 37 if (weight < gfx::Font::Weight::BOLD)
39 return gfx::Font::Weight::BOLD; 38 return gfx::Font::Weight::BOLD;
40 switch (weight) { 39 switch (weight) {
41 case gfx::Font::Weight::BOLD: 40 case gfx::Font::Weight::BOLD:
42 return gfx::Font::Weight::EXTRA_BOLD; 41 return gfx::Font::Weight::EXTRA_BOLD;
43 case gfx::Font::Weight::EXTRA_BOLD: 42 case gfx::Font::Weight::EXTRA_BOLD:
44 case gfx::Font::Weight::BLACK: 43 case gfx::Font::Weight::BLACK:
45 return gfx::Font::Weight::BLACK; 44 return gfx::Font::Weight::BLACK;
46 default: 45 default:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 label_(new Label()), 85 label_(new Label()),
87 ink_drop_container_(new InkDropContainerView()), 86 ink_drop_container_(new InkDropContainerView()),
88 cached_normal_font_list_(GetDefaultNormalFontList()), 87 cached_normal_font_list_(GetDefaultNormalFontList()),
89 cached_bold_font_list_(GetDefaultBoldFontList()), 88 cached_bold_font_list_(GetDefaultBoldFontList()),
90 button_state_images_(), 89 button_state_images_(),
91 button_state_colors_(), 90 button_state_colors_(),
92 explicitly_set_colors_(), 91 explicitly_set_colors_(),
93 is_default_(false), 92 is_default_(false),
94 style_(STYLE_TEXTBUTTON), 93 style_(STYLE_TEXTBUTTON),
95 border_is_themed_border_(true), 94 border_is_themed_border_(true),
96 image_label_spacing_(kSpacing), 95 image_label_spacing_(ViewsDelegate::GetInstance()->GetDistanceMetric(
96 DistanceMetric::RELATED_CONTROL_HORIZONTAL)),
97 horizontal_alignment_(gfx::ALIGN_LEFT) { 97 horizontal_alignment_(gfx::ALIGN_LEFT) {
98 SetAnimationDuration(kHoverAnimationDurationMs); 98 SetAnimationDuration(kHoverAnimationDurationMs);
99 SetTextInternal(text); 99 SetTextInternal(text);
100 100
101 AddChildView(ink_drop_container_); 101 AddChildView(ink_drop_container_);
102 ink_drop_container_->SetPaintToLayer(); 102 ink_drop_container_->SetPaintToLayer();
103 ink_drop_container_->layer()->SetFillsBoundsOpaquely(false); 103 ink_drop_container_->layer()->SetFillsBoundsOpaquely(false);
104 ink_drop_container_->SetVisible(false); 104 ink_drop_container_->SetVisible(false);
105 105
106 AddChildView(image_); 106 AddChildView(image_);
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 : PlatformStyle::TextColorForButton(button_state_colors_, *this); 604 : PlatformStyle::TextColorForButton(button_state_colors_, *this);
605 if (state() != STATE_DISABLED && label_->enabled_color() != color) 605 if (state() != STATE_DISABLED && label_->enabled_color() != color)
606 label_->SetEnabledColor(color); 606 label_->SetEnabledColor(color);
607 } 607 }
608 608
609 bool LabelButton::UseFloodFillInkDrop() const { 609 bool LabelButton::UseFloodFillInkDrop() const {
610 return !GetText().empty(); 610 return !GetText().empty();
611 } 611 }
612 612
613 } // namespace views 613 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_frame_view.cc ('k') | ui/views/controls/button/md_text_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698