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/base/material_design/material_design_controller.h" | 15 #include "ui/base/material_design/material_design_controller.h" |
16 #include "ui/gfx/animation/throb_animation.h" | 16 #include "ui/gfx/animation/throb_animation.h" |
17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
18 #include "ui/gfx/color_utils.h" | 18 #include "ui/gfx/color_utils.h" |
19 #include "ui/gfx/font_list.h" | 19 #include "ui/gfx/font_list.h" |
20 #include "ui/gfx/geometry/vector2d.h" | 20 #include "ui/gfx/geometry/vector2d.h" |
21 #include "ui/native_theme/native_theme.h" | 21 #include "ui/native_theme/native_theme.h" |
22 #include "ui/views/accessibility/native_view_accessibility.h" | |
22 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 23 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
23 #include "ui/views/animation/ink_drop_highlight.h" | 24 #include "ui/views/animation/ink_drop_highlight.h" |
24 #include "ui/views/animation/square_ink_drop_ripple.h" | 25 #include "ui/views/animation/square_ink_drop_ripple.h" |
25 #include "ui/views/background.h" | 26 #include "ui/views/background.h" |
26 #include "ui/views/controls/button/label_button_border.h" | 27 #include "ui/views/controls/button/label_button_border.h" |
27 #include "ui/views/painter.h" | 28 #include "ui/views/painter.h" |
28 #include "ui/views/style/platform_style.h" | 29 #include "ui/views/style/platform_style.h" |
29 #include "ui/views/window/dialog_delegate.h" | 30 #include "ui/views/window/dialog_delegate.h" |
30 | 31 |
31 namespace { | 32 namespace { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 image_->set_interactive(false); | 123 image_->set_interactive(false); |
123 | 124 |
124 AddChildView(label_); | 125 AddChildView(label_); |
125 label_->SetFontList(cached_normal_font_list_); | 126 label_->SetFontList(cached_normal_font_list_); |
126 label_->SetAutoColorReadabilityEnabled(false); | 127 label_->SetAutoColorReadabilityEnabled(false); |
127 label_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); | 128 label_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); |
128 | 129 |
129 // Inset the button focus rect from the actual border; roughly match Windows. | 130 // Inset the button focus rect from the actual border; roughly match Windows. |
130 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets(gfx::Insets( | 131 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets(gfx::Insets( |
131 kFocusRectInset, kFocusRectInset, kFocusRectInset, kFocusRectInset))); | 132 kFocusRectInset, kFocusRectInset, kFocusRectInset, kFocusRectInset))); |
133 | |
134 // Label buttons should be treated as a single accessibility button element. | |
135 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | |
tapted
2016/07/12 01:44:23
The goal would be to make these lines unnecessary.
Patti Lor
2016/11/25 03:59:28
Oh, you're right, this seems to already be the cas
| |
136 for (int i = 0; i < child_count(); ++i) | |
137 child_at(i)->SetFocusBehavior(FocusBehavior::NEVER); | |
132 } | 138 } |
133 | 139 |
134 LabelButton::~LabelButton() {} | 140 LabelButton::~LabelButton() {} |
135 | 141 |
136 gfx::ImageSkia LabelButton::GetImage(ButtonState for_state) const { | 142 gfx::ImageSkia LabelButton::GetImage(ButtonState for_state) const { |
137 if (for_state != STATE_NORMAL && button_state_images_[for_state].isNull()) | 143 if (for_state != STATE_NORMAL && button_state_images_[for_state].isNull()) |
138 return button_state_images_[STATE_NORMAL]; | 144 return button_state_images_[STATE_NORMAL]; |
139 return button_state_images_[for_state]; | 145 return button_state_images_[for_state]; |
140 } | 146 } |
141 | 147 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
588 void LabelButton::ResetLabelEnabledColor() { | 594 void LabelButton::ResetLabelEnabledColor() { |
589 const SkColor color = | 595 const SkColor color = |
590 explicitly_set_colors_[state()] | 596 explicitly_set_colors_[state()] |
591 ? button_state_colors_[state()] | 597 ? button_state_colors_[state()] |
592 : PlatformStyle::TextColorForButton(button_state_colors_, *this); | 598 : PlatformStyle::TextColorForButton(button_state_colors_, *this); |
593 if (state() != STATE_DISABLED && label_->enabled_color() != color) | 599 if (state() != STATE_DISABLED && label_->enabled_color() != color) |
594 label_->SetEnabledColor(color); | 600 label_->SetEnabledColor(color); |
595 } | 601 } |
596 | 602 |
597 } // namespace views | 603 } // namespace views |
OLD | NEW |