-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
63 lines (48 loc) · 2.24 KB
/
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <memory>
#include "MainComponent.hpp"
struct GuiAppApplication final : public juce::JUCEApplication
{
GuiAppApplication() = default;
auto getApplicationName() -> juce::String const override { return JUCE_APPLICATION_NAME_STRING; }
auto getApplicationVersion() -> juce::String const override { return JUCE_APPLICATION_VERSION_STRING; }
auto moreThanOneInstanceAllowed() -> bool override { return true; }
void initialise(juce::String const& /*commandLine*/) override
{
_mainWindow = std::make_unique<MainWindow>(getApplicationName());
}
void shutdown() override { _mainWindow = nullptr; }
void systemRequestedQuit() override { quit(); }
void anotherInstanceStarted(juce::String const& commandLine) override { juce::ignoreUnused(commandLine); }
struct MainWindow final : juce::DocumentWindow
{
explicit MainWindow(juce::String const& name)
: DocumentWindow(
name,
juce::Desktop::getInstance().getDefaultLookAndFeel().findColour(ResizableWindow::backgroundColourId),
DocumentWindow::allButtons)
{
setUsingNativeTitleBar(true);
setContentOwned(new MainComponent(), true);
#if JUCE_IOS || JUCE_ANDROID
setFullScreen(true);
#else
setResizable(true, true);
centreWithSize(getWidth(), getHeight());
#endif
setVisible(true);
}
void closeButtonPressed() override { JUCEApplication::getInstance()->systemRequestedQuit(); }
/* Note: Be careful if you override any DocumentWindow methods - the base
class uses a lot of them, so by overriding you might break its
functionality. It's best to do all your work in your content component
instead, but if you really have to override any DocumentWindow methods,
make sure your subclass also calls the superclass's method.
*/
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainWindow) // NOLINT
};
private:
std::unique_ptr<MainWindow> _mainWindow;
};
// This macro generates the main() routine that launches the app.
START_JUCE_APPLICATION(GuiAppApplication) // NOLINT