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
32
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 {
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
std::pair< ImFont *, float > FontAndSize
Definition MRViewerFwd.h:90
FontFile
Unique fonts that are used for different FontTypes.
Definition MRRibbonFontManager.h:35
static float getFontSizeByType(FontType type)
get font size by font type
ImFont * fontPtr
offset that is used for each glyph while creating atlas (updates in updateFontsScaledOffset_),...
Definition MRRibbonFontManager.h:85
void setNewFontPaths(const FontFilePaths &paths)
static FontAndSize getFontAndSizeByTypeStatic(FontType type)
static void initFontManagerInstance(RibbonFontManager *ribbonFontManager)
ImFont * getFontByType(FontType type) const
get font by font type
static ImFont * getFontByTypeStatic(FontType type)
FontFile fontFile
Definition MRRibbonFontManager.h:83
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
Vector2f scaledOffset
what file type to use for this font
Definition MRRibbonFontManager.h:84
void loadAllFonts(ImWchar *charRanges)
load all fonts using in ribbon menu
std::filesystem::path getMenuFontPath() const
get ribbon menu font path
@ RegularSC
Definition MRRibbonFontManager.h:37
@ Regular
Definition MRRibbonFontManager.h:36
@ Count
Definition MRRibbonFontManager.h:41
@ BigSemiBold
Definition MRRibbonFontManager.h:27
@ Small
Definition MRRibbonFontManager.h:22
@ SemiBold
Definition MRRibbonFontManager.h:24
@ Default
Definition MRRibbonFontManager.h:21
@ Icons
Definition MRRibbonFontManager.h:25
@ Monospace
Definition MRRibbonFontManager.h:29
@ Middle
Definition MRRibbonFontManager.h:23
@ Headline
Definition MRRibbonFontManager.h:28
@ Big
Definition MRRibbonFontManager.h:26
@ Count
Definition MRRibbonFontManager.h:30
only for bindings generation
Definition MRCameraOrientationPlugin.h:8