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_PROVIDER_H_ | |
| 6 #define UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "third_party/skia/include/core/SkColor.h" | |
| 10 #include "ui/gfx/font.h" | |
| 11 #include "ui/views/views_export.h" | |
| 12 | |
| 13 namespace gfx { | |
| 14 class FontList; | |
| 15 } | |
| 16 | |
| 17 namespace views { | |
| 18 | |
| 19 // Provides fonts to use in toolkit-views UI. | |
| 20 class VIEWS_EXPORT TypographyProvider { | |
| 21 public: | |
| 22 // Gets the FontList for the given |context| and |style|. | |
| 23 virtual const gfx::FontList& GetFont(int context, int style) const = 0; | |
| 24 | |
| 25 // Gets the color for the given |context| and |style|. This may consult | |
| 26 // ui::NativeTheme. | |
| 27 virtual SkColor GetColor(int context, int style) const = 0; | |
| 28 | |
| 29 // Gets the line spacing, or 0 if it should be provided by gfx::FontList. | |
| 30 virtual int GetLineHeight(int context, int style) const = 0; | |
| 31 | |
| 32 virtual ~TypographyProvider() = default; | |
|
Peter Kasting
2017/03/17 02:26:01
Nit: Destructor before the other methods; see http
tapted
2017/03/17 10:33:11
Done.
| |
| 33 | |
| 34 protected: | |
| 35 TypographyProvider() = default; | |
| 36 | |
| 37 private: | |
| 38 DISALLOW_COPY_AND_ASSIGN(TypographyProvider); | |
| 39 }; | |
| 40 | |
| 41 // The default provider aims to provide values to match pre-Harmony constants | |
| 42 // for the given contexts so that old UI does not change. | |
| 43 class VIEWS_EXPORT DefaultTypographyProvider : public TypographyProvider { | |
| 44 public: | |
| 45 DefaultTypographyProvider() = default; | |
| 46 | |
| 47 const gfx::FontList& GetFont(int context, int style) const override; | |
| 48 SkColor GetColor(int context, int style) const override; | |
| 49 int GetLineHeight(int context, int style) const override; | |
| 50 | |
| 51 // Describes the font that the default GetFont() implementation uses. Always | |
|
Peter Kasting
2017/03/17 02:26:01
Nit: Maybe "Describes" -> "Sets the |size_delta| a
tapted
2017/03/17 10:33:11
Done.
| |
| 52 // writes a value, even for styles it doesn't know about. | |
|
Peter Kasting
2017/03/17 02:26:01
Nit: "writes a value" -> "sets values"?
tapted
2017/03/17 10:33:11
Done.
| |
| 53 void GetDefaultFont(int context, | |
| 54 int style, | |
| 55 int* size_delta, | |
| 56 gfx::Font::Weight* font_weight) const; | |
| 57 | |
| 58 private: | |
| 59 DISALLOW_COPY_AND_ASSIGN(DefaultTypographyProvider); | |
| 60 }; | |
| 61 | |
| 62 } // namespace views | |
| 63 | |
| 64 #endif // UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ | |
| OLD | NEW |