Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: ui/views/controls/button/md_text_button.h

Issue 2380303004: Move MdFocusRing to be a property of FocusManager. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/controls/button/md_text_button.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Creates a normal STYLE_BUTTON LabelButton in pre-MD, or an MdTextButton 18 // Creates a normal STYLE_BUTTON LabelButton in pre-MD, or an MdTextButton
23 // in MD mode. 19 // in MD mode.
24 static LabelButton* CreateStandardButton(ButtonListener* listener, 20 static LabelButton* CreateStandardButton(ButtonListener* listener,
25 const base::string16& text); 21 const base::string16& text);
26 // As above, but only creates an MdTextButton if MD is enabled in the 22 // As above, but only creates an MdTextButton if MD is enabled in the
27 // secondary UI (as opposed to just "top chrome"/"primary" UI). 23 // secondary UI (as opposed to just "top chrome"/"primary" UI).
28 static LabelButton* CreateSecondaryUiButton(ButtonListener* listener, 24 static LabelButton* CreateSecondaryUiButton(ButtonListener* listener,
29 const base::string16& text); 25 const base::string16& text);
30 static LabelButton* CreateSecondaryUiBlueButton(ButtonListener* listener, 26 static LabelButton* CreateSecondaryUiBlueButton(ButtonListener* listener,
31 const base::string16& text); 27 const base::string16& text);
32 static MdTextButton* Create(ButtonListener* listener, 28 static MdTextButton* Create(ButtonListener* listener,
33 const base::string16& text); 29 const base::string16& text);
34 30
35 // See |is_prominent_|. 31 // See |is_prominent_|.
36 void SetProminent(bool is_prominent); 32 void SetProminent(bool is_prominent);
37 void set_bg_color_override(SkColor color) { bg_color_override_ = color; } 33 void set_bg_color_override(SkColor color) { bg_color_override_ = color; }
38 34
39 // LabelButton: 35 // LabelButton:
40 void Layout() override;
41 void OnFocus() override;
42 void OnBlur() override;
43 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; 36 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
44 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; 37 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
45 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() 38 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
46 const override; 39 const override;
47 SkColor GetInkDropBaseColor() const override; 40 SkColor GetInkDropBaseColor() const override;
48 bool ShouldShowInkDropForFocus() const override; 41 bool ShouldShowInkDropForFocus() const override;
49 void SetEnabledTextColors(SkColor color) override; 42 void SetEnabledTextColors(SkColor color) override;
50 void SetText(const base::string16& text) override; 43 void SetText(const base::string16& text) override;
51 void AdjustFontSize(int size_delta) override; 44 void AdjustFontSize(int size_delta) override;
52 void UpdateStyleToIndicateDefaultStatus() override; 45 void UpdateStyleToIndicateDefaultStatus() override;
53 void StateChanged() override; 46 void StateChanged() override;
54 47
55 protected: 48 protected:
56 // LabelButton: 49 // LabelButton:
57 void SetFontList(const gfx::FontList& font_list) override; 50 void SetFontList(const gfx::FontList& font_list) override;
58 51
59 private: 52 private:
60 explicit MdTextButton(ButtonListener* listener); 53 explicit MdTextButton(ButtonListener* listener);
61 ~MdTextButton() override; 54 ~MdTextButton() override;
62 55
63 void UpdatePadding(); 56 void UpdatePadding();
64 void UpdateColors(); 57 void UpdateColors();
65 58
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
68 // |this|.
69 internal::MdFocusRing* focus_ring_;
70
71 // True if this button uses prominent styling (blue fill, etc.). 59 // True if this button uses prominent styling (blue fill, etc.).
72 bool is_prominent_; 60 bool is_prominent_;
73 61
74 // When set, this provides the background color. 62 // When set, this provides the background color.
75 base::Optional<SkColor> bg_color_override_; 63 base::Optional<SkColor> bg_color_override_;
76 64
77 DISALLOW_COPY_AND_ASSIGN(MdTextButton); 65 DISALLOW_COPY_AND_ASSIGN(MdTextButton);
78 }; 66 };
79 67
80 } // namespace views 68 } // namespace views
81 69
82 #endif // UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_ 70 #endif // UI_VIEWS_CONTROLS_BUTTON_MD_TEXT_BUTTON_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/button/md_text_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698