| 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 namespace internal { | |
| 16 class MdFocusRing; | |
| 17 } // namespace internal | |
| 18 | |
| 19 // A button class that implements the Material Design text button spec. | 15 // A button class that implements the Material Design text button spec. |
| 20 class VIEWS_EXPORT MdTextButton : public LabelButton { | 16 class VIEWS_EXPORT MdTextButton : public LabelButton { |
| 21 public: | 17 public: |
| 22 // 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 |
| 23 // secondary UI (as opposed to just "top chrome"/"primary" UI). | 19 // secondary UI (as opposed to just "top chrome"/"primary" UI). |
| 24 static LabelButton* CreateSecondaryUiButton(ButtonListener* listener, | 20 static LabelButton* CreateSecondaryUiButton(ButtonListener* listener, |
| 25 const base::string16& text); | 21 const base::string16& text); |
| 26 static LabelButton* CreateSecondaryUiBlueButton(ButtonListener* listener, | 22 static LabelButton* CreateSecondaryUiBlueButton(ButtonListener* listener, |
| 27 const base::string16& text); | 23 const base::string16& text); |
| 28 static MdTextButton* Create(ButtonListener* listener, | 24 static MdTextButton* Create(ButtonListener* listener, |
| 29 const base::string16& text); | 25 const base::string16& text); |
| 30 | 26 |
| 31 // See |is_prominent_|. | 27 // See |is_prominent_|. |
| 32 void SetProminent(bool is_prominent); | 28 void SetProminent(bool is_prominent); |
| 33 void set_bg_color_override(SkColor color) { bg_color_override_ = color; } | 29 void set_bg_color_override(SkColor color) { bg_color_override_ = color; } |
| 34 | 30 |
| 35 // LabelButton: | 31 // LabelButton: |
| 36 void Layout() override; | |
| 37 void OnFocus() override; | 32 void OnFocus() override; |
| 38 void OnBlur() override; | 33 void OnBlur() override; |
| 39 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 34 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
| 40 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; | 35 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; |
| 41 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() | 36 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() |
| 42 const override; | 37 const override; |
| 43 SkColor GetInkDropBaseColor() const override; | 38 SkColor GetInkDropBaseColor() const override; |
| 44 bool ShouldShowInkDropForFocus() const override; | 39 bool ShouldShowInkDropForFocus() const override; |
| 45 void SetEnabledTextColors(SkColor color) override; | 40 void SetEnabledTextColors(SkColor color) override; |
| 46 void SetText(const base::string16& text) override; | 41 void SetText(const base::string16& text) override; |
| 47 void AdjustFontSize(int size_delta) override; | 42 void AdjustFontSize(int size_delta) override; |
| 48 void UpdateStyleToIndicateDefaultStatus() override; | 43 void UpdateStyleToIndicateDefaultStatus() override; |
| 49 void StateChanged() override; | 44 void StateChanged() override; |
| 50 | 45 |
| 51 protected: | 46 protected: |
| 52 // LabelButton: | 47 // LabelButton: |
| 53 void SetFontList(const gfx::FontList& font_list) override; | 48 void SetFontList(const gfx::FontList& font_list) override; |
| 54 | 49 |
| 55 private: | 50 private: |
| 56 explicit MdTextButton(ButtonListener* listener); | 51 explicit MdTextButton(ButtonListener* listener); |
| 57 ~MdTextButton() override; | 52 ~MdTextButton() override; |
| 58 | 53 |
| 59 void UpdatePadding(); | 54 void UpdatePadding(); |
| 60 void UpdateColors(); | 55 void UpdateColors(); |
| 61 | 56 |
| 62 // The MD-style focus ring. This is not done via a FocusPainter | |
| 63 // because it needs to paint to a layer so it can extend beyond the bounds of | |
| 64 // |this|. | |
| 65 internal::MdFocusRing* focus_ring_; | |
| 66 | |
| 67 // True if this button uses prominent styling (blue fill, etc.). | 57 // True if this button uses prominent styling (blue fill, etc.). |
| 68 bool is_prominent_; | 58 bool is_prominent_; |
| 69 | 59 |
| 70 // When set, this provides the background color. | 60 // When set, this provides the background color. |
| 71 base::Optional<SkColor> bg_color_override_; | 61 base::Optional<SkColor> bg_color_override_; |
| 72 | 62 |
| 73 DISALLOW_COPY_AND_ASSIGN(MdTextButton); | 63 DISALLOW_COPY_AND_ASSIGN(MdTextButton); |
| 74 }; | 64 }; |
| 75 | 65 |
| 76 } // namespace views | 66 } // namespace views |
| 77 | 67 |
| 78 #endif // UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_ | 68 #endif // UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_ |
| OLD | NEW |