MeshLib C++ Docs
Loading...
Searching...
No Matches
MRRibbonFontManager.h
Go to the documentation of this file.
1#pragma once
2#include "exports.h"
3#include "MRViewerFwd.h"
4#include "MRImGui.h"
5#include <array>
6#include <filesystem>
7
8namespace MR
9{
12
13
14class MRVIEWER_CLASS RibbonFontManager
15{
16public:
17
19 enum class FontType
20 {
21 Default,
22 Small,
23 Middle,
24 SemiBold,
25 Icons,
26 Big,
27 BigSemiBold,
28 Headline,
29 Monospace,
30 Count
31 };
32
34 enum class FontFile
35 {
36 Regular,
37 RegularSC,
38 SemiBold,
39 Monospace,
40 Icons,
41 Count
42 };
43
44 using FontFilePaths = std::array<std::filesystem::path, size_t( FontFile::Count )>;
45
46 MRVIEWER_API RibbonFontManager();
47
49 MRVIEWER_API void loadAllFonts( ImWchar* charRanges );
50
52 MRVIEWER_API ImFont* getFontByType( FontType type ) const;
54 MRVIEWER_API static float getFontSizeByType( FontType type );
55
57 MRVIEWER_API std::filesystem::path getMenuFontPath() const;
58
60 const FontFilePaths& getAllFontPaths() const { return fontPaths_; }
61
64 MRVIEWER_API void setNewFontPaths( const FontFilePaths& paths );
65
68 MRVIEWER_API static ImFont* getFontByTypeStatic( FontType type );
69
72 MRVIEWER_API static FontAndSize getFontAndSizeByTypeStatic( FontType type );
73
76 MRVIEWER_API static void initFontManagerInstance( RibbonFontManager* ribbonFontManager );
77
78private:
79
80 FontFilePaths fontPaths_;
81 struct FontData
82 {
83 FontFile fontFile{ FontFile::RegularSC };
84 Vector2f scaledOffset;
85 ImFont* fontPtr{ nullptr };
86 };
87 std::array<FontData, size_t( FontType::Count )> fonts_;
88
90 static RibbonFontManager*& getFontManagerInstance_();
91
93 void updateFontsScaledOffset_();
94
95 void loadFont_( FontType type, const ImWchar* ranges );
96};
97
98}
Definition MRRibbonFontManager.h:15
static MRVIEWER_API void initFontManagerInstance(RibbonFontManager *ribbonFontManager)
static MRVIEWER_API float getFontSizeByType(FontType type)
get font size by font type
FontFile
Unique fonts that are used for different FontTypes.
Definition MRRibbonFontManager.h:35
static MRVIEWER_API FontAndSize getFontAndSizeByTypeStatic(FontType type)
static MRVIEWER_API ImFont * getFontByTypeStatic(FontType type)
MRVIEWER_API void setNewFontPaths(const FontFilePaths &paths)
const FontFilePaths & getAllFontPaths() const
returns list of all font paths
Definition MRRibbonFontManager.h:60
std::array< std::filesystem::path, size_t(FontFile::Count)> FontFilePaths
Definition MRRibbonFontManager.h:44
FontType
Font types used in current design.
Definition MRRibbonFontManager.h:20
MRVIEWER_API RibbonFontManager()
Vector2f scaledOffset
what file type to use for this font
Definition MRRibbonFontManager.h:84
MRVIEWER_API ImFont * getFontByType(FontType type) const
get font by font type
MRVIEWER_API void loadAllFonts(ImWchar *charRanges)
load all fonts using in ribbon menu
MRVIEWER_API std::filesystem::path getMenuFontPath() const
get ribbon menu font path
@ Middle
GLFW_MOUSE_BUTTON_2.
only for bindings generation
Definition MRCameraOrientationPlugin.h:8