Skip to content

Commit c431ee5

Browse files
committed
Add about window
1 parent fce3b91 commit c431ee5

File tree

8 files changed

+163
-8
lines changed

8 files changed

+163
-8
lines changed

src/ProjectMWrapper.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,20 @@ void ProjectMWrapper::ChangeBeatSensitivity(float value)
179179
new DisplayToastNotification(Poco::format("Beat Sensitivity: %.2hf", projectm_get_beat_sensitivity(_projectM))));
180180
}
181181

182+
std::string ProjectMWrapper::ProjectMBuildVersion()
183+
{
184+
return PROJECTM_VERSION_STRING;
185+
}
186+
187+
std::string ProjectMWrapper::ProjectMRuntimeVersion()
188+
{
189+
auto* projectMVersion = projectm_get_version_string();
190+
std::string projectMRuntimeVersion(projectMVersion);
191+
projectm_free_string(projectMVersion);
192+
193+
return projectMRuntimeVersion;
194+
}
195+
182196
void ProjectMWrapper::PresetSwitchedEvent(bool isHardCut, unsigned int index, void* context)
183197
{
184198
auto that = reinterpret_cast<ProjectMWrapper*>(context);

src/ProjectMWrapper.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ class ProjectMWrapper : public Poco::Util::Subsystem
6363
*/
6464
void ChangeBeatSensitivity(float value);
6565

66+
/**
67+
* @brief Returns the libprojectM version this application was built against.
68+
* @return A string with the libprojectM build version.
69+
*/
70+
std::string ProjectMBuildVersion();
71+
72+
/**
73+
* @brief Returns the libprojectM version this applications currently runs with.
74+
* @return A string with the libprojectM runtime library version.
75+
*/
76+
std::string ProjectMRuntimeVersion();
77+
6678
private:
6779
/**
6880
* @brief projectM callback. Called whenever a preset is switched.

src/gui/AboutWindow.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#include "AboutWindow.h"
2+
3+
#include "ProjectMGUI.h"
4+
#include "SystemBrowser.h"
5+
6+
#include "ProjectMSDLApplication.h"
7+
#include "ProjectMWrapper.h"
8+
9+
#include <imgui.h>
10+
11+
#include <Poco/Util/Application.h>
12+
13+
AboutWindow::AboutWindow(ProjectMGUI& gui)
14+
: _gui(gui)
15+
, _application(ProjectMSDLApplication::instance())
16+
, _projectMWrapper(Poco::Util::Application::instance().getSubsystem<ProjectMWrapper>())
17+
{
18+
}
19+
20+
void AboutWindow::Show()
21+
{
22+
_visible = true;
23+
}
24+
25+
void AboutWindow::Draw()
26+
{
27+
if (!_visible)
28+
{
29+
return;
30+
}
31+
32+
ImGui::SetNextWindowSize(ImVec2(750, 600), ImGuiCond_FirstUseEver);
33+
if (ImGui::Begin("About the projectM SDL Frontend", &_visible, ImGuiWindowFlags_NoCollapse))
34+
{
35+
_gui.PushToastFont();
36+
ImGui::TextUnformatted("projectM SDL Frontend");
37+
_gui.PopFont();
38+
ImGui::Dummy({.0f, 10.0f});
39+
ImGui::Text("Version: %s", PROJECTMSDL_VERSION);
40+
ImGui::Text("libprojectM: %s (built with %s)", _projectMWrapper.ProjectMRuntimeVersion().c_str(), _projectMWrapper.ProjectMBuildVersion().c_str());
41+
ImGui::Dummy({.0f, 20.0f});
42+
ImGui::TextUnformatted("Brought to you by the projectM Team and contributors!");
43+
ImGui::Dummy({.0f, 10.0f});
44+
ImGui::Separator();
45+
ImGui::Dummy({.0f, 10.0f});
46+
ImGui::TextWrapped("The projectM SDL frontend is open-source software licensed under the GNU General Public License, version 3.");
47+
ImGui::Dummy({.0f, 10.0f});
48+
ImGui::TextWrapped("Get the source code on GitHub or report an issue with the SDL frontend:");
49+
if (ImGui::SmallButton("https://github.com/projectM-visualizer/frontend-sdl2"))
50+
{
51+
SystemBrowser::OpenURL("https://github.com/projectM-visualizer/frontend-sdl2");
52+
}
53+
ImGui::Dummy({.0f, 10.0f});
54+
if (ImGui::CollapsingHeader("Open-Source Software Used in this Application"))
55+
{
56+
ImGui::TextUnformatted("Used in projectM SDL:");
57+
ImGui::BulletText("libprojectM by The projectM Team (GNU LGPL v2.1)");
58+
ImGui::BulletText("Simple DirectMedia Layer 2 (SDL) (zlib License)");
59+
ImGui::BulletText("Dear ImGui by Omar Cornut and contributors (MIT)");
60+
ImGui::BulletText("The POCO C++ Framework by Applied Informatics GmbH (MIT)");
61+
ImGui::BulletText("FreeType 2 (FreeType License / GNU GPL v2)");
62+
63+
ImGui::Dummy({.0f, 10.0f});
64+
ImGui::TextUnformatted("Via libprojectM:");
65+
ImGui::BulletText("projectm-eval by The projectM Team (MIT)");
66+
ImGui::BulletText("SOIL2 by Martín Lucas Golini (MIT-0)");
67+
ImGui::BulletText("hlslparser by Unknown Worlds Entertainment, Inc. (MIT)");
68+
ImGui::BulletText("OpenGL Mathematics (GLM) by G-Truc Creation (The Happy Bunny License)");
69+
}
70+
}
71+
ImGui::End();
72+
}

src/gui/AboutWindow.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#pragma once
2+
3+
#include <string>
4+
5+
class ProjectMGUI;
6+
class ProjectMSDLApplication;
7+
class ProjectMWrapper;
8+
9+
class AboutWindow
10+
{
11+
public:
12+
explicit AboutWindow(ProjectMGUI& gui);
13+
14+
~AboutWindow() = default;
15+
16+
/**
17+
* @brief Displays the about window.
18+
*/
19+
void Show();
20+
21+
/**
22+
* @brief Draws the about window.
23+
*/
24+
void Draw();
25+
26+
private:
27+
ProjectMGUI& _gui; //!< Reference to the projectM GUI instance
28+
ProjectMSDLApplication& _application;
29+
ProjectMWrapper& _projectMWrapper;
30+
31+
bool _visible{false};
32+
};

src/gui/CMakeLists.txt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Font embedding
2-
if(CMAKE_CROSSCOMPILING)
2+
if (CMAKE_CROSSCOMPILING)
33
find_program(BINARY_TO_COMPRESSED_EXECUTABLE binary_to_compressed_c)
4-
if(NOT BINARY_TO_COMPRESSED_EXECUTABLE)
4+
if (NOT BINARY_TO_COMPRESSED_EXECUTABLE)
55
message(FATAL_ERROR "Could not find host-executable \"binary_to_compressed_c\" tool. Add its location to CMAKE_PREFIX_PATH.")
6-
endif()
7-
else()
6+
endif ()
7+
else ()
88
set(BINARY_TO_COMPRESSED_EXECUTABLE "$<TARGET_FILE:ImGuiBinaryToCompressedC>")
9-
endif()
9+
endif ()
1010

1111
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AnonymousProFont.h"
1212
COMMAND ${BINARY_TO_COMPRESSED_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/resources/AnonymousPro-Regular.ttf" AnonymousPro > "${CMAKE_CURRENT_BINARY_DIR}/AnonymousProFont.h"
@@ -21,19 +21,30 @@ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/LiberationSansFont.h"
2121
add_library(ProjectMSDL-GUI STATIC
2222
"${CMAKE_CURRENT_BINARY_DIR}/AnonymousProFont.h"
2323
"${CMAKE_CURRENT_BINARY_DIR}/LiberationSansFont.h"
24+
AboutWindow.cpp
25+
AboutWindow.h
2426
FileChooser.cpp
2527
FileChooser.h
28+
HelpWindow.cpp
29+
HelpWindow.h
2630
MainMenu.cpp
2731
MainMenu.h
2832
PresetSelection.cpp
2933
PresetSelection.h
3034
ProjectMGUI.cpp
3135
ProjectMGUI.h
36+
SettingsWindow.cpp
37+
SettingsWindow.h
38+
SystemBrowser.cpp
39+
SystemBrowser.h
3240
ToastMessage.cpp
3341
ToastMessage.h
34-
HelpWindow.cpp HelpWindow.h SettingsWindow.cpp SettingsWindow.h
35-
SystemBrowser.cpp
36-
SystemBrowser.h)
42+
)
43+
44+
target_compile_definitions(ProjectMSDL-GUI
45+
PRIVATE
46+
PROJECTMSDL_VERSION="${PROJECT_VERSION}"
47+
)
3748

3849
target_include_directories(ProjectMSDL-GUI
3950
PUBLIC

src/gui/MainMenu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ void MainMenu::Draw()
146146

147147
if (ImGui::MenuItem("About projectM..."))
148148
{
149+
_gui.ShowAboutWindow();
149150
}
150151

151152
ImGui::Separator();

src/gui/ProjectMGUI.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ void ProjectMGUI::Draw()
163163
{
164164
_mainMenu.Draw();
165165
_settingsWindow.Draw();
166+
_aboutWindow.Draw();
166167
_helpWindow.Draw();
167168
}
168169

@@ -202,6 +203,11 @@ void ProjectMGUI::ShowSettingsWindow()
202203
_settingsWindow.Show();
203204
}
204205

206+
void ProjectMGUI::ShowAboutWindow()
207+
{
208+
_aboutWindow.Show();
209+
}
210+
205211
void ProjectMGUI::ShowHelpWindow()
206212
{
207213
_helpWindow.Show();

src/gui/ProjectMGUI.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include "AboutWindow.h"
34
#include "HelpWindow.h"
45
#include "MainMenu.h"
56
#include "ToastMessage.h"
@@ -93,6 +94,11 @@ class ProjectMGUI : public Poco::Util::Subsystem
9394
*/
9495
void ShowSettingsWindow();
9596

97+
/**
98+
* @brief Displays the about window.
99+
*/
100+
void ShowAboutWindow();
101+
96102
/**
97103
* @brief Displays the help window.
98104
*/
@@ -118,6 +124,7 @@ class ProjectMGUI : public Poco::Util::Subsystem
118124

119125
MainMenu _mainMenu{*this};
120126
SettingsWindow _settingsWindow{*this}; //!< The settings window.
127+
AboutWindow _aboutWindow{*this}; //!< The about window.
121128
HelpWindow _helpWindow; //!< Help window with shortcuts and tips.
122129

123130
std::unique_ptr<ToastMessage> _toast; //!< Current toast to be displayed.

0 commit comments

Comments
 (0)