Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions .github/workflows/buildcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ jobs:
cmake --build cmake-build-libprojectm --parallel
cmake --install "${{ github.workspace }}/cmake-build-libprojectm"

- name: Build/Install projectm-eval
run: |
mkdir cmake-build-projectm-eval
cmake -G Ninja -S projectm/vendor/projectm-eval -B cmake-build-projectm-eval -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install-projectm-eval
cmake --build cmake-build-projectm-eval --parallel
cmake --install "${{ github.workspace }}/cmake-build-projectm-eval"

- name: Checkout frontend-sdl2 Sources
uses: actions/checkout@v4
with:
Expand All @@ -75,7 +82,7 @@ jobs:
mkdir cmake-build-frontend-sdl2
cmake -G Ninja -S frontend-sdl2 -B cmake-build-frontend-sdl2 \
-DCMAKE_BUILD_TYPE=Release \
"-DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install-libprojectm;${GITHUB_WORKSPACE}/install-poco" \
"-DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install-libprojectm;${{ github.workspace }}/install-projectm-eval;${GITHUB_WORKSPACE}/install-poco" \
"-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install-frontend-sdl2"
cmake --build cmake-build-frontend-sdl2 --parallel

Expand Down Expand Up @@ -126,20 +133,6 @@ jobs:
setapikey "${{ secrets.VCPKG_PACKAGES_TOKEN }}" `
-Source "${{ env.FEED_URL }}"

- name: Checkout libprojectM Sources
uses: actions/checkout@v4
with:
repository: projectM-visualizer/projectm
path: projectm
submodules: recursive

- name: Build/Install libprojectM
run: |
mkdir cmake-build-libprojectm
cmake -G "Visual Studio 17 2022" -A "X64" -S "${{ github.workspace }}/projectm" -B "${{ github.workspace }}/cmake-build-libprojectm" -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install-libprojectm" -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>" -DCMAKE_VERBOSE_MAKEFILE=YES -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=NO
cmake --build "${{ github.workspace }}/cmake-build-libprojectm" --config Release --parallel
cmake --install "${{ github.workspace }}/cmake-build-libprojectm" --config Release

- name: Checkout projectMSDL Sources
uses: actions/checkout@v4
with:
Expand All @@ -149,7 +142,7 @@ jobs:
- name: Build projectMSDL
run: |
mkdir cmake-build-frontend-sdl2
cmake -G "Visual Studio 17 2022" -A "X64" -S "${{ github.workspace }}/frontend-sdl2" -B "${{ github.workspace }}/cmake-build-frontend-sdl2" -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_PREFIX_PATH="${{ github.workspace }}/install-libprojectm" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install-frontend-sdl2" -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>" -DCMAKE_VERBOSE_MAKEFILE=YES -DSDL2_LINKAGE=static -DBUILD_TESTING=YES
cmake -G "Visual Studio 17 2022" -A "X64" -S "${{ github.workspace }}/frontend-sdl2" -B "${{ github.workspace }}/cmake-build-frontend-sdl2" -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install-frontend-sdl2" -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>" -DCMAKE_VERBOSE_MAKEFILE=YES -DSDL2_LINKAGE=static -DBUILD_TESTING=YES
cmake --build "${{ github.workspace }}/cmake-build-frontend-sdl2" --parallel --config Release

- name: Package projectMSDL
Expand Down Expand Up @@ -181,10 +174,17 @@ jobs:
- name: Build/Install libprojectM
run: |
mkdir cmake-build-libprojectm
cmake -G Ninja -S "${{ github.workspace }}/projectm" -B "${{ github.workspace }}/cmake-build-libprojectm" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install-libprojectm"
cmake -G Ninja -S "${{ github.workspace }}/projectm" -B "${{ github.workspace }}/cmake-build-libprojectm" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install-libprojectm;"
cmake --build "${{ github.workspace }}/cmake-build-libprojectm" --parallel
cmake --install "${{ github.workspace }}/cmake-build-libprojectm"

- name: Build/Install projectm-eval
run: |
mkdir cmake-build-projectm-eval
cmake -G Ninja -S "${{ github.workspace }}/projectm/vendor/projectm-eval" -B "${{ github.workspace }}/cmake-build-projectm-eval" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install-projectm-eval"
cmake --build "${{ github.workspace }}/cmake-build-projectm-eval" --parallel
cmake --install "${{ github.workspace }}/cmake-build-projectm-eval"

- name: Checkout projectMSDL Sources
uses: actions/checkout@v4
with:
Expand All @@ -194,7 +194,7 @@ jobs:
- name: Build projectMSDL
run: |
mkdir cmake-build-frontend-sdl2
cmake -G Ninja -S "${{ github.workspace }}/frontend-sdl2" -B "${{ github.workspace }}/cmake-build-frontend-sdl2" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="${{ github.workspace }}/install-libprojectm" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install-frontend-sdl2"
cmake -G Ninja -S "${{ github.workspace }}/frontend-sdl2" -B "${{ github.workspace }}/cmake-build-frontend-sdl2" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="${{ github.workspace }}/install-libprojectm;${{ github.workspace }}/install-projectm-eval" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install-frontend-sdl2"
cmake --build "${{ github.workspace }}/cmake-build-frontend-sdl2" --parallel

- name: Package projectMSDL
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ if(NOT SDL2_LINKAGE STREQUAL "shared" AND NOT SDL2_LINKAGE STREQUAL "static")
endif()

find_package(projectM4 REQUIRED COMPONENTS Playlist)
find_package(projectM-Eval REQUIRED)
find_package(SDL2 REQUIRED)
find_package(Poco REQUIRED COMPONENTS JSON XML Util Foundation)

Expand Down
73 changes: 73 additions & 0 deletions src/ProjectMWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,31 @@ projectm_playlist_handle ProjectMWrapper::Playlist() const
return _playlist;
}

bool ProjectMWrapper::LoadPresetData(const std::string& presetData, std::string& errorMessage)
{
projectm_load_preset_data(_projectM, presetData.c_str(), false);

if (_presetLoadFailed)
{
errorMessage = _presetLoadFailedMessage;
_presetLoadFailed = false;
return false;
}

return true;
}

void ProjectMWrapper::UnbindPlaylist()
{
projectm_playlist_connect(_playlist, nullptr);
}

void ProjectMWrapper::BindPlaylist()
{
projectm_playlist_connect(_playlist, _projectM);
projectm_playlist_set_position(_playlist, projectm_playlist_get_position(_playlist), false);
}

int ProjectMWrapper::TargetFPS()
{
return _projectMConfigView->getInt("fps", 60);
Expand Down Expand Up @@ -206,6 +231,42 @@ std::string ProjectMWrapper::ProjectMRuntimeVersion()
return projectMRuntimeVersion;
}

std::string ProjectMWrapper::CurrentPresetFileName() const
{
if (projectm_playlist_size(_playlist) == 0)
{
return {};
}

auto presetName = projectm_playlist_item(_playlist, projectm_playlist_get_position(_playlist));
std::string presetNameString(presetName);
projectm_playlist_free_string(presetName);

if (presetNameString.substr(0, 5) == "idle:")
{
return {};
}

return presetNameString;
}

void ProjectMWrapper::EnablePlaybackControl(bool enable)
{
_playbackControlEnabled = enable;
}

void ProjectMWrapper::HardLockPreset(bool lock)
{
if (lock)
{
projectm_set_preset_locked(_projectM, true);
}
else
{
projectm_set_preset_locked(_projectM, _userConfig->getBool("projectM.presetLocked", false));
}
}

void ProjectMWrapper::PresetFileNameToClipboard() const
{
auto presetName = projectm_playlist_item(_playlist, projectm_playlist_get_position(_playlist));
Expand All @@ -223,8 +284,20 @@ void ProjectMWrapper::PresetSwitchedEvent(bool isHardCut, unsigned int index, vo
Poco::NotificationCenter::defaultCenter().postNotification(new UpdateWindowTitleNotification);
}

void ProjectMWrapper::PresetSwitchFailedEvent(const char* presetFilename, const char* message, void* context)
{
auto that = reinterpret_cast<ProjectMWrapper*>(context);
that->_presetLoadFailedMessage = message;
that->_presetLoadFailed = true;
}

void ProjectMWrapper::PlaybackControlNotificationHandler(const Poco::AutoPtr<PlaybackControlNotification>& notification)
{
if (!_playbackControlEnabled)
{
return;
}

bool shuffleEnabled = projectm_playlist_get_shuffle(_playlist);

switch (notification->ControlAction())
Expand Down
46 changes: 44 additions & 2 deletions src/ProjectMWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "notifications/PlaybackControlNotification.h"

#include <projectM-4/projectM.h>
#include <projectM-4/playlist.h>
#include <projectM-4/projectM.h>

#include <Poco/Logger.h>
#include <Poco/NObserver.h>
Expand Down Expand Up @@ -34,6 +34,24 @@ class ProjectMWrapper : public Poco::Util::Subsystem
*/
projectm_playlist_handle Playlist() const;

/**
* @brief Detaches the current playlist and loads a single preset.
* @param presetData The preset data to load.
* @param errorMessage The error message from projectM if loading failed.
* @return true if the preset was loaded successfully, false if an error occurred.
*/
bool LoadPresetData(const std::string& presetData, std::string& errorMessage);

/**
* @brief Detaches the internal playlist, so it no longer controls the preset playback.
*/
void UnbindPlaylist();

/**
* @brief Binds the internal playlist and resets the preset lock to the user setting.
*/
void BindPlaylist();

/**
* Renders a single projectM frame.
*/
Expand Down Expand Up @@ -70,11 +88,29 @@ class ProjectMWrapper : public Poco::Util::Subsystem
std::string ProjectMBuildVersion();

/**
* @brief Returns the libprojectM version this applications currently runs with.
* @brief Returns the libprojectM version this application currently runs with.
* @return A string with the libprojectM runtime library version.
*/
std::string ProjectMRuntimeVersion();

/**
* @brief Returns the full path of the currently displayed preset.
* @return The full path of the currently displayed preset, or an empty string if the idle preset is loaded.
*/
std::string CurrentPresetFileName() const;

/**
* @brief Toggles handling of playback control notifications.
* @param enable true to enable handling of playback control notifications, false to disable.
*/
void EnablePlaybackControl(bool enable);

/**
* @brief Locks or unlocks the current preset without changing the user setting.
* @param lock true to lock the current preset, false to enable auto-switching.
*/
void HardLockPreset(bool lock);

/**
* Copies the full path of the current preset into the OS clipboard.
*/
Expand All @@ -89,6 +125,8 @@ class ProjectMWrapper : public Poco::Util::Subsystem
*/
static void PresetSwitchedEvent(bool isHardCut, unsigned int index, void* context);

static void PresetSwitchFailedEvent(const char* presetFilename, const char* message, void* context);

void PlaybackControlNotificationHandler(const Poco::AutoPtr<PlaybackControlNotification>& notification);

std::vector<std::string> GetPathListWithDefault(const std::string& baseKey, const std::string& defaultPath);
Expand All @@ -110,6 +148,10 @@ class ProjectMWrapper : public Poco::Util::Subsystem

projectm_handle _projectM{nullptr}; //!< Pointer to the projectM instance used by the application.
projectm_playlist_handle _playlist{nullptr}; //!< Pointer to the projectM playlist manager instance.
bool _playbackControlEnabled{true}; //!< If false, any playback control notifications are ignored.

bool _presetLoadFailed{false};
std::string _presetLoadFailedMessage;

Poco::NObserver<ProjectMWrapper, PlaybackControlNotification> _playbackControlNotificationObserver{*this, &ProjectMWrapper::PlaybackControlNotificationHandler};

Expand Down
1 change: 1 addition & 0 deletions src/RenderLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "gui/ProjectMGUI.h"

#include <Poco/File.h>
#include <Poco/NotificationCenter.h>

#include <Poco/Util/Application.h>
Expand Down
10 changes: 8 additions & 2 deletions src/SDLRenderingWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,17 @@ SDL_GLContext SDLRenderingWindow::GetGlContext() const

void SDLRenderingWindow::UpdateWindowTitleNotificationHandler(POCO_UNUSED const Poco::AutoPtr<UpdateWindowTitleNotification>& notification)
{
UpdateWindowTitle();
UpdateWindowTitle(notification->_customTitle);
}

void SDLRenderingWindow::UpdateWindowTitle()
void SDLRenderingWindow::UpdateWindowTitle(const std::string& customTitle)
{
if (!customTitle.empty())
{
SDL_SetWindowTitle(_renderingWindow, customTitle.c_str());
return;
}

std::string newTitle = "projectM";

if (_config->getBool("displayPresetNameInTitle", true))
Expand Down
2 changes: 1 addition & 1 deletion src/SDLRenderingWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class SDLRenderingWindow : public Poco::Util::Subsystem
/**
* @brief Updates the window title.
*/
void UpdateWindowTitle();
void UpdateWindowTitle(const std::string& customTitle = "");

/**
* @brief Updates the swap interval from the user settings.
Expand Down
8 changes: 5 additions & 3 deletions src/gui/AboutWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "AboutWindow.h"

#include "IconsFontAwesome7.h"
#include "ProjectMGUI.h"
#include "SystemBrowser.h"

Expand Down Expand Up @@ -30,7 +31,7 @@ void AboutWindow::Draw()
}

ImGui::SetNextWindowSize(ImVec2(750, 600), ImGuiCond_FirstUseEver);
if (ImGui::Begin("About the projectM SDL Frontend###About", &_visible, ImGuiWindowFlags_NoCollapse))
if (ImGui::Begin(ICON_FA_INFO " About the projectM SDL Frontend###About", &_visible, ImGuiWindowFlags_NoCollapse))
{
_gui.PushToastFont();
ImGui::TextUnformatted("projectM SDL Frontend");
Expand All @@ -46,9 +47,9 @@ void AboutWindow::Draw()
ImGui::TextWrapped("The projectM SDL frontend is open-source software licensed under the GNU General Public License, version 3.");
ImGui::Dummy({.0f, 10.0f});
ImGui::TextWrapped("Get the source code on GitHub or report an issue with the SDL frontend:");
if (ImGui::SmallButton("https://github.com/projectM-visualizer/frontend-sdl2"))
if (ImGui::SmallButton(ICON_FA_ARROW_UP_RIGHT_FROM_SQUARE " https://github.com/projectM-visualizer/frontend-sdl-cpp"))
{
SystemBrowser::OpenURL("https://github.com/projectM-visualizer/frontend-sdl2");
SystemBrowser::OpenURL("https://github.com/projectM-visualizer/frontend-sdl-cpp");
}
ImGui::Dummy({.0f, 10.0f});
if (ImGui::CollapsingHeader("Open-Source Software Used in this Application"))
Expand All @@ -59,6 +60,7 @@ void AboutWindow::Draw()
ImGui::BulletText("Dear ImGui by Omar Cornut and contributors (MIT)");
ImGui::BulletText("The POCO C++ Framework by Applied Informatics GmbH (MIT)");
ImGui::BulletText("FreeType 2 (FreeType License / GNU GPL v2)");
ImGui::BulletText("FontAwesome Free Icons v7 (FontAwesome License / SIL OFL 1.1)");

ImGui::Dummy({.0f, 10.0f});
ImGui::TextUnformatted("Via libprojectM:");
Expand Down
15 changes: 15 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,28 @@ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/LiberationSansFont.h"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/src/resources/LiberationSans-Regular.ttf"
)

add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/FontAwesomeIconsRegular7.h"
COMMAND ${BINARY_TO_COMPRESSED_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/resources/fa-regular-400.ttf" FontAwesomeIconsRegular7 > "${CMAKE_CURRENT_BINARY_DIR}/FontAwesomeIconsRegular7.h"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/src/resources/fa-regular-400.ttf"
)

add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/FontAwesomeIconsSolid7.h"
COMMAND ${BINARY_TO_COMPRESSED_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/resources/fa-solid-900.ttf" FontAwesomeIconsSolid7 > "${CMAKE_CURRENT_BINARY_DIR}/FontAwesomeIconsSolid7.h"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/src/resources/fa-solid-900.ttf"
)

add_library(ProjectMSDL-GUI STATIC
"${CMAKE_CURRENT_BINARY_DIR}/AnonymousProFont.h"
"${CMAKE_CURRENT_BINARY_DIR}/LiberationSansFont.h"
"${CMAKE_CURRENT_BINARY_DIR}/FontAwesomeIconsRegular7.h"
"${CMAKE_CURRENT_BINARY_DIR}/FontAwesomeIconsSolid7.h"
AboutWindow.cpp
AboutWindow.h
FileChooser.cpp
FileChooser.h
HelpWindow.cpp
HelpWindow.h
IconsFontAwesome7.h
MainMenu.cpp
MainMenu.h
PresetSelection.cpp
Expand Down Expand Up @@ -54,9 +67,11 @@ target_include_directories(ProjectMSDL-GUI

target_link_libraries(ProjectMSDL-GUI
PUBLIC
PresetEditor
Poco::Util
ImGui
libprojectM::projectM
"$<$<PLATFORM_ID:Darwin>:-framework ApplicationServices>"
)

add_subdirectory(preset_editor)
Loading
Loading