OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_VIEWS_STYLE_TYPOGRAPHY_H_ | |
6 #define UI_VIEWS_STYLE_TYPOGRAPHY_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "third_party/skia/include/core/SkColor.h" | |
12 #include "ui/views/views_export.h" | |
13 | |
14 namespace gfx { | |
15 class FontList; | |
16 } | |
17 | |
18 namespace views { | |
19 | |
20 // Where a piece of text appears in the UI. This influences size and weight, but | |
21 // typically not style or color. | |
22 enum class TextContext { | |
sky
2017/03/14 17:31:47
It seems fair to enumerate the places in views tha
Peter Kasting
2017/03/14 19:35:49
I chatted briefly with Scott about this, since it
tapted
2017/03/15 08:26:24
Done.
| |
23 HEADLINE, // Headline text. Usually 20pt. Never multi-line. | |
24 DIALOG_TITLE, // A title for a dialog window. Usually 15pt. Multi-line OK. | |
25 DIALOG_MESSAGE, // "Body 1". Usually 13pt. | |
26 DIALOG_TEXT_SMALL, // "Body 2". Usually 12pt. | |
27 CONTROL_LABEL, // "Body 2". Usually 12pt. | |
28 FIELD, // A text field. Usually matches CONTROL_LABEL. | |
29 BUTTON_TEXT, // Text that appears on a button control. Usually 12pt. | |
tapted
2017/03/14 09:56:18
BUTTON_TEXT is different in the spec, but DIALOG_T
| |
30 | |
31 // Transitional contexts. | |
32 DEPRECATED_SMALL, // ResourceBundle::SmallFont (11 pt). | |
33 }; | |
34 | |
35 // How a piece of text should be presented. This influences color and style, but | |
36 // typically not size. | |
37 enum class TextStyle { | |
sky
2017/03/14 17:31:47
Similar comment as to TextContext. I'm ok with enu
tapted
2017/03/15 08:26:24
Done.
| |
38 // Primary text: solid black, normal weight. Converts to DISABLED in some | |
39 // contexts (e.g. BUTTON_TEXT, FIELD). | |
40 PRIMARY, | |
41 | |
42 // Secondary text: may be lighter. | |
43 SECONDARY, | |
44 | |
45 // "Hint" text, usually a line that gives context to something more important. | |
46 HINT, | |
47 | |
48 DISABLED, // Disabled "greyed out" text. | |
49 RED, // A solid shade of red. | |
50 GREEN, // A solid shade of green. | |
51 LINK, // A solid shade of blue. | |
52 | |
53 // Legacy styles start here. | |
Peter Kasting
2017/03/14 23:53:33
Are these intended to be "deprecated, don't add us
tapted
2017/03/15 08:26:24
It's more about a set of styles that just don't ex
| |
54 | |
55 ACTIVE_TAB, // Active tab in a tabbed pane. | |
56 INACTIVE_TAB, // Inactive tab in a tabbed pane. | |
57 HOVERED_TAB, // Hovered tab in a tabbed pane. | |
58 WEB_DOMAIN, // Used to draw attention to a web domain. | |
59 EXTENSION_NAME, // Used to draw attention to an extension name. | |
60 }; | |
61 | |
62 // Provides fonts to use in toolkit-views UI. | |
63 class VIEWS_EXPORT TypographyProvider { | |
64 public: | |
65 // Gets the FontList for the given |context| and |style|. | |
66 virtual const gfx::FontList& GetFont(TextContext context, | |
67 TextStyle style) = 0; | |
68 | |
69 // Gets the color for the given |context| and |style|. This may consult | |
70 // ui::NativeTheme. | |
71 virtual SkColor GetColor(TextContext context, TextStyle style) = 0; | |
72 | |
73 // Gets the line spacing, or 0 if it should be provided by gfx::FontList. | |
Peter Kasting
2017/03/14 23:53:33
I admit it's not totally clear to me how this work
tapted
2017/03/15 08:26:24
I think it does and should. views::Label has a lin
Peter Kasting
2017/03/15 10:01:48
My worry here is that that means this line spacing
tapted
2017/03/15 11:04:06
(disclaimer: I'm not a typesetting expert) I think
tapted
2017/03/15 22:43:34
bettes@ recently pointed me to https://goto.google
| |
74 virtual int GetLineSpacing(TextContext context, TextStyle style) = 0; | |
75 | |
76 virtual ~TypographyProvider() {} | |
Peter Kasting
2017/03/14 23:53:34
Nit: I tend to prefer "= default" to "{}" as the w
tapted
2017/03/15 08:26:24
Done.
| |
77 | |
78 protected: | |
79 TypographyProvider() {} | |
80 | |
81 private: | |
82 DISALLOW_COPY_AND_ASSIGN(TypographyProvider); | |
83 }; | |
84 | |
85 // Helper class to query (or change) the current TypographyProvider. | |
Peter Kasting
2017/03/14 23:53:34
Hmm. Is this really just a way to group some rela
tapted
2017/03/15 08:26:24
Hm - conceptually, `Typography` also encapsulates
| |
86 class VIEWS_EXPORT Typography { | |
87 public: | |
88 static void SetProvider(std::unique_ptr<TypographyProvider> provider); | |
89 | |
90 static const gfx::FontList& GetFont(TextContext context, TextStyle style); | |
91 static SkColor GetColor(TextContext context, TextStyle style); | |
92 static int GetLineSpacing(TextContext context, TextStyle style); | |
93 | |
94 private: | |
95 DISALLOW_IMPLICIT_CONSTRUCTORS(Typography); | |
96 }; | |
97 | |
98 } // namespace views | |
99 | |
100 #endif // UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ | |
OLD | NEW |