| OLD | NEW |
| 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/layout/layout_constants.h" |
| 29 #include "ui/views/layout/layout_provider.h" |
| 29 #include "ui/views/painter.h" | 30 #include "ui/views/painter.h" |
| 30 #include "ui/views/style/platform_style.h" | 31 #include "ui/views/style/platform_style.h" |
| 31 #include "ui/views/views_delegate.h" | |
| 32 #include "ui/views/window/dialog_delegate.h" | 32 #include "ui/views/window/dialog_delegate.h" |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 gfx::Font::Weight GetValueBolderThan(gfx::Font::Weight weight) { | 36 gfx::Font::Weight GetValueBolderThan(gfx::Font::Weight weight) { |
| 37 if (weight < gfx::Font::Weight::BOLD) | 37 if (weight < gfx::Font::Weight::BOLD) |
| 38 return gfx::Font::Weight::BOLD; | 38 return gfx::Font::Weight::BOLD; |
| 39 switch (weight) { | 39 switch (weight) { |
| 40 case gfx::Font::Weight::BOLD: | 40 case gfx::Font::Weight::BOLD: |
| 41 return gfx::Font::Weight::EXTRA_BOLD; | 41 return gfx::Font::Weight::EXTRA_BOLD; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 label_(new Label()), | 85 label_(new Label()), |
| 86 ink_drop_container_(new InkDropContainerView()), | 86 ink_drop_container_(new InkDropContainerView()), |
| 87 cached_normal_font_list_(GetDefaultNormalFontList()), | 87 cached_normal_font_list_(GetDefaultNormalFontList()), |
| 88 cached_bold_font_list_(GetDefaultBoldFontList()), | 88 cached_bold_font_list_(GetDefaultBoldFontList()), |
| 89 button_state_images_(), | 89 button_state_images_(), |
| 90 button_state_colors_(), | 90 button_state_colors_(), |
| 91 explicitly_set_colors_(), | 91 explicitly_set_colors_(), |
| 92 is_default_(false), | 92 is_default_(false), |
| 93 style_(STYLE_TEXTBUTTON), | 93 style_(STYLE_TEXTBUTTON), |
| 94 border_is_themed_border_(true), | 94 border_is_themed_border_(true), |
| 95 image_label_spacing_(ViewsDelegate::GetInstance()->GetDistanceMetric( | 95 image_label_spacing_(LayoutProvider::Get()->GetDistanceMetric( |
| 96 DistanceMetric::RELATED_CONTROL_HORIZONTAL)), | 96 DISTANCE_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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 : PlatformStyle::TextColorForButton(button_state_colors_, *this); | 601 : PlatformStyle::TextColorForButton(button_state_colors_, *this); |
| 602 if (state() != STATE_DISABLED && label_->enabled_color() != color) | 602 if (state() != STATE_DISABLED && label_->enabled_color() != color) |
| 603 label_->SetEnabledColor(color); | 603 label_->SetEnabledColor(color); |
| 604 } | 604 } |
| 605 | 605 |
| 606 bool LabelButton::UseFloodFillInkDrop() const { | 606 bool LabelButton::UseFloodFillInkDrop() const { |
| 607 return !GetText().empty(); | 607 return !GetText().empty(); |
| 608 } | 608 } |
| 609 | 609 |
| 610 } // namespace views | 610 } // namespace views |
| OLD | NEW |