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

Unified Diff: ui/views/style/typography.h

Issue 2734113006: "Bootstrap" a toolkit-views Typography spec. (Closed)
Patch Set: respond to comments Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/style/typography.h
diff --git a/ui/views/style/typography.h b/ui/views/style/typography.h
new file mode 100644
index 0000000000000000000000000000000000000000..a0e7548af7234f6ae69af54bb8cd294c82304498
--- /dev/null
+++ b/ui/views/style/typography.h
@@ -0,0 +1,87 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_STYLE_TYPOGRAPHY_H_
+#define UI_VIEWS_STYLE_TYPOGRAPHY_H_
+
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/views/views_export.h"
+
+namespace gfx {
+class FontList;
+}
+
+namespace views {
+namespace style {
+
+// Where a piece of text appears in the UI. This influences size and weight, but
+// typically not style or color.
+enum TextContext {
+ // Embedders can extend this enum with additional values that are understood
+ // by the TypographyProvider offered by their ViewsDelegate. Embedders define
+ // enum values from VIEWS_TEXT_CONTEXT_END. Values named beginning with
+ // "CONTEXT_" represent the actual TextContexts: the rest are markers.
+ VIEWS_TEXT_CONTEXT_START = 0,
+
+ // A title for a dialog window. Usually 15pt. Multi-line OK.
+ CONTEXT_DIALOG_TITLE = VIEWS_TEXT_CONTEXT_START,
+
+ // Text to label a control, usually next to it. "Body 2". Usually 12pt.
+ CONTEXT_LABEL,
+
+ // An editable text field. Usually matches CONTROL_LABEL.
+ CONTEXT_TEXT_FIELD,
Peter Kasting 2017/03/17 20:59:39 Nit: Is TEXTFIELD better than TEXT_FIELD? The vie
tapted 2017/03/20 07:33:35 Done (-> TEXTFIELD). Heh, niggles like this can be
+
+ // Text that appears on a button control. Usually 12pt.
+ CONTEXT_BUTTON,
+
+ // Embedders must start TextContext enum values from this value.
+ VIEWS_TEXT_CONTEXT_END,
+
+ // All TextContext enum values must be below this value.
+ TEXT_CONTEXT_MAX = 0x1000
+};
+
+// How a piece of text should be presented. This influences color and style, but
+// typically not size.
+enum TextStyle {
+ // TextStyle enum values must always be greater than any TextContext value.
+ // This allows them to be verified at runtime. E.g. if they have been swapped.
Peter Kasting 2017/03/17 20:59:39 Nit: Maybe "This allows the code to verify at runt
tapted 2017/03/20 07:33:36 Done.
+ VIEWS_TEXT_STYLE_START = TEXT_CONTEXT_MAX,
+
+ // Primary text: solid black, normal weight. Converts to DISABLED in some
+ // contexts (e.g. BUTTON_TEXT, FIELD).
+ STYLE_PRIMARY = VIEWS_TEXT_STYLE_START,
+
+ // Disabled "greyed out" text.
+ STYLE_DISABLED,
+
+ // The style used for links. Usually a solid shade of blue.
+ STYLE_LINK,
+
+ // Active tab in a tabbed pane.
+ STYLE_TAB_ACTIVE,
+
+ // Hovered tab in a tabbed pane.
+ STYLE_TAB_HOVERED,
+
+ // Inactive tab in a tabbed pane.
+ STYLE_TAB_INACTIVE,
+
+ // Embedders must start TextStyle enum values from here.
+ VIEWS_TEXT_STYLE_END
+};
+
+// Helpers to obtain font properties from the TypographyProvider given by the
+// current ViewsDelegate. |context| can be an enum value from TextContext, or a
+// value understood by the embedder's TypographyProvider. Similarly,
+// |text_style| corresponds to TextStyle.
+VIEWS_EXPORT const gfx::FontList& GetFont(int text_context, int text_style);
+VIEWS_EXPORT SkColor GetColor(int text_context, int text_style);
+VIEWS_EXPORT int GetLineHeight(int text_context, int text_style);
+
+} // namespace style
+} // namespace views
+
+#endif // UI_VIEWS_STYLE_TYPOGRAPHY_H_

Powered by Google App Engine
This is Rietveld 408576698