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.

103 lines
3.7KB

  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_VST3 || 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) override
  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. LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
  38. mainWindow = new MainHostWindow();
  39. mainWindow->setUsingNativeTitleBar (true);
  40. commandManager.registerAllCommandsForTarget (this);
  41. commandManager.registerAllCommandsForTarget (mainWindow);
  42. mainWindow->menuItemsChanged();
  43. if (commandLine.isNotEmpty()
  44. && ! commandLine.trimStart().startsWith ("-")
  45. && mainWindow->getGraphEditor() != nullptr)
  46. mainWindow->getGraphEditor()->graph.loadFrom (File::getCurrentWorkingDirectory()
  47. .getChildFile (commandLine), true);
  48. }
  49. void shutdown() override
  50. {
  51. mainWindow = nullptr;
  52. appProperties = nullptr;
  53. LookAndFeel::setDefaultLookAndFeel (nullptr);
  54. }
  55. void systemRequestedQuit() override
  56. {
  57. if (mainWindow != nullptr)
  58. mainWindow->tryToQuitApplication();
  59. else
  60. JUCEApplicationBase::quit();
  61. }
  62. const String getApplicationName() override { return "Juce Plug-In Host"; }
  63. const String getApplicationVersion() override { return ProjectInfo::versionString; }
  64. bool moreThanOneInstanceAllowed() override { return true; }
  65. ApplicationCommandManager commandManager;
  66. ScopedPointer<ApplicationProperties> appProperties;
  67. LookAndFeel_V3 lookAndFeel;
  68. private:
  69. ScopedPointer<MainHostWindow> mainWindow;
  70. };
  71. static PluginHostApp& getApp() { return *dynamic_cast<PluginHostApp*>(JUCEApplication::getInstance()); }
  72. ApplicationCommandManager& getCommandManager() { return getApp().commandManager; }
  73. ApplicationProperties& getAppProperties() { return *getApp().appProperties; }
  74. // This kicks the whole thing off..
  75. START_JUCE_APPLICATION (PluginHostApp)