Audio plugin host https://kx.studio/carla
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.

193 lines
7.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. An instance of this class is used to specify initialisation and shutdown
  24. code for the application.
  25. Any application that wants to run an event loop must declare a subclass of
  26. JUCEApplicationBase or JUCEApplication, and implement its various pure virtual
  27. methods.
  28. It then needs to use the START_JUCE_APPLICATION macro somewhere in a CPP file
  29. to declare an instance of this class and generate suitable platform-specific
  30. boilerplate code to launch the app.
  31. Note that this class is derived from JUCEApplicationBase, which contains most
  32. of the useful methods and functionality. This derived class is here simply as
  33. a convenient way to also inherit from an ApplicationCommandTarget, and to implement
  34. default versions of some of the pure virtual base class methods. But you can derive
  35. your app object directly from JUCEApplicationBase if you want to, and by doing so
  36. can avoid having a dependency on the juce_gui_basics module.
  37. e.g. @code
  38. class MyJUCEApp : public JUCEApplication
  39. {
  40. public:
  41. MyJUCEApp() {}
  42. ~MyJUCEApp() {}
  43. void initialise (const String& commandLine) override
  44. {
  45. myMainWindow = new MyApplicationWindow();
  46. myMainWindow->setBounds (100, 100, 400, 500);
  47. myMainWindow->setVisible (true);
  48. }
  49. void shutdown() override
  50. {
  51. myMainWindow = nullptr;
  52. }
  53. const String getApplicationName() override
  54. {
  55. return "Super JUCE-o-matic";
  56. }
  57. const String getApplicationVersion() override
  58. {
  59. return "1.0";
  60. }
  61. private:
  62. ScopedPointer<MyApplicationWindow> myMainWindow;
  63. };
  64. // this generates boilerplate code to launch our app class:
  65. START_JUCE_APPLICATION (MyJUCEApp)
  66. @endcode
  67. @see JUCEApplicationBase, START_JUCE_APPLICATION
  68. */
  69. class JUCE_API JUCEApplication : public JUCEApplicationBase,
  70. public ApplicationCommandTarget
  71. {
  72. public:
  73. //==============================================================================
  74. /** Constructs a JUCE app object.
  75. If subclasses implement a constructor or destructor, they shouldn't call any
  76. JUCE code in there - put your startup/shutdown code in initialise() and
  77. shutdown() instead.
  78. */
  79. JUCEApplication();
  80. /** Destructor.
  81. If subclasses implement a constructor or destructor, they shouldn't call any
  82. JUCE code in there - put your startup/shutdown code in initialise() and
  83. shutdown() instead.
  84. */
  85. ~JUCEApplication();
  86. //==============================================================================
  87. /** Returns the global instance of the application object being run. */
  88. static JUCEApplication* JUCE_CALLTYPE getInstance() noexcept;
  89. //==============================================================================
  90. #if DOXYGEN
  91. /** Returns the application's name. */
  92. virtual const String getApplicationName() = 0;
  93. /** Returns the application's version number. */
  94. virtual const String getApplicationVersion() = 0;
  95. #endif
  96. /** Checks whether multiple instances of the app are allowed.
  97. If you application class returns true for this, more than one instance is
  98. permitted to run (except on OSX where the OS automatically stops you launching
  99. a second instance of an app without explicitly starting it from the command-line).
  100. If it's false, the second instance won't start, but it you will still get a
  101. callback to anotherInstanceStarted() to tell you about this - which
  102. gives you a chance to react to what the user was trying to do.
  103. */
  104. bool moreThanOneInstanceAllowed() override;
  105. /** Indicates that the user has tried to start up another instance of the app.
  106. This will get called even if moreThanOneInstanceAllowed() is false.
  107. */
  108. void anotherInstanceStarted (const String& commandLine) override;
  109. /** Called when the operating system is trying to close the application.
  110. The default implementation of this method is to call quit(), but it may
  111. be overloaded to ignore the request or do some other special behaviour
  112. instead. For example, you might want to offer the user the chance to save
  113. their changes before quitting, and give them the chance to cancel.
  114. If you want to send a quit signal to your app, this is the correct method
  115. to call, because it means that requests that come from the system get handled
  116. in the same way as those from your own application code. So e.g. you'd
  117. call this method from a "quit" item on a menu bar.
  118. */
  119. void systemRequestedQuit() override;
  120. /** This method is called when the application is being put into background mode
  121. by the operating system.
  122. */
  123. void suspended() override;
  124. /** This method is called when the application is being woken from background mode
  125. by the operating system.
  126. */
  127. void resumed() override;
  128. /** If any unhandled exceptions make it through to the message dispatch loop, this
  129. callback will be triggered, in case you want to log them or do some other
  130. type of error-handling.
  131. If the type of exception is derived from the std::exception class, the pointer
  132. passed-in will be valid. If the exception is of unknown type, this pointer
  133. will be null.
  134. */
  135. void unhandledException (const std::exception* e,
  136. const String& sourceFilename,
  137. int lineNumber) override;
  138. //==============================================================================
  139. /** @internal */
  140. ApplicationCommandTarget* getNextCommandTarget() override;
  141. /** @internal */
  142. void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
  143. /** @internal */
  144. void getAllCommands (Array<CommandID>&) override;
  145. /** @internal */
  146. bool perform (const InvocationInfo&) override;
  147. private:
  148. bool initialiseApp() override;
  149. JUCE_DECLARE_NON_COPYABLE (JUCEApplication)
  150. };
  151. } // namespace juce