-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathHelpWindow.cpp
171 lines (152 loc) · 5.68 KB
/
HelpWindow.cpp
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include "HelpWindow.h"
#include "imgui.h"
#include <Poco/Util/Application.h>
void HelpWindow::Show()
{
if (_commandLineArguments.empty())
{
FillCommandLineArgumentTable();
}
if (_shortcuts.empty())
{
FillKeyboardShortcutsTable();
}
_visible = true;
ImGui::SetWindowFocus("Help");
}
void HelpWindow::Draw()
{
if (!_visible)
{
return;
}
constexpr ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoCollapse;
constexpr ImGuiTabBarFlags tabBarFlags = ImGuiTabBarFlags_None;
constexpr ImGuiTableFlags tableFlags = ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg;
ImGui::SetNextWindowSize(ImVec2(1000, 600), ImGuiCond_FirstUseEver);
if (ImGui::Begin("Quick Help###Help", &_visible, windowFlags))
{
if (ImGui::BeginTabBar("Help Topics", tabBarFlags))
{
if (ImGui::BeginTabItem("Keyboard Shortcuts"))
{
if (ImGui::BeginTable("Keyboard Shortcuts", 2, tableFlags))
{
ImGui::TableSetupColumn("Function", ImGuiTableColumnFlags_WidthFixed, .0f);
ImGui::TableSetupColumn("Shortcut", ImGuiTableColumnFlags_WidthFixed, .0f);
ImGui::TableHeadersRow();
for (const auto& shortcut : _shortcuts)
{
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::TextUnformatted(shortcut.first.c_str());
ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted(shortcut.second.c_str());
}
ImGui::EndTable();
}
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Command Line Arguments"))
{
if (ImGui::BeginTable("Command Line Arguments", 3, tableFlags))
{
ImGui::TableSetupColumn("Short", ImGuiTableColumnFlags_WidthFixed, .0f);
ImGui::TableSetupColumn("Argument", ImGuiTableColumnFlags_WidthFixed, .0f);
ImGui::TableSetupColumn("Description", ImGuiTableColumnFlags_WidthStretch, .0f);
ImGui::TableHeadersRow();
for (const auto& argument : _commandLineArguments)
{
int columnIndex = 0;
ImGui::TableNextRow();
#ifdef POCO_OS_FAMILY_UNIX
ImGui::TableSetColumnIndex(columnIndex++);
ImGui::TextUnformatted(std::get<0>(argument).c_str());
#endif
ImGui::TableSetColumnIndex(columnIndex++);
ImGui::TextUnformatted(std::get<1>(argument).c_str());
ImGui::TableSetColumnIndex(columnIndex++);
ImGui::TextWrapped("%s", std::get<2>(argument).c_str());
}
ImGui::EndTable();
}
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
}
ImGui::End();
}
void HelpWindow::FillCommandLineArgumentTable()
{
auto& app = Poco::Util::Application::instance();
const auto& options = app.options();
for (const auto& option : options)
{
std::string shortArgument = option.shortName();
std::string longArgument = option.fullName();
std::string description = option.description();
if (option.takesArgument())
{
if (!shortArgument.empty())
{
#ifdef POCO_OS_FAMILY_UNIX
shortArgument = "-" + shortArgument;
#else
shortArgument = "/" + shortArgument;
#endif
if (!option.argumentRequired())
{
shortArgument += "[";
}
shortArgument += option.argumentName();
if (!option.argumentRequired())
{
shortArgument += "]";
}
}
if (!longArgument.empty())
{
#ifdef POCO_OS_FAMILY_UNIX
longArgument = "--" + longArgument;
#else
longArgument = "/" + longArgument;
#endif
if (!option.argumentRequired())
{
longArgument += "[";
}
longArgument += "=" + option.argumentName();
if (!option.argumentRequired())
{
longArgument += "]";
}
}
}
_commandLineArguments.emplace_back(shortArgument, longArgument, description);
}
}
void HelpWindow::FillKeyboardShortcutsTable()
{
_shortcuts = {
{"Quit projectM", "Ctrl+q"},
{"Toggle Menu/UI", "Escape"},
{"Next Preset in Playlist (immediate)", "n"},
{"Next Preset in Playlist (smooth)", "Shift+n"},
{"Previous Preset in Playlist (immediate)", "p"},
{"Previous Preset in Playlist (smooth)", "Shift+p"},
{"Last Played Preset (Back, immediate)", "Backspace"},
{"Last Played Preset (Back, smooth)", "Shift+Backspace"},
{"Random Preset (immediate)", "r"},
{"Random Preset (smooth)", "Shift+r"},
{"Lock Current Preset", "Spacebar"},
{"Toggle Shuffle", "y"},
{"Toggle Fullscreen", "Ctrl-f, Right Mouse"},
{"Toggle Aspect Correction", "Ctrl-a"},
{"Next Audio Input Device", "Ctrl-i"},
{"Move to Next Monitor", "Ctrl-m"},
{"Increase Beat Sensitivity by 1%", "Cursor Up"},
{"Decrease Beat Sensitivity by 1%", "Cursor Down"},
{"Add Random Waveform at Mouse Pointer", "Shift+Left Mouse"},
{"Clear Random Waveforms", "Middle Mouse"}};
}