- Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCuiComponent.cpp
More file actions
Latest commit
119 lines (97 loc) · 3.84 KB
/
Copy pathCuiComponent.cpp
File metadata and controls
119 lines (97 loc) · 3.84 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#pragma warning(push, 1)
#include"../columns_ui-sdk/ui_extension.h"
#pragma warning(pop)
#include"ContainerWindow.h"
#include"style_manager.h"
namespace {
classStyleCallback : publiccolumns_ui::colours::common_callback,
public columns_ui::fonts::common_callback {
static_api_ptr_t<cui::colours::manager> colorManager;
static_api_ptr_t<cui::fonts::manager> fontManager;
std::function<void()> callback;
public:
StyleCallback(std::function<void()> callback) : callback(callback) {
colorManager->register_common_callback(this);
fontManager->register_common_callback(this);
}
~StyleCallback() {
colorManager->deregister_common_callback(this);
fontManager->deregister_common_callback(this);
}
voidon_colour_changed(t_size mask) constfinal { callback(); }
voidon_bool_changed(t_size mask) constfinal { callback(); }
voidon_font_changed(t_size mask) constfinal { callback(); }
};
classCuiStyleManager : publicStyleManager {
StyleCallback callback;
public:
CuiStyleManager() : callback([&] { this->onChange(); }) { updateCache(); }
virtualCOLORREFdefaultTitleColor() final {
returncolumns_ui::colours::helper(GUID{}).get_colour(
columns_ui::colours::colour_text);
}
virtualLOGFONTdefaultTitleFont() final {
LOGFONT font;
static_api_ptr_t<cui::fonts::manager> fontManager;
fontManager->get_font(columns_ui::fonts::font_type_items, font);
return font;
}
virtualCOLORREFdefaultBgColor() final {
returncolumns_ui::colours::helper(GUID{}).get_colour(
columns_ui::colours::colour_background);
}
};
classcui_chronflow : publicui_extension::window {
ui_extension::window_host_ptr m_host;
std::optional<ContainerWindow> window;
std::optional<CuiStyleManager> style_manager;
public:
cui_chronflow() = default;
voidget_category(pfc::string_base& out) constfinal { out = "Panels"; }
constGUID& get_extension_guid() constfinal {
// {DA317C70-654F-4A75-A4F2-10F4873773FC}
staticconstGUID guid_foo_chronflow = {
0xda317c70, 0x654f, 0x4a75, {0xa4, 0xf2, 0x10, 0xf4, 0x87, 0x37, 0x73, 0xfc}};
return guid_foo_chronflow;
}
voidget_name(pfc::string_base& out) constfinal { out = "Coverflow"; }
unsignedget_type() constfinal { return ui_extension::type_panel; }
boolis_available(const ui_extension::window_host_ptr& p_host) constfinal {
return !m_host.is_valid() || p_host->get_host_guid() != m_host->get_host_guid();
}
HWNDcreate_or_transfer_window(HWND wnd_parent,
const ui_extension::window_host_ptr& p_host,
const ui_helpers::window_position_t& p_position) final {
if (!window || !window->getHWND()) {
try {
if (!style_manager)
style_manager.emplace();
window.emplace(wnd_parent, *style_manager);
} catch (std::exception& e) {
FB2K_console_formatter()
<< "foo_chronflow panel failed to initialize: " << e.what();
returnnullptr;
}
m_host = p_host;
ShowWindow(window->getHWND(), SW_HIDE);
SetWindowPos(window->getHWND(), nullptr, p_position.x, p_position.y, p_position.cx,
p_position.cy, SWP_NOZORDER);
} else {
ShowWindow(window->getHWND(), SW_HIDE);
SetParent(window->getHWND(), wnd_parent);
SetWindowPos(window->getHWND(), nullptr, p_position.x, p_position.y, p_position.cx,
p_position.cy, SWP_NOZORDER);
m_host->relinquish_ownership(window->getHWND());
m_host = p_host;
}
return window->getHWND();
}
voiddestroy_window() final {
window.reset();
m_host.release();
}
HWNDget_wnd() constfinal { return window->getHWND(); }
constboolget_is_single_instance() constfinal { returntrue; }
};
staticservice_factory_single_t<cui_chronflow> cui_chronflow_instance;
} // namespace