NanoOcp
Minimal AES70 / OCP.1 TCP client/server library for d&b Soundscape devices
Loading...
Searching...
No Matches
Main.cpp
Go to the documentation of this file.
1/* Copyright (c) 2020-2023, Christian Ahrens
2 *
3 * This file is part of NanoOcp <https://github.com/ChristianAhrens/NanoOcp>
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License version 3.0 as published
7 * by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#include <JuceHeader.h>
20
21#include "MainComponent.h"
22
23namespace NanoOcp1Demo
24{
25
26//==============================================================================
27class NanoOcp1DemoApplication : public JUCEApplication
28{
29public:
30 //==============================================================================
32
33 const String getApplicationName() override { return ProjectInfo::projectName; }
34 const String getApplicationVersion() override { return ProjectInfo::versionString; }
35 bool moreThanOneInstanceAllowed() override { return true; }
36
37 //==============================================================================
38 void initialise (const String& commandLine) override
39 {
40 ignoreUnused(commandLine);
41
42 mainWindow.reset (new MainWindow (getApplicationName()));
43 }
44
45 void shutdown() override
46 {
47 mainWindow = nullptr;
48 }
49
50 //==============================================================================
51 void systemRequestedQuit() override
52 {
53 // This is called when the app is being asked to quit: you can ignore this
54 // request and let the app carry on running, or call quit() to allow the app to close.
55 quit();
56 }
57
58 void anotherInstanceStarted (const String& commandLine) override
59 {
60 ignoreUnused(commandLine);
61 // When another instance of the app is launched while this one is running,
62 // this method is invoked, and the commandLine parameter tells you what
63 // the other instance's command-line arguments were.
64 }
65
66 //==============================================================================
67 /*
68 This class implements the desktop window that contains an instance of
69 our MainComponent class.
70 */
71 class MainWindow : public DocumentWindow
72 {
73 public:
74 MainWindow (String name) : DocumentWindow (name,
75 Desktop::getInstance().getDefaultLookAndFeel()
76 .findColour (ResizableWindow::backgroundColourId),
77 DocumentWindow::allButtons)
78 {
79
80 setUsingNativeTitleBar (true);
81 setContentOwned (new MainComponent(), true);
82
83 #if JUCE_IOS || JUCE_ANDROID
84 setFullScreen (true);
85 #else
86 setResizable (true, true);
87 centreWithSize (getWidth(), getHeight());
88 #endif
89
90 setVisible (true);
91 }
92
93 void closeButtonPressed() override
94 {
95 // This is called when the user tries to close this window. Here, we'll just
96 // ask the app to quit when this happens, but you can change this to do
97 // whatever you need.
98 JUCEApplication::getInstance()->systemRequestedQuit();
99 }
100
101 /* Note: Be careful if you override any DocumentWindow methods - the base
102 class uses a lot of them, so by overriding you might break its functionality.
103 It's best to do all your work in your content component instead, but if
104 you really have to override any DocumentWindow methods, make sure your
105 subclass also calls the superclass's method.
106 */
107
108 private:
109
110 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
111 };
112
113private:
114 std::unique_ptr<MainWindow> mainWindow;
115};
116
117}
118
119//==============================================================================
120// This macro generates the main() routine that launches the app.
121START_JUCE_APPLICATION (NanoOcp1Demo::NanoOcp1DemoApplication)
void initialise(const String &commandLine) override
Definition Main.cpp:38
bool moreThanOneInstanceAllowed() override
Definition Main.cpp:35
const String getApplicationVersion() override
Definition Main.cpp:34
const String getApplicationName() override
Definition Main.cpp:33
void systemRequestedQuit() override
Definition Main.cpp:51
void anotherInstanceStarted(const String &commandLine) override
Definition Main.cpp:58