| 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 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 explicitly_set_colors_(), | 92 explicitly_set_colors_(), |
| 93 is_default_(false), | 93 is_default_(false), |
| 94 style_(STYLE_TEXTBUTTON), | 94 style_(STYLE_TEXTBUTTON), |
| 95 border_is_themed_border_(true), | 95 border_is_themed_border_(true), |
| 96 image_label_spacing_(kSpacing), | 96 image_label_spacing_(kSpacing), |
| 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(true); | 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_); |
| 107 image_->set_interactive(false); | 107 image_->set_interactive(false); |
| 108 | 108 |
| 109 AddChildView(label_); | 109 AddChildView(label_); |
| 110 label_->SetFontList(cached_normal_font_list_); | 110 label_->SetFontList(cached_normal_font_list_); |
| 111 label_->SetAutoColorReadabilityEnabled(false); | 111 label_->SetAutoColorReadabilityEnabled(false); |
| 112 label_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); | 112 label_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 UpdateThemedBorder(); | 416 UpdateThemedBorder(); |
| 417 ResetLabelEnabledColor(); | 417 ResetLabelEnabledColor(); |
| 418 // Invalidate the layout to pickup the new insets from the border. | 418 // Invalidate the layout to pickup the new insets from the border. |
| 419 InvalidateLayout(); | 419 InvalidateLayout(); |
| 420 // The entire button has to be repainted here, since the native theme can | 420 // The entire button has to be repainted here, since the native theme can |
| 421 // define the tint for the entire background/border/focus ring. | 421 // define the tint for the entire background/border/focus ring. |
| 422 SchedulePaint(); | 422 SchedulePaint(); |
| 423 } | 423 } |
| 424 | 424 |
| 425 void LabelButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 425 void LabelButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 426 image()->SetPaintToLayer(true); | 426 image()->SetPaintToLayer(); |
| 427 image()->layer()->SetFillsBoundsOpaquely(false); | 427 image()->layer()->SetFillsBoundsOpaquely(false); |
| 428 ink_drop_container_->AddInkDropLayer(ink_drop_layer); | 428 ink_drop_container_->AddInkDropLayer(ink_drop_layer); |
| 429 } | 429 } |
| 430 | 430 |
| 431 void LabelButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 431 void LabelButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 432 image()->SetPaintToLayer(false); | 432 image()->DetachLayer(); |
| 433 ink_drop_container_->RemoveInkDropLayer(ink_drop_layer); | 433 ink_drop_container_->RemoveInkDropLayer(ink_drop_layer); |
| 434 } | 434 } |
| 435 | 435 |
| 436 std::unique_ptr<InkDrop> LabelButton::CreateInkDrop() { | 436 std::unique_ptr<InkDrop> LabelButton::CreateInkDrop() { |
| 437 return UseFloodFillInkDrop() ? CreateDefaultFloodFillInkDropImpl() | 437 return UseFloodFillInkDrop() ? CreateDefaultFloodFillInkDropImpl() |
| 438 : CustomButton::CreateInkDrop(); | 438 : CustomButton::CreateInkDrop(); |
| 439 } | 439 } |
| 440 | 440 |
| 441 std::unique_ptr<views::InkDropRipple> LabelButton::CreateInkDropRipple() const { | 441 std::unique_ptr<views::InkDropRipple> LabelButton::CreateInkDropRipple() const { |
| 442 return UseFloodFillInkDrop() | 442 return UseFloodFillInkDrop() |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |