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

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

Issue 2801583002: Use views::style for buttons, bootstrap ash_typography to do so. (Closed)
Patch Set: More self review Created 3 years, 8 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 21
21 namespace views { 22 namespace views {
22 23
23 class InkDropContainerView; 24 class InkDropContainerView;
24 class LabelButtonBorder; 25 class LabelButtonBorder;
25 class Painter; 26 class Painter;
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
36 LabelButton(ButtonListener* listener, const base::string16& text); 37 // Creates a LabelButton with ButtonPressed() events sent to |listener| and
38 // label |text|. |button_context| is a value from views::style::TextContext
39 // and determines the appearance of |text|.
40 LabelButton(ButtonListener* listener,
41 const base::string16& text,
42 int button_context = style::CONTEXT_BUTTON);
37 ~LabelButton() override; 43 ~LabelButton() override;
38 44
39 // Gets or sets the image shown for the specified button state. 45 // Gets or sets the image shown for the specified button state.
40 // GetImage returns the image for STATE_NORMAL if the state's image is empty. 46 // GetImage returns the image for STATE_NORMAL if the state's image is empty.
41 virtual gfx::ImageSkia GetImage(ButtonState for_state) const; 47 virtual gfx::ImageSkia GetImage(ButtonState for_state) const;
42 void SetImage(ButtonState for_state, const gfx::ImageSkia& image); 48 void SetImage(ButtonState for_state, const gfx::ImageSkia& image);
43 49
44 // Gets or sets the text shown on the button. 50 // Gets or sets the text shown on the button.
45 const base::string16& GetText() const; 51 const base::string16& GetText() const;
46 virtual void SetText(const base::string16& text); 52 virtual void SetText(const base::string16& text);
47 53
48 // Sets the text color shown for the specified button |for_state| to |color|. 54 // Sets the text color shown for the specified button |for_state| to |color|.
49 void SetTextColor(ButtonState for_state, SkColor color); 55 void SetTextColor(ButtonState for_state, SkColor color);
50 56
51 // Sets the text colors shown for the non-disabled states to |color|. 57 // Sets the text colors shown for the non-disabled states to |color|.
52 virtual void SetEnabledTextColors(SkColor color); 58 virtual void SetEnabledTextColors(SkColor color);
53 59
54 // Sets drop shadows underneath the text. 60 // Sets drop shadows underneath the text.
55 void SetTextShadows(const gfx::ShadowValues& shadows); 61 void SetTextShadows(const gfx::ShadowValues& shadows);
56 62
57 // Sets whether subpixel rendering is used on the label. 63 // Sets whether subpixel rendering is used on the label.
58 void SetTextSubpixelRenderingEnabled(bool enabled); 64 void SetTextSubpixelRenderingEnabled(bool enabled);
59 65
60 // Adjusts the font size up or down by the given amount.
61 virtual void AdjustFontSize(int font_size_delta);
62
63 // Sets the elide behavior of this button. 66 // Sets the elide behavior of this button.
64 void SetElideBehavior(gfx::ElideBehavior elide_behavior); 67 void SetElideBehavior(gfx::ElideBehavior elide_behavior);
65 68
66 // Sets the horizontal alignment used for the button; reversed in RTL. The 69 // Sets the horizontal alignment used for the button; reversed in RTL. The
67 // optional image will lead the text, unless the button is right-aligned. 70 // optional image will lead the text, unless the button is right-aligned.
68 void SetHorizontalAlignment(gfx::HorizontalAlignment alignment); 71 void SetHorizontalAlignment(gfx::HorizontalAlignment alignment);
69 72
70 // Call SetMinSize(gfx::Size()) to clear the monotonically increasing size. 73 // Call SetMinSize(gfx::Size()) to clear the monotonically increasing size.
71 void SetMinSize(const gfx::Size& min_size); 74 void SetMinSize(const gfx::Size& min_size);
72 void SetMaxSize(const gfx::Size& max_size); 75 void SetMaxSize(const gfx::Size& max_size);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 Label* label() const { return label_; } 112 Label* label() const { return label_; }
110 113
111 bool explicitly_set_normal_color() const { 114 bool explicitly_set_normal_color() const {
112 return explicitly_set_colors_[STATE_NORMAL]; 115 return explicitly_set_colors_[STATE_NORMAL];
113 } 116 }
114 117
115 // Returns the available area for the label and image. Subclasses can change 118 // Returns the available area for the label and image. Subclasses can change
116 // these bounds if they need room to do manual painting. 119 // these bounds if they need room to do manual painting.
117 virtual gfx::Rect GetChildAreaBounds(); 120 virtual gfx::Rect GetChildAreaBounds();
118 121
119 // Sets the font list used by this button.
120 virtual void SetFontList(const gfx::FontList& font_list);
121
122 // View: 122 // View:
123 void OnPaint(gfx::Canvas* canvas) override; 123 void OnPaint(gfx::Canvas* canvas) override;
124 void OnFocus() override; 124 void OnFocus() override;
125 void OnBlur() override; 125 void OnBlur() override;
126 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; 126 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
127 127
128 // CustomButton: 128 // CustomButton:
129 void StateChanged(ButtonState old_state) override; 129 void StateChanged(ButtonState old_state) override;
130 130
131 // Fills |params| with information about the button. 131 // Fills |params| with information about the button.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 gfx::HorizontalAlignment horizontal_alignment_; 234 gfx::HorizontalAlignment horizontal_alignment_;
235 235
236 std::unique_ptr<Painter> focus_painter_; 236 std::unique_ptr<Painter> focus_painter_;
237 237
238 DISALLOW_COPY_AND_ASSIGN(LabelButton); 238 DISALLOW_COPY_AND_ASSIGN(LabelButton);
239 }; 239 };
240 240
241 } // namespace views 241 } // namespace views
242 242
243 #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