OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_MD_TEXT_BUTTON_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_ |
6 #define UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/optional.h" | 10 #include "base/optional.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // Creates a normal STYLE_BUTTON LabelButton in pre-MD, or an MdTextButton | 22 // Creates a normal STYLE_BUTTON LabelButton in pre-MD, or an MdTextButton |
23 // in MD mode. | 23 // in MD mode. |
24 static LabelButton* CreateStandardButton(ButtonListener* listener, | 24 static LabelButton* CreateStandardButton(ButtonListener* listener, |
25 const base::string16& text); | 25 const base::string16& text); |
26 // As above, but only creates an MdTextButton if MD is enabled in the | 26 // As above, but only creates an MdTextButton if MD is enabled in the |
27 // secondary UI (as opposed to just "top chrome"/"primary" UI). | 27 // secondary UI (as opposed to just "top chrome"/"primary" UI). |
28 static LabelButton* CreateSecondaryUiButton(ButtonListener* listener, | 28 static LabelButton* CreateSecondaryUiButton(ButtonListener* listener, |
29 const base::string16& text); | 29 const base::string16& text); |
30 static LabelButton* CreateSecondaryUiBlueButton(ButtonListener* listener, | 30 static LabelButton* CreateSecondaryUiBlueButton(ButtonListener* listener, |
31 const base::string16& text); | 31 const base::string16& text); |
32 static MdTextButton* CreateMdButton(ButtonListener* listener, | 32 static MdTextButton* Create(ButtonListener* listener, |
33 const base::string16& text); | 33 const base::string16& text); |
34 | 34 |
35 // See |is_cta_|. | 35 // See |is_cta_|. |
36 void SetCallToAction(bool cta); | 36 void SetCallToAction(bool cta); |
37 void set_bg_color_override(SkColor color) { bg_color_override_ = color; } | 37 void set_bg_color_override(SkColor color) { bg_color_override_ = color; } |
38 | 38 |
39 // LabelButton: | 39 // LabelButton: |
40 void Layout() override; | 40 void Layout() override; |
41 void OnFocus() override; | 41 void OnFocus() override; |
42 void OnBlur() override; | 42 void OnBlur() override; |
43 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 43 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
44 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; | 44 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; |
45 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() | 45 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() |
46 const override; | 46 const override; |
47 SkColor GetInkDropBaseColor() const override; | 47 SkColor GetInkDropBaseColor() const override; |
48 bool ShouldShowInkDropForFocus() const override; | 48 bool ShouldShowInkDropForFocus() const override; |
49 void SetEnabledTextColors(SkColor color) override; | 49 void SetEnabledTextColors(SkColor color) override; |
50 void SetText(const base::string16& text) override; | 50 void SetText(const base::string16& text) override; |
51 void AdjustFontSize(int size_delta) override; | 51 void AdjustFontSize(int size_delta) override; |
52 void UpdateStyleToIndicateDefaultStatus() override; | 52 void UpdateStyleToIndicateDefaultStatus() override; |
53 void StateChanged() override; | 53 void StateChanged() override; |
54 | 54 |
55 protected: | 55 protected: |
56 // LabelButton: | 56 // LabelButton: |
57 void SetFontList(const gfx::FontList& font_list) override; | 57 void SetFontList(const gfx::FontList& font_list) override; |
58 | 58 |
59 private: | 59 private: |
60 MdTextButton(ButtonListener* listener); | 60 explicit MdTextButton(ButtonListener* listener); |
61 ~MdTextButton() override; | 61 ~MdTextButton() override; |
62 | 62 |
63 void UpdatePadding(); | 63 void UpdatePadding(); |
64 void UpdateColors(); | 64 void UpdateColors(); |
65 | 65 |
66 // The MD-style focus ring. This is not done via a FocusPainter | 66 // The MD-style focus ring. This is not done via a FocusPainter |
67 // because it needs to paint to a layer so it can extend beyond the bounds of | 67 // because it needs to paint to a layer so it can extend beyond the bounds of |
68 // |this|. | 68 // |this|. |
69 internal::MdFocusRing* focus_ring_; | 69 internal::MdFocusRing* focus_ring_; |
70 | 70 |
71 // True if this button uses call-to-action styling. | 71 // True if this button uses call-to-action styling. |
72 bool is_cta_; | 72 bool is_cta_; |
73 | 73 |
74 // When set, this provides the background color. | 74 // When set, this provides the background color. |
75 base::Optional<SkColor> bg_color_override_; | 75 base::Optional<SkColor> bg_color_override_; |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(MdTextButton); | 77 DISALLOW_COPY_AND_ASSIGN(MdTextButton); |
78 }; | 78 }; |
79 | 79 |
80 } // namespace views | 80 } // namespace views |
81 | 81 |
82 #endif // UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_ | 82 #endif // UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_ |
OLD | NEW |