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

Side by Side Diff: ui/views/style/typography_provider.h

Issue 2734113006: "Bootstrap" a toolkit-views Typography spec. (Closed)
Patch Set: Shred Typography class, follow-up on some other things. fix compile. 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 unified diff | Download patch
OLDNEW
(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_PROVIDER_H_
6 #define UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "third_party/skia/include/core/SkColor.h"
12 #include "ui/gfx/font.h"
13 #include "ui/views/views_export.h"
14
15 namespace gfx {
16 class FontList;
17 }
18
19 namespace views {
20
21 class TextContext;
22 class TextStyle;
23
24 // Provides fonts to use in toolkit-views UI.
25 class VIEWS_EXPORT TypographyProvider {
26 public:
27 // Gets the FontList for the given |context| and |style|.
28 virtual const gfx::FontList& GetFont(TextContext context,
29 TextStyle style) const = 0;
30
31 // Gets the color for the given |context| and |style|. This may consult
32 // ui::NativeTheme.
33 virtual SkColor GetColor(TextContext context, TextStyle style) const = 0;
34
35 // Gets the line spacing, or 0 if it should be provided by gfx::FontList.
36 virtual int GetLineSpacing(TextContext context, TextStyle style) const = 0;
tapted 2017/03/15 11:04:07 (note to self: rename to GetLineHeight to match vi
tapted 2017/03/16 11:13:39 Done.
37
38 virtual ~TypographyProvider() = default;
39
40 static void Set(std::unique_ptr<TypographyProvider> provider);
41 static const TypographyProvider& Get();
42
43 protected:
44 TypographyProvider() = default;
45
46 private:
47 DISALLOW_COPY_AND_ASSIGN(TypographyProvider);
48 };
49
50 // The default provider aims to provide values to match pre-Harmony constants
51 // for the given contexts so that old UI does not change.
52 class VIEWS_EXPORT DefaultTypographyProvider : public TypographyProvider {
53 public:
54 DefaultTypographyProvider() = default;
55
56 const gfx::FontList& GetFont(TextContext context,
57 TextStyle style) const override;
58 SkColor GetColor(TextContext context, TextStyle style) const override;
59 int GetLineSpacing(TextContext context, TextStyle style) const override;
60
61 // Describes the font that the default GetFont() implementation uses. Always
62 // writes a value, even for styles it doesn't know about.
63 void GetDefaultFont(TextContext context,
64 TextStyle style,
65 int* size_delta,
66 gfx::Font::Weight* font_weight) const;
67
68 private:
69 DISALLOW_COPY_AND_ASSIGN(DefaultTypographyProvider);
70 };
71
72 } // namespace views
73
74 #endif // UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698