The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
4.0KB

  1. /*
  2. ==============================================================================
  3. This file contains the basic startup code for a JUCE application.
  4. ==============================================================================
  5. */
  6. %%app_headers%%
  7. //==============================================================================
  8. class %%app_class_name%% : public juce::JUCEApplication
  9. {
  10. public:
  11. //==============================================================================
  12. %%app_class_name%%() {}
  13. const juce::String getApplicationName() override { return ProjectInfo::projectName; }
  14. const juce::String getApplicationVersion() override { return ProjectInfo::versionString; }
  15. bool moreThanOneInstanceAllowed() override { return true; }
  16. //==============================================================================
  17. void initialise (const juce::String& commandLine) override
  18. {
  19. // This method is where you should put your application's initialisation code..
  20. mainWindow.reset (new MainWindow (getApplicationName()));
  21. }
  22. void shutdown() override
  23. {
  24. // Add your application's shutdown code here..
  25. mainWindow = nullptr; // (deletes our window)
  26. }
  27. //==============================================================================
  28. void systemRequestedQuit() override
  29. {
  30. // This is called when the app is being asked to quit: you can ignore this
  31. // request and let the app carry on running, or call quit() to allow the app to close.
  32. quit();
  33. }
  34. void anotherInstanceStarted (const juce::String& commandLine) override
  35. {
  36. // When another instance of the app is launched while this one is running,
  37. // this method is invoked, and the commandLine parameter tells you what
  38. // the other instance's command-line arguments were.
  39. }
  40. //==============================================================================
  41. /*
  42. This class implements the desktop window that contains an instance of
  43. our %%content_component_class%% class.
  44. */
  45. class MainWindow : public juce::DocumentWindow
  46. {
  47. public:
  48. MainWindow (juce::String name)
  49. : DocumentWindow (name,
  50. juce::Desktop::getInstance().getDefaultLookAndFeel()
  51. .findColour (juce::ResizableWindow::backgroundColourId),
  52. DocumentWindow::allButtons)
  53. {
  54. setUsingNativeTitleBar (true);
  55. setContentOwned (new %%content_component_class%%(), true);
  56. #if JUCE_IOS || JUCE_ANDROID
  57. setFullScreen (true);
  58. #else
  59. setResizable (true, true);
  60. centreWithSize (getWidth(), getHeight());
  61. #endif
  62. setVisible (true);
  63. }
  64. void closeButtonPressed() override
  65. {
  66. // This is called when the user tries to close this window. Here, we'll just
  67. // ask the app to quit when this happens, but you can change this to do
  68. // whatever you need.
  69. JUCEApplication::getInstance()->systemRequestedQuit();
  70. }
  71. /* Note: Be careful if you override any DocumentWindow methods - the base
  72. class uses a lot of them, so by overriding you might break its functionality.
  73. It's best to do all your work in your content component instead, but if
  74. you really have to override any DocumentWindow methods, make sure your
  75. subclass also calls the superclass's method.
  76. */
  77. private:
  78. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
  79. };
  80. private:
  81. std::unique_ptr<MainWindow> mainWindow;
  82. };
  83. //==============================================================================
  84. // This macro generates the main() routine that launches the app.
  85. START_JUCE_APPLICATION (%%app_class_name%%)