Index: ui/views/controls/label.h |
diff --git a/ui/views/controls/label.h b/ui/views/controls/label.h |
index 516368ee974367c7a711d497590ade90e1c02af3..1243f55206654d310d90d7c0dcfd75b26867ba1f 100644 |
--- a/ui/views/controls/label.h |
+++ b/ui/views/controls/label.h |
@@ -12,6 +12,7 @@ |
#include "ui/gfx/render_text.h" |
#include "ui/views/context_menu_controller.h" |
#include "ui/views/selection_controller_delegate.h" |
+#include "ui/views/style/typography.h" |
#include "ui/views/view.h" |
#include "ui/views/word_lookup_client.h" |
@@ -33,9 +34,35 @@ class VIEWS_EXPORT Label : public View, |
// The padding for the focus border when rendering focused text. |
static const int kFocusBorderPadding; |
+ // Helper to construct a Label that doesn't use the views::Typography spec. |
+ // Using this causes Label to obtain colors from ui::NativeTheme and line |
+ // spacing from gfx::FontList::GetHeight(). |
+ // TOOD(tapted): Audit users of this class when MD is default. Then add |
Peter Kasting
2017/03/17 02:26:00
Nit: TOOD? :)
tapted
2017/03/17 10:33:10
whoops. fixed. (I have spell checking for comments
|
+ // foreground/background colors, line spacing and everything else that |
+ // views::TextContext abstracts away so the separate setters can be removed. |
+ struct CustomFont { |
Peter Kasting
2017/03/17 02:26:00
Nit: Just for the sake of keeping the diff minimal
tapted
2017/03/17 10:33:10
Yeah, I also want any new code to be considering a
|
+ // TODO(tapted): Change this to a size delta and font weight since that's |
+ // typically all the callers really care about, and would allow Label to |
+ // guarantee caching of the FontList in ResourceBundle. |
+ const gfx::FontList& font_list; |
+ }; |
+ |
+ // Create Labels with typography::CONTEXT_CONTROL_LABEL and |
+ // typography::STYLE_PRIMARY. |
+ // TODO(tapted): Remove these. Callers must specify a context or use the |
+ // constructor taking a CustomFont. |
Label(); |
explicit Label(const base::string16& text); |
- Label(const base::string16& text, const gfx::FontList& font_list); |
+ |
+ // Construct a Label in the given |text_context|. The text_style can change |
Peter Kasting
2017/03/17 02:26:00
Nit: Use || consistently
tapted
2017/03/17 10:33:10
Done.
|
+ // later, so provide a default. The |text_context| is fixed. |
+ Label(const base::string16& text, |
+ int text_context, |
+ int text_style = typography::STYLE_PRIMARY); |
+ |
+ // Construct a Label with the given |font| description. |
+ Label(const base::string16& text, const CustomFont& font); |
+ |
~Label() override; |
static const gfx::FontList& GetDefaultFontList(); |
@@ -43,6 +70,7 @@ class VIEWS_EXPORT Label : public View, |
// Gets or sets the fonts used by this label. |
const gfx::FontList& font_list() const { return render_text_->font_list(); } |
+ // TODO(tapted): Replace this with a private method, e.g., OnFontChanged(). |
virtual void SetFontList(const gfx::FontList& font_list); |
// Get or set the label text. |