@@ -19,6 +19,16 @@ void RenderLoop::Run()
19
19
FPSLimiter limiter;
20
20
limiter.TargetFPS (_projectMWrapper.TargetFPS ());
21
21
22
+ projectm_set_preset_switched_event_callback (_projectMHandle, &RenderLoop::PresetSwitchedEvent,
23
+ static_cast <void *>(this ));
24
+
25
+ // Update title bar with initial preset.
26
+ unsigned int currentIndex;
27
+ if (projectm_get_selected_preset_index (_projectMHandle, ¤tIndex))
28
+ {
29
+ PresetSwitchedEvent (true , currentIndex, this );
30
+ }
31
+
22
32
while (!_wantsToQuit)
23
33
{
24
34
limiter.StartFrame ();
@@ -27,6 +37,8 @@ void RenderLoop::Run()
27
37
_sdlRenderingWindow.Swap ();
28
38
limiter.EndFrame ();
29
39
}
40
+
41
+ projectm_set_preset_switched_event_callback (_projectMHandle, nullptr , nullptr );
30
42
}
31
43
32
44
void RenderLoop::PollEvents ()
@@ -331,7 +343,7 @@ void RenderLoop::ScrollEvent(const SDL_MouseWheelEvent& event)
331
343
{
332
344
projectm_select_previous_preset (_projectMHandle, true );
333
345
}
334
- // Wheel down is negative
346
+ // Wheel down is negative
335
347
else if (event.y < 0 )
336
348
{
337
349
projectm_select_next_preset (_projectMHandle, true );
@@ -386,3 +398,15 @@ void RenderLoop::MouseUpEvent(const SDL_MouseButtonEvent& event)
386
398
_mouseDown = false ;
387
399
}
388
400
}
401
+
402
+ void RenderLoop::PresetSwitchedEvent (bool isHardCut, unsigned int index, void * context)
403
+ {
404
+ auto that = reinterpret_cast <RenderLoop*>(context);
405
+ auto presetName = projectm_get_preset_name (that->_projectMHandle , index );
406
+ SDL_LogInfo (SDL_LOG_CATEGORY_APPLICATION, " Displaying preset: %s\n " , presetName);
407
+
408
+ std::string newTitle = " projectM ➫ " + std::string (presetName);
409
+ projectm_free_string (presetName);
410
+
411
+ that->_sdlRenderingWindow .SetTitle (newTitle);
412
+ }
0 commit comments