| 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( |
| 25 const base::string16& text); | 26 ButtonListener* listener, |
| 27 const base::string16& text, |
| 28 int button_context = style::CONTEXT_DIALOG_BUTTON); |
| 26 | 29 |
| 27 ~MdTextButton() override; | 30 ~MdTextButton() override; |
| 28 | 31 |
| 29 // See |is_prominent_|. | 32 // See |is_prominent_|. |
| 30 void SetProminent(bool is_prominent); | 33 void SetProminent(bool is_prominent); |
| 31 | 34 |
| 32 // See |bg_color_override_|. | 35 // See |bg_color_override_|. |
| 33 void SetBgColorOverride(const base::Optional<SkColor>& color); | 36 void SetBgColorOverride(const base::Optional<SkColor>& color); |
| 34 | 37 |
| 35 // View: | 38 // View: |
| 36 void OnPaintBackground(gfx::Canvas* canvas) override; | 39 void OnPaintBackground(gfx::Canvas* canvas) override; |
| 37 | 40 |
| 38 // LabelButton: | 41 // LabelButton: |
| 39 void OnFocus() override; | 42 void OnFocus() override; |
| 40 void OnBlur() override; | 43 void OnBlur() override; |
| 41 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 44 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
| 42 std::unique_ptr<InkDrop> CreateInkDrop() override; | 45 std::unique_ptr<InkDrop> CreateInkDrop() override; |
| 43 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; | 46 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; |
| 44 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() | 47 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() |
| 45 const override; | 48 const override; |
| 46 SkColor GetInkDropBaseColor() const override; | 49 SkColor GetInkDropBaseColor() const override; |
| 47 void SetEnabledTextColors(SkColor color) override; | 50 void SetEnabledTextColors(SkColor color) override; |
| 48 void SetText(const base::string16& text) override; | 51 void SetText(const base::string16& text) override; |
| 49 void AdjustFontSize(int size_delta) override; | |
| 50 void UpdateStyleToIndicateDefaultStatus() override; | 52 void UpdateStyleToIndicateDefaultStatus() override; |
| 51 void StateChanged(ButtonState old_state) override; | 53 void StateChanged(ButtonState old_state) override; |
| 52 | 54 |
| 53 protected: | |
| 54 // LabelButton: | |
| 55 void SetFontList(const gfx::FontList& font_list) override; | |
| 56 | |
| 57 private: | 55 private: |
| 58 explicit MdTextButton(ButtonListener* listener); | 56 MdTextButton(ButtonListener* listener, int button_context); |
| 59 | 57 |
| 60 void UpdatePadding(); | 58 void UpdatePadding(); |
| 61 void UpdateColors(); | 59 void UpdateColors(); |
| 62 | 60 |
| 63 // True if this button uses prominent styling (blue fill, etc.). | 61 // True if this button uses prominent styling (blue fill, etc.). |
| 64 bool is_prominent_; | 62 bool is_prominent_; |
| 65 | 63 |
| 66 // When set, this provides the background color. | 64 // When set, this provides the background color. |
| 67 base::Optional<SkColor> bg_color_override_; | 65 base::Optional<SkColor> bg_color_override_; |
| 68 | 66 |
| 69 DISALLOW_COPY_AND_ASSIGN(MdTextButton); | 67 DISALLOW_COPY_AND_ASSIGN(MdTextButton); |
| 70 }; | 68 }; |
| 71 | 69 |
| 72 } // namespace views | 70 } // namespace views |
| 73 | 71 |
| 74 #endif // UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_ | 72 #endif // UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_ |
| OLD | NEW |