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.

99 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. //==============================================================================
  24. class PluginHostApp : public JUCEApplication
  25. {
  26. public:
  27. PluginHostApp() {}
  28. void initialise (const String& commandLine)
  29. {
  30. // initialise our settings file..
  31. PropertiesFile::Options options;
  32. options.applicationName = "Juce Audio Plugin Host";
  33. options.filenameSuffix = "settings";
  34. options.osxLibrarySubFolder = "Preferences";
  35. appProperties = new ApplicationProperties();
  36. appProperties->setStorageParameters (options);
  37. mainWindow = new MainHostWindow();
  38. mainWindow->setUsingNativeTitleBar (true);
  39. commandManager.registerAllCommandsForTarget (this);
  40. commandManager.registerAllCommandsForTarget (mainWindow);
  41. mainWindow->menuItemsChanged();
  42. if (commandLine.isNotEmpty()
  43. && ! commandLine.trimStart().startsWith ("-")
  44. && mainWindow->getGraphEditor() != nullptr)
  45. mainWindow->getGraphEditor()->graph.loadFrom (File::getCurrentWorkingDirectory()
  46. .getChildFile (commandLine), true);
  47. }
  48. void shutdown()
  49. {
  50. mainWindow = nullptr;
  51. appProperties = nullptr;
  52. }
  53. void systemRequestedQuit()
  54. {
  55. if (mainWindow != nullptr)
  56. mainWindow->tryToQuitApplication();
  57. else
  58. JUCEApplication::quit();
  59. }
  60. const String getApplicationName() { return "Juce Plug-In Host"; }
  61. const String getApplicationVersion() { return ProjectInfo::versionString; }
  62. bool moreThanOneInstanceAllowed() { return true; }
  63. ApplicationCommandManager commandManager;
  64. ScopedPointer<ApplicationProperties> appProperties;
  65. private:
  66. ScopedPointer<MainHostWindow> mainWindow;
  67. };
  68. static PluginHostApp& getApp() { return *dynamic_cast<PluginHostApp*>(JUCEApplication::getInstance()); }
  69. ApplicationCommandManager& getCommandManager() { return getApp().commandManager; }
  70. ApplicationProperties& getAppProperties() { return *getApp().appProperties; }
  71. // This kicks the whole thing off..
  72. START_JUCE_APPLICATION (PluginHostApp)