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.

107 lines
3.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software 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 "MainHostWindow.h"
  19. #include "InternalFilters.h"
  20. #if ! (JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_AU)
  21. #error "If you're building the audio plugin host, you probably want to enable VST and/or AU support"
  22. #endif
  23. ApplicationCommandManager* commandManager = nullptr;
  24. ApplicationProperties* appProperties = nullptr;
  25. //==============================================================================
  26. class PluginHostApp : public JUCEApplication
  27. {
  28. public:
  29. //==============================================================================
  30. PluginHostApp()
  31. {
  32. }
  33. void initialise (const String& commandLine)
  34. {
  35. // initialise our settings file..
  36. PropertiesFile::Options options;
  37. options.applicationName = "Juce Audio Plugin Host";
  38. options.filenameSuffix = "settings";
  39. options.osxLibrarySubFolder = "Preferences";
  40. appProperties = new ApplicationProperties();
  41. appProperties->setStorageParameters (options);
  42. commandManager = new ApplicationCommandManager();
  43. mainWindow = new MainHostWindow();
  44. //mainWindow->setUsingNativeTitleBar (true);
  45. commandManager->registerAllCommandsForTarget (this);
  46. commandManager->registerAllCommandsForTarget (mainWindow);
  47. mainWindow->menuItemsChanged();
  48. if (commandLine.isNotEmpty() && mainWindow->getGraphEditor() != 0)
  49. {
  50. #if JUCE_MAC
  51. if (! commandLine.trimStart().startsWith ("-"))
  52. #endif
  53. mainWindow->getGraphEditor()->graph.loadFrom (File::getCurrentWorkingDirectory()
  54. .getChildFile (commandLine), true);
  55. }
  56. }
  57. void shutdown()
  58. {
  59. mainWindow = 0;
  60. appProperties->closeFiles();
  61. deleteAndZero (commandManager);
  62. deleteAndZero (appProperties);
  63. }
  64. void systemRequestedQuit()
  65. {
  66. if (mainWindow != 0)
  67. mainWindow->tryToQuitApplication();
  68. else
  69. JUCEApplication::quit();
  70. }
  71. const String getApplicationName() { return "Juce Plug-In Host"; }
  72. const String getApplicationVersion() { return ProjectInfo::versionString; }
  73. bool moreThanOneInstanceAllowed() { return true; }
  74. private:
  75. ScopedPointer <MainHostWindow> mainWindow;
  76. };
  77. // This kicks the whole thing off..
  78. START_JUCE_APPLICATION (PluginHostApp)