@@ -57,13 +57,15 @@ class Application : public JUCEApplication {
5757 ignoreUnused (commandLine);
5858 }
5959
60- class MainWindow : public DocumentWindow {
60+ class MainWindow : public DocumentWindow ,
61+ public Controller::Listener {
6162 public:
6263 MainWindow (String name, Controller& vc)
6364 : DocumentWindow (name, Desktop::getInstance().getDefaultLookAndFeel().findColour (ResizableWindow::backgroundColourId),
6465 DocumentWindow::closeButton | DocumentWindow::minimiseButton),
6566 controller (vc)
6667 {
68+ controller.addListener (this );
6769#if JUCE_LINUX
6870 setUsingNativeTitleBar (false );
6971#else
@@ -81,11 +83,14 @@ class Application : public JUCEApplication {
8183 setContentComponentSize (VMC_WIDTH, VMC_HEIGHT);
8284 setResizable (false , false );
8385
86+ deviceChanged ();
87+
8488 setVisible (true );
8589 }
8690
8791 ~MainWindow () override
8892 {
93+ controller.removeListener (this );
8994 clearContentComponent ();
9095 setConstrainer (nullptr );
9196 }
@@ -110,6 +115,12 @@ class Application : public JUCEApplication {
110115 return ;
111116 }
112117
118+ void deviceChanged () override
119+ {
120+ auto name = controller.deviceFile ().getFileNameWithoutExtension ();
121+ setName (" Virtual MIDI Controller - " + name);
122+ }
123+
113124 private:
114125 Controller& controller;
115126 ComponentBoundsConstrainer constrain;
0 commit comments