forked from hoffstadt/DearPyGui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmvFontManager.h
More file actions
53 lines (43 loc) · 1.34 KB
/
Copy pathmvFontManager.h
File metadata and controls
53 lines (43 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include <string>
#include <unordered_map>
#include <imgui.h>
#include "mvContext.h"
#include "mvToolWindow.h"
class mvFontManager : public mvToolWindow
{
public:
mvFontManager();
void updateAtlas();
float& getGlobalFontScale() { return _globalFontScale; }
void setGlobalFontScale(float scale);
bool isDefaultFont(const std::shared_ptr<mvAppItem>& item)
{
return (_defaultFont.lock() == item);
}
void setDefaultFont(const std::shared_ptr<mvAppItem>& font)
{
_defaultFont = font;
_updateDefault = true;
}
void clearDefaultFont()
{
_defaultFont.reset();
_updateDefault = true;
}
mvUUID getUUID() const override { return MV_TOOL_FONT_UUID; }
const char* getTitle() const override { return "Font Manager"; }
protected:
void drawWidgets() override;
void drawFontNode(ImFont* font);
void drawFontSelector(const char* label);
public:
// Must be a mvFont (or empty)
std::weak_ptr<mvAppItem> _defaultFont;
// The only reason we need this _updateDefault flag is for "Set as default"
// buttons work in Font Manager window and in ImGui Style Editor. If not for those
// buttons, we could set the default font every frame all the time.
// Updates are blocked whenever the user clicks one of those "Set as default" buttons.
bool _updateDefault = true;
float _globalFontScale = 1.0f;
};