Skip to content

Commit 8f6301b

Browse files
committed
Display locked state in the window title.
1 parent 95cfabc commit 8f6301b

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/RenderLoop.cpp

+18-3
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ void RenderLoop::KeyEvent(const SDL_KeyboardEvent& event, bool down)
206206

207207
case SDLK_SPACE:
208208
projectm_set_preset_locked(_projectMHandle, !projectm_get_preset_locked(_projectMHandle));
209+
UpdateWindowTitle();
209210
break;
210211

211212
case SDLK_UP:
@@ -286,10 +287,24 @@ void RenderLoop::PresetSwitchedEvent(bool isHardCut, unsigned int index, void* c
286287
{
287288
auto that = reinterpret_cast<RenderLoop*>(context);
288289
auto presetName = projectm_playlist_item(that->_playlistHandle, index);
289-
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Displaying preset: %s\n", presetName);
290+
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Displaying preset: %s\n", presetName);;
291+
projectm_free_string(presetName);
292+
293+
that->UpdateWindowTitle();
294+
}
295+
296+
void RenderLoop::UpdateWindowTitle()
297+
{
298+
auto presetName = projectm_playlist_item(_playlistHandle, projectm_playlist_get_position(_playlistHandle));
290299

291-
std::string newTitle = "projectM ➫ " + std::string(presetName);
300+
Poco::Path presetFile(presetName);
292301
projectm_free_string(presetName);
293302

294-
that->_sdlRenderingWindow.SetTitle(newTitle);
303+
std::string newTitle = "projectM ➫ " + presetFile.getBaseName();
304+
if (projectm_get_preset_locked(_projectMHandle))
305+
{
306+
newTitle += " [locked]";
307+
}
308+
309+
_sdlRenderingWindow.SetTitle(newTitle);
295310
}

src/RenderLoop.h

+5
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ class RenderLoop
6969
*/
7070
static void PresetSwitchedEvent(bool isHardCut, unsigned int index, void* context);
7171

72+
/**
73+
* Sets the window title to the current preset name.
74+
*/
75+
void UpdateWindowTitle();
76+
7277
AudioCapture& _audioCapture;
7378
ProjectMWrapper& _projectMWrapper;
7479
SDLRenderingWindow& _sdlRenderingWindow;

0 commit comments

Comments
 (0)