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 virtual ~TypographyProvider() = default; |
| 23 |
| 24 // Gets the FontList for the given |context| and |style|. |
| 25 virtual const gfx::FontList& GetFont(int context, int style) const = 0; |
| 26 |
| 27 // Gets the color for the given |context| and |style|. This may consult |
| 28 // ui::NativeTheme. |
| 29 virtual SkColor GetColor(int context, int style) const = 0; |
| 30 |
| 31 // Gets the line spacing, or 0 if it should be provided by gfx::FontList. |
| 32 virtual int GetLineHeight(int context, int style) const = 0; |
| 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 // TypographyProvider: |
| 48 const gfx::FontList& GetFont(int context, int style) const override; |
| 49 SkColor GetColor(int context, int style) const override; |
| 50 int GetLineHeight(int context, int style) const override; |
| 51 |
| 52 // Sets the |size_delta| and |font_weight| that the the default GetFont() |
| 53 // implementation uses. Always sets values, even for styles it doesn't know |
| 54 // about. |
| 55 void GetDefaultFont(int context, |
| 56 int style, |
| 57 int* size_delta, |
| 58 gfx::Font::Weight* font_weight) const; |
| 59 |
| 60 private: |
| 61 DISALLOW_COPY_AND_ASSIGN(DefaultTypographyProvider); |
| 62 }; |
| 63 |
| 64 } // namespace views |
| 65 |
| 66 #endif // UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ |
OLD | NEW |