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" |
11 #include "ui/views/controls/button/label_button.h" | 11 #include "ui/views/controls/button/label_button.h" |
| 12 #include "ui/views/style/typography.h" |
12 | 13 |
13 namespace views { | 14 namespace views { |
14 | 15 |
15 // A button class that implements the Material Design text button spec. | 16 // A button class that implements the Material Design text button spec. |
16 class VIEWS_EXPORT MdTextButton : public LabelButton { | 17 class VIEWS_EXPORT MdTextButton : public LabelButton { |
17 public: | 18 public: |
18 // As above, but only creates an MdTextButton if MD is enabled in the | 19 // As above, but only creates an MdTextButton if MD is enabled in the |
19 // secondary UI (as opposed to just "top chrome"/"primary" UI). | 20 // secondary UI (as opposed to just "top chrome"/"primary" UI). |
20 static LabelButton* CreateSecondaryUiButton(ButtonListener* listener, | 21 static LabelButton* CreateSecondaryUiButton(ButtonListener* listener, |
21 const base::string16& text); | 22 const base::string16& text); |
22 static LabelButton* CreateSecondaryUiBlueButton(ButtonListener* listener, | 23 static LabelButton* CreateSecondaryUiBlueButton(ButtonListener* listener, |
23 const base::string16& text); | 24 const base::string16& text); |
24 static MdTextButton* Create(ButtonListener* listener, | 25 static MdTextButton* Create(ButtonListener* listener, |
25 const base::string16& text); | 26 const base::string16& text, |
| 27 int button_context = style::CONTEXT_BUTTON_MD); |
26 | 28 |
27 ~MdTextButton() override; | 29 ~MdTextButton() override; |
28 | 30 |
29 // See |is_prominent_|. | 31 // See |is_prominent_|. |
30 void SetProminent(bool is_prominent); | 32 void SetProminent(bool is_prominent); |
31 | 33 |
32 // See |bg_color_override_|. | 34 // See |bg_color_override_|. |
33 void SetBgColorOverride(const base::Optional<SkColor>& color); | 35 void SetBgColorOverride(const base::Optional<SkColor>& color); |
34 | 36 |
35 // View: | 37 // View: |
36 void OnPaintBackground(gfx::Canvas* canvas) override; | 38 void OnPaintBackground(gfx::Canvas* canvas) override; |
37 | 39 |
38 // LabelButton: | 40 // LabelButton: |
39 void OnFocus() override; | 41 void OnFocus() override; |
40 void OnBlur() override; | 42 void OnBlur() override; |
41 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 43 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
42 std::unique_ptr<InkDrop> CreateInkDrop() override; | 44 std::unique_ptr<InkDrop> CreateInkDrop() override; |
43 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; | 45 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; |
44 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() | 46 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() |
45 const override; | 47 const override; |
46 SkColor GetInkDropBaseColor() const override; | 48 SkColor GetInkDropBaseColor() const override; |
47 void SetEnabledTextColors(SkColor color) override; | 49 void SetEnabledTextColors(SkColor color) override; |
48 void SetText(const base::string16& text) override; | 50 void SetText(const base::string16& text) override; |
49 void AdjustFontSize(int size_delta) override; | |
50 void UpdateStyleToIndicateDefaultStatus() override; | 51 void UpdateStyleToIndicateDefaultStatus() override; |
51 void StateChanged(ButtonState old_state) override; | 52 void StateChanged(ButtonState old_state) override; |
52 | 53 |
53 protected: | |
54 // LabelButton: | |
55 void SetFontList(const gfx::FontList& font_list) override; | |
56 | |
57 private: | 54 private: |
58 explicit MdTextButton(ButtonListener* listener); | 55 MdTextButton(ButtonListener* listener, int button_context); |
59 | 56 |
60 void UpdatePadding(); | 57 void UpdatePadding(); |
61 void UpdateColors(); | 58 void UpdateColors(); |
62 | 59 |
63 // True if this button uses prominent styling (blue fill, etc.). | 60 // True if this button uses prominent styling (blue fill, etc.). |
64 bool is_prominent_; | 61 bool is_prominent_; |
65 | 62 |
66 // When set, this provides the background color. | 63 // When set, this provides the background color. |
67 base::Optional<SkColor> bg_color_override_; | 64 base::Optional<SkColor> bg_color_override_; |
68 | 65 |
69 DISALLOW_COPY_AND_ASSIGN(MdTextButton); | 66 DISALLOW_COPY_AND_ASSIGN(MdTextButton); |
70 }; | 67 }; |
71 | 68 |
72 } // namespace views | 69 } // namespace views |
73 | 70 |
74 #endif // UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_ | 71 #endif // UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_ |
OLD | NEW |