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.

194 lines
7.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. An instance of this class is used to specify initialisation and shutdown
  23. code for the application.
  24. Any application that wants to run an event loop must declare a subclass of
  25. JUCEApplicationBase or JUCEApplication, and implement its various pure virtual
  26. methods.
  27. It then needs to use the START_JUCE_APPLICATION macro somewhere in a CPP file
  28. to declare an instance of this class and generate suitable platform-specific
  29. boilerplate code to launch the app.
  30. Note that this class is derived from JUCEApplicationBase, which contains most
  31. of the useful methods and functionality. This derived class is here simply as
  32. a convenient way to also inherit from an ApplicationCommandTarget, and to implement
  33. default versions of some of the pure virtual base class methods. But you can derive
  34. your app object directly from JUCEApplicationBase if you want to, and by doing so
  35. can avoid having a dependency on the juce_gui_basics module.
  36. e.g. @code
  37. class MyJUCEApp : public JUCEApplication
  38. {
  39. public:
  40. MyJUCEApp() {}
  41. ~MyJUCEApp() {}
  42. void initialise (const String& commandLine) override
  43. {
  44. myMainWindow.reset (new MyApplicationWindow());
  45. myMainWindow->setBounds (100, 100, 400, 500);
  46. myMainWindow->setVisible (true);
  47. }
  48. void shutdown() override
  49. {
  50. myMainWindow = nullptr;
  51. }
  52. const String getApplicationName() override
  53. {
  54. return "Super JUCE-o-matic";
  55. }
  56. const String getApplicationVersion() override
  57. {
  58. return "1.0";
  59. }
  60. private:
  61. std::unique_ptr<MyApplicationWindow> myMainWindow;
  62. };
  63. // this generates boilerplate code to launch our app class:
  64. START_JUCE_APPLICATION (MyJUCEApp)
  65. @endcode
  66. @see JUCEApplicationBase, START_JUCE_APPLICATION
  67. @tags{GUI}
  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() override;
  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 your 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 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