forked from Paremo/foo_bbookmark
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyle_manager.h
More file actions
79 lines (63 loc) · 1.83 KB
/
style_manager.h
File metadata and controls
79 lines (63 loc) · 1.83 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma once
#include <windef.h>
#include <wingdi.h>
#include <functional>
namespace {
class StyleManager {
public:
virtual ~StyleManager() {
setChangeHandler([](bool) {});
}
virtual bool isDark() const = 0;
virtual COLORREF getTitleColor() const = 0;
virtual COLORREF getBgColor() const = 0;
virtual COLORREF getSelColor() const = 0;
virtual COLORREF getHighColor() const = 0;
virtual COLORREF getHotColor() const = 0;
virtual LOGFONT getTitleFont() const = 0;
virtual LOGFONT getListFont() const = 0;
virtual LOGFONT getPlaylistFont() const = 0;
void setChangeHandler(std::function<void(bool)> handler) {
changeHandler = handler;
};
void onChange(uint32_t chg = 0) {
if (glb::g_guiLists.empty()) {
return;
}
updateCache();
if (changeHandler) {
changeHandler(true);
}
}
protected:
virtual COLORREF defaultTitleColor() = 0;
virtual COLORREF defaultBgColor() = 0;
virtual COLORREF defaultSelColor() = 0;
virtual COLORREF defaultHighColor() = 0;
virtual COLORREF defaultHotColor() = 0;
virtual LOGFONT defaultTitleFont() = 0;
virtual LOGFONT defaultListFont() = 0;
virtual LOGFONT defaultPlaylistFont() = 0;
void updateCache() {
cachedTitleColor = defaultTitleColor();
cachedBgColor = defaultBgColor();
cachedSelColor = defaultSelColor();
cachedHighColor = defaultHighColor();
cachedHotColor = defaultHotColor();
cachedTitleFont = defaultTitleFont();
cachedListFont = defaultListFont();
cachedPlaylistFont = defaultPlaylistFont();
}
protected:
COLORREF cachedTitleColor{};
COLORREF cachedBgColor{};
COLORREF cachedSelColor{};
COLORREF cachedHighColor{};
COLORREF cachedHotColor{};
LOGFONT cachedTitleFont{};
LOGFONT cachedListFont{};
LOGFONT cachedPlaylistFont{};
private:
std::function<void(bool)> changeHandler = nullptr;
};
}