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.

121 lines
4.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #include "../JuceLibraryCode/JuceHeader.h"
  18. #include "MainComponent.h"
  19. //==============================================================================
  20. class MidiTestApplication : public JUCEApplication
  21. {
  22. public:
  23. //==============================================================================
  24. MidiTestApplication() {}
  25. const String getApplicationName() override { return ProjectInfo::projectName; }
  26. const String getApplicationVersion() override { return ProjectInfo::versionString; }
  27. bool moreThanOneInstanceAllowed() override { return true; }
  28. //==============================================================================
  29. void initialise (const String& commandLine) override
  30. {
  31. // This method is where you should put your application's initialisation code..
  32. ignoreUnused (commandLine);
  33. mainWindow = new MainWindow (getApplicationName());
  34. }
  35. void shutdown() override
  36. {
  37. // Add your application's shutdown code here..
  38. mainWindow = nullptr; // (deletes our window)
  39. }
  40. //==============================================================================
  41. void systemRequestedQuit() override
  42. {
  43. // This is called when the app is being asked to quit: you can ignore this
  44. // request and let the app carry on running, or call quit() to allow the app to close.
  45. quit();
  46. }
  47. void anotherInstanceStarted (const String& commandLine) override
  48. {
  49. // When another instance of the app is launched while this one is running,
  50. // this method is invoked, and the commandLine parameter tells you what
  51. // the other instance's command-line arguments were.
  52. ignoreUnused (commandLine);
  53. }
  54. //==============================================================================
  55. /*
  56. This class implements the desktop window that contains an instance of
  57. our MainContentComponent class.
  58. */
  59. class MainWindow : public DocumentWindow
  60. {
  61. public:
  62. MainWindow (String name) : DocumentWindow (name,
  63. Colours::lightgrey,
  64. DocumentWindow::allButtons)
  65. {
  66. setUsingNativeTitleBar (true);
  67. setContentOwned (new MainContentComponent(), true);
  68. setResizable (true, false);
  69. #if JUCE_IOS || JUCE_ANDROID
  70. setFullScreen (true);
  71. #endif
  72. centreWithSize (getWidth(), getHeight());
  73. setVisible (true);
  74. }
  75. void closeButtonPressed() override
  76. {
  77. // This is called when the user tries to close this window. Here, we'll just
  78. // ask the app to quit when this happens, but you can change this to do
  79. // whatever you need.
  80. JUCEApplication::getInstance()->systemRequestedQuit();
  81. }
  82. /* Note: Be careful if you override any DocumentWindow methods - the base
  83. class uses a lot of them, so by overriding you might break its functionality.
  84. It's best to do all your work in your content component instead, but if
  85. you really have to override any DocumentWindow methods, make sure your
  86. subclass also calls the superclass's method.
  87. */
  88. private:
  89. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
  90. };
  91. private:
  92. ScopedPointer<MainWindow> mainWindow;
  93. };
  94. //==============================================================================
  95. // This macro generates the main() routine that launches the app.
  96. START_JUCE_APPLICATION (MidiTestApplication)