Chromium Code Reviews| 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 "third_party/skia/include/core/SkColor.h" | |
| 9 #include "ui/views/views_export.h" | |
| 10 | |
| 11 namespace gfx { | |
| 12 class FontList; | |
| 13 } | |
| 14 | |
| 15 namespace views { | |
| 16 namespace style { | |
| 17 | |
| 18 // Where a piece of text appears in the UI. This influences size and weight, but | |
| 19 // typically not style or color. | |
| 20 enum TextContext { | |
| 21 // Embedders can extend this enum with additional values that are understood | |
| 22 // by the TypographyProvider offered by their ViewsDelegate. Embedders define | |
| 23 // enum values from VIEWS_TEXT_CONTEXT_END. Values named beginning with | |
| 24 // "CONTEXT_" represent the actual TextContexts: the rest are markers. | |
| 25 VIEWS_TEXT_CONTEXT_START = 0, | |
| 26 | |
| 27 // A title for a dialog window. Usually 15pt. Multi-line OK. | |
| 28 CONTEXT_DIALOG_TITLE = VIEWS_TEXT_CONTEXT_START, | |
| 29 | |
| 30 // Text to label a control, usually next to it. "Body 2". Usually 12pt. | |
| 31 CONTEXT_LABEL, | |
| 32 | |
| 33 // An editable text field. Usually matches CONTROL_LABEL. | |
| 34 CONTEXT_TEXTFIELD, | |
| 35 | |
| 36 // Text that appears on a button control. Usually 12pt. | |
| 37 CONTEXT_BUTTON, | |
| 38 | |
| 39 // Embedders must start TextContext enum values from this value. | |
| 40 VIEWS_TEXT_CONTEXT_END, | |
| 41 | |
| 42 // All TextContext enum values must be below this value. | |
| 43 TEXT_CONTEXT_MAX = 0x1000 | |
| 44 }; | |
| 45 | |
| 46 // How a piece of text should be presented. This influences color and style, but | |
| 47 // typically not size. | |
| 48 enum TextStyle { | |
| 49 // TextStyle enum values must always be greater than any TextContext value. | |
| 50 // This allows the code to verify at runtime that arguments of the two types | |
| 51 // have not been swapped. | |
| 52 VIEWS_TEXT_STYLE_START = TEXT_CONTEXT_MAX, | |
| 53 | |
| 54 // Primary text: solid black, normal weight. Converts to DISABLED in some | |
| 55 // contexts (e.g. BUTTON_TEXT, FIELD). | |
| 56 STYLE_PRIMARY = VIEWS_TEXT_STYLE_START, | |
|
sky
2017/03/20 16:33:11
Did you consider STYLE_ENABLED? I like that better
Peter Kasting
2017/03/20 20:00:34
There is a "secondary"; it's over on the Chrome si
tapted
2017/03/20 22:31:42
There is that :). I also think ENABLED is too spec
| |
| 57 | |
| 58 // Disabled "greyed out" text. | |
| 59 STYLE_DISABLED, | |
| 60 | |
| 61 // The style used for links. Usually a solid shade of blue. | |
| 62 STYLE_LINK, | |
| 63 | |
| 64 // Active tab in a tabbed pane. | |
| 65 STYLE_TAB_ACTIVE, | |
| 66 | |
| 67 // Hovered tab in a tabbed pane. | |
| 68 STYLE_TAB_HOVERED, | |
| 69 | |
| 70 // Inactive tab in a tabbed pane. | |
| 71 STYLE_TAB_INACTIVE, | |
| 72 | |
| 73 // Embedders must start TextStyle enum values from here. | |
| 74 VIEWS_TEXT_STYLE_END | |
| 75 }; | |
| 76 | |
| 77 // Helpers to obtain font properties from the TypographyProvider given by the | |
| 78 // current ViewsDelegate. |context| can be an enum value from TextContext, or a | |
| 79 // value understood by the embedder's TypographyProvider. Similarly, | |
| 80 // |text_style| corresponds to TextStyle. | |
| 81 VIEWS_EXPORT const gfx::FontList& GetFont(int text_context, int text_style); | |
| 82 VIEWS_EXPORT SkColor GetColor(int text_context, int text_style); | |
| 83 VIEWS_EXPORT int GetLineHeight(int text_context, int text_style); | |
| 84 | |
| 85 } // namespace style | |
| 86 } // namespace views | |
| 87 | |
| 88 #endif // UI_VIEWS_STYLE_TYPOGRAPHY_H_ | |
| OLD | NEW |