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

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

Issue 2913933002: Move views::Label DisabledColor logic into views::LabelButtonLabel (Closed)
Patch Set: Back to PatchSet 11 Created 3 years, 6 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
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 #ifndef UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_
6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ 6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_
7 7
8 #include <array> 8 #include <array>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/gfx/image/image_skia.h" 15 #include "ui/gfx/image/image_skia.h"
16 #include "ui/views/controls/button/custom_button.h" 16 #include "ui/views/controls/button/custom_button.h"
17 #include "ui/views/controls/image_view.h" 17 #include "ui/views/controls/image_view.h"
18 #include "ui/views/controls/label.h" 18 #include "ui/views/controls/label.h"
19 #include "ui/views/native_theme_delegate.h" 19 #include "ui/views/native_theme_delegate.h"
20 #include "ui/views/style/typography.h" 20 #include "ui/views/style/typography.h"
21 21
22 namespace views { 22 namespace views {
23 23
24 class InkDropContainerView; 24 class InkDropContainerView;
25 class LabelButtonBorder; 25 class LabelButtonBorder;
26 class LabelButtonLabel;
26 27
27 // LabelButton is a button with text and an icon, it's not focusable by default. 28 // LabelButton is a button with text and an icon, it's not focusable by default.
28 class VIEWS_EXPORT LabelButton : public CustomButton, 29 class VIEWS_EXPORT LabelButton : public CustomButton,
29 public NativeThemeDelegate { 30 public NativeThemeDelegate {
30 public: 31 public:
31 // The length of the hover fade animation. 32 // The length of the hover fade animation.
32 static const int kHoverAnimationDurationMs; 33 static const int kHoverAnimationDurationMs;
33 34
34 static const char kViewClassName[]; 35 static const char kViewClassName[];
35 36
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 const char* GetClassName() const override; 101 const char* GetClassName() const override;
101 void EnableCanvasFlippingForRTLUI(bool flip) override; 102 void EnableCanvasFlippingForRTLUI(bool flip) override;
102 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; 103 void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
103 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; 104 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
104 std::unique_ptr<InkDrop> CreateInkDrop() override; 105 std::unique_ptr<InkDrop> CreateInkDrop() override;
105 std::unique_ptr<InkDropRipple> CreateInkDropRipple() const override; 106 std::unique_ptr<InkDropRipple> CreateInkDropRipple() const override;
106 std::unique_ptr<InkDropHighlight> CreateInkDropHighlight() const override; 107 std::unique_ptr<InkDropHighlight> CreateInkDropHighlight() const override;
107 108
108 protected: 109 protected:
109 ImageView* image() const { return image_; } 110 ImageView* image() const { return image_; }
110 Label* label() const { return label_; } 111 Label* label() const;
111 InkDropContainerView* ink_drop_container() const { 112 InkDropContainerView* ink_drop_container() const {
112 return ink_drop_container_; 113 return ink_drop_container_;
113 } 114 }
114 115
115 bool explicitly_set_normal_color() const { 116 bool explicitly_set_normal_color() const {
116 return explicitly_set_colors_[STATE_NORMAL]; 117 return explicitly_set_colors_[STATE_NORMAL];
117 } 118 }
118 119
119 // Returns the available area for the label and image. Subclasses can change 120 // Returns the available area for the label and image. Subclasses can change
120 // these bounds if they need room to do manual painting. 121 // these bounds if they need room to do manual painting.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // as false. 180 // as false.
180 void ResetCachedPreferredSize(); 181 void ResetCachedPreferredSize();
181 182
182 // Updates additional state related to focus or default status, rather than 183 // Updates additional state related to focus or default status, rather than
183 // merely the CustomButton::state(). E.g. ensures the label text color is 184 // merely the CustomButton::state(). E.g. ensures the label text color is
184 // correct for the current background. 185 // correct for the current background.
185 void ResetLabelEnabledColor(); 186 void ResetLabelEnabledColor();
186 187
187 // The image and label shown in the button. 188 // The image and label shown in the button.
188 ImageView* image_; 189 ImageView* image_;
189 Label* label_; 190 LabelButtonLabel* label_;
190 191
191 // A separate view is necessary to hold the ink drop layer so that it can 192 // A separate view is necessary to hold the ink drop layer so that it can
192 // be stacked below |image_| and on top of |label_|, without resorting to 193 // be stacked below |image_| and on top of |label_|, without resorting to
193 // drawing |label_| on a layer (which can mess with subpixel anti-aliasing). 194 // drawing |label_| on a layer (which can mess with subpixel anti-aliasing).
194 InkDropContainerView* ink_drop_container_; 195 InkDropContainerView* ink_drop_container_;
195 196
196 // The cached font lists in the normal and default button style. The latter 197 // The cached font lists in the normal and default button style. The latter
197 // may be bold. 198 // may be bold.
198 gfx::FontList cached_normal_font_list_; 199 gfx::FontList cached_normal_font_list_;
199 gfx::FontList cached_default_button_font_list_; 200 gfx::FontList cached_default_button_font_list_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // text direction) while |this| is laid out as ALIGN_LEFT (alignment matches 234 // text direction) while |this| is laid out as ALIGN_LEFT (alignment matches
234 // UI direction). 235 // UI direction).
235 gfx::HorizontalAlignment horizontal_alignment_; 236 gfx::HorizontalAlignment horizontal_alignment_;
236 237
237 DISALLOW_COPY_AND_ASSIGN(LabelButton); 238 DISALLOW_COPY_AND_ASSIGN(LabelButton);
238 }; 239 };
239 240
240 } // namespace views 241 } // namespace views
241 242
242 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ 243 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698