Skip to content

Commit 4284155

Browse files
committed
Apply libprojectM API changes (ImGui)
1 parent d3137e2 commit 4284155

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

src/AudioCaptureImpl_SDL.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ bool AudioCaptureImpl::OpenAudioDevice()
116116
if (_currentAudioDeviceID == 0)
117117
{
118118
poco_error_f3(_logger, R"(Failed to open audio device "%s" (ID %?d): %s)",
119-
std::string(deviceName ? deviceName : "System default capturing device"),
119+
std::string(deviceName != nullptr ? deviceName : "System default capturing device"),
120120
_currentAudioDeviceIndex,
121121
std::string(SDL_GetError()));
122122
return false;
@@ -125,7 +125,7 @@ bool AudioCaptureImpl::OpenAudioDevice()
125125
_channels = actualSpecs.channels;
126126

127127
poco_information_f4(_logger, R"(Opened audio recording device "%s" (ID %?d) with %?d channels at %?d Hz.)",
128-
std::string(deviceName ? deviceName : "System default capturing device"),
128+
std::string(deviceName != nullptr ? deviceName : "System default capturing device"),
129129
_currentAudioDeviceIndex,
130130
actualSpecs.channels,
131131
actualSpecs.freq);

src/gui/PresetSelection.cpp

+18-20
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "PresetSelection.h"
22

3+
#include "AnonymousProFont.h"
34
#include "ProjectMWrapper.h"
45
#include "SDLRenderingWindow.h"
5-
#include "AnonymousProFont.h"
66

77
#include "imgui.h"
88
#include "imgui_impl_opengl3.h"
@@ -57,7 +57,7 @@ void PresetSelection::UpdateFontSize()
5757
{
5858
ImGuiIO& io = ImGui::GetIO();
5959

60-
float dpi{96.0f};// Use default value of 96 DPI if SDL_GetDisplayDPI doesn't return a value!
60+
float dpi{96.0f}; // Use default value of 96 DPI if SDL_GetDisplayDPI doesn't return a value!
6161
auto displayIndex = SDL_GetWindowDisplayIndex(_renderingWindow);
6262
if (displayIndex < 0)
6363
{
@@ -91,10 +91,8 @@ void PresetSelection::UpdateFontSize()
9191
void PresetSelection::ProcessInput(const SDL_Event& event)
9292
{
9393
ImGui_ImplSDL2_ProcessEvent(&event);
94-
unsigned int position;
95-
projectm_get_selected_preset_index(_projectMWrapper->ProjectM(), &position);
96-
_playlistPosition = static_cast<int>(position);
97-
_playlistSize = projectm_get_playlist_size(_projectMWrapper->ProjectM());
94+
_playlistPosition = projectm_playlist_get_position(_projectMWrapper->Playlist());
95+
_playlistSize = projectm_playlist_size(_projectMWrapper->Playlist());
9896
}
9997

10098
void PresetSelection::Draw()
@@ -106,26 +104,24 @@ void PresetSelection::Draw()
106104
if (_settingsVisible)
107105
{
108106
DrawSettingsWindow();
109-
110107
}
111108

112-
try {
109+
try
110+
{
113111

114112
if (_fileChooser.Draw())
115113
{
116114
// Preset selected, load & switch.
117115
std::string presetName = Poco::Path(_fileChooser.SelectedFile().path()).getFileName();
118116

119117
int ratingList[2]{};
120-
projectm_add_preset_url(_projectMWrapper->ProjectM(),
121-
_fileChooser.SelectedFile().path().c_str(),
122-
presetName.c_str(),
123-
&ratingList[0], 2);
124-
projectm_select_preset(_projectMWrapper->ProjectM(), projectm_get_playlist_size(_projectMWrapper->ProjectM()) - 1, true);
118+
projectm_playlist_add_preset(_projectMWrapper->Playlist(),
119+
_fileChooser.SelectedFile().path().c_str(),
120+
false);
121+
projectm_playlist_set_position(_projectMWrapper->Playlist(), projectm_playlist_size(_projectMWrapper->Playlist()) - 1, true);
125122
}
126-
127123
}
128-
catch(Poco::Exception& ex)
124+
catch (Poco::Exception& ex)
129125
{
130126
poco_error_f1(_logger, "Exception in file chooser: %s", ex.message());
131127
}
@@ -159,9 +155,9 @@ void PresetSelection::DrawSettingsWindow()
159155
projectm_set_preset_duration(_projectMWrapper->ProjectM(), _displayDuration);
160156
}
161157

162-
if (ImGui::SliderInt("Playlist Position", &_playlistPosition, 0, _playlistSize - 1))
158+
if (ImGui::SliderInt("Playlist Position", reinterpret_cast<int*>(&_playlistPosition), 0, _playlistSize - 1))
163159
{
164-
projectm_select_preset(_projectMWrapper->ProjectM(), _playlistPosition, true);
160+
projectm_playlist_set_position(_projectMWrapper->Playlist(), _playlistPosition, true);
165161
}
166162

167163
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
@@ -175,14 +171,17 @@ void PresetSelection::DrawSettingsWindow()
175171

176172
if (ImGui::Button("Random Preset"))
177173
{
178-
projectm_select_random_preset(_projectMWrapper->ProjectM(), true);
174+
bool shuffleEnabled = projectm_playlist_get_shuffle(_projectMWrapper->Playlist());
175+
projectm_playlist_set_shuffle(_projectMWrapper->Playlist(), true);
176+
projectm_playlist_play_next(_projectMWrapper->Playlist(), true);
177+
projectm_playlist_set_shuffle(_projectMWrapper->Playlist(), shuffleEnabled);
179178
}
180179

181180
ImGui::SameLine();
182181

183182
if (ImGui::Button("Lock Preset"))
184183
{
185-
projectm_lock_preset(_projectMWrapper->ProjectM(), !projectm_is_preset_locked(_projectMWrapper->ProjectM()));
184+
projectm_set_preset_locked(_projectMWrapper->ProjectM(), !projectm_get_preset_locked(_projectMWrapper->ProjectM()));
186185
}
187186

188187
ImGui::SameLine();
@@ -191,7 +190,6 @@ void PresetSelection::DrawSettingsWindow()
191190
{
192191
_fileChooser.Show();
193192
}
194-
195193
}
196194
ImGui::End();
197195
}

src/gui/PresetSelection.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class PresetSelection : public Poco::Util::Subsystem
4848

4949
bool _settingsVisible{ true }; //!< Flag for settings window visibility.
5050
float _displayDuration{ 0.0f }; //!< Preset display time
51-
int _playlistPosition{ 0 }; //!< Playlist position
52-
int _playlistSize{ 0 }; //!< Playlist size
51+
uint32_t _playlistPosition{ 0 }; //!< Playlist position
52+
uint32_t _playlistSize{ 0 }; //!< Playlist size
5353

5454
Poco::Logger& _logger{ Poco::Logger::get("PresetSelectionGui") }; //!< The class logger.
5555

0 commit comments

Comments
 (0)