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.

108 lines
3.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-9 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #include "../JuceLibraryCode/JuceHeader.h"
  19. #include "MainHostWindow.h"
  20. #include "InternalFilters.h"
  21. #if ! (JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_AU)
  22. #error "If you're building the audio plugin host, you probably want to enable VST and/or AU support"
  23. #endif
  24. ApplicationCommandManager* commandManager = nullptr;
  25. ApplicationProperties* appProperties = nullptr;
  26. //==============================================================================
  27. class PluginHostApp : public JUCEApplication
  28. {
  29. public:
  30. //==============================================================================
  31. PluginHostApp()
  32. {
  33. }
  34. void initialise (const String& commandLine)
  35. {
  36. // initialise our settings file..
  37. PropertiesFile::Options options;
  38. options.applicationName = "Juce Audio Plugin Host";
  39. options.filenameSuffix = "settings";
  40. options.osxLibrarySubFolder = "Preferences";
  41. appProperties = new ApplicationProperties();
  42. appProperties->setStorageParameters (options);
  43. commandManager = new ApplicationCommandManager();
  44. mainWindow = new MainHostWindow();
  45. //mainWindow->setUsingNativeTitleBar (true);
  46. commandManager->registerAllCommandsForTarget (this);
  47. commandManager->registerAllCommandsForTarget (mainWindow);
  48. mainWindow->menuItemsChanged();
  49. if (commandLine.isNotEmpty() && mainWindow->getGraphEditor() != 0)
  50. {
  51. #if JUCE_MAC
  52. if (! commandLine.trimStart().startsWith ("-"))
  53. #endif
  54. mainWindow->getGraphEditor()->graph.loadFrom (File::getCurrentWorkingDirectory()
  55. .getChildFile (commandLine), true);
  56. }
  57. }
  58. void shutdown()
  59. {
  60. mainWindow = 0;
  61. appProperties->closeFiles();
  62. deleteAndZero (commandManager);
  63. deleteAndZero (appProperties);
  64. }
  65. void systemRequestedQuit()
  66. {
  67. if (mainWindow != 0)
  68. mainWindow->tryToQuitApplication();
  69. else
  70. JUCEApplication::quit();
  71. }
  72. const String getApplicationName() { return "Juce Plug-In Host"; }
  73. const String getApplicationVersion() { return ProjectInfo::versionString; }
  74. bool moreThanOneInstanceAllowed() { return true; }
  75. private:
  76. ScopedPointer <MainHostWindow> mainWindow;
  77. };
  78. // This kicks the whole thing off..
  79. START_JUCE_APPLICATION (PluginHostApp)