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