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.

143 lines
5.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - 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 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-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. #pragma once
  19. #include "../Plugins/PluginGraph.h"
  20. #include "GraphEditorPanel.h"
  21. //==============================================================================
  22. namespace CommandIDs
  23. {
  24. #if ! (JUCE_IOS || JUCE_ANDROID)
  25. static const int open = 0x30000;
  26. static const int save = 0x30001;
  27. static const int saveAs = 0x30002;
  28. static const int newFile = 0x30003;
  29. #endif
  30. static const int showPluginListEditor = 0x30100;
  31. static const int showAudioSettings = 0x30200;
  32. static const int aboutBox = 0x30300;
  33. static const int allWindowsForward = 0x30400;
  34. static const int toggleDoublePrecision = 0x30500;
  35. static const int autoScalePluginWindows = 0x30600;
  36. }
  37. //==============================================================================
  38. ApplicationCommandManager& getCommandManager();
  39. ApplicationProperties& getAppProperties();
  40. bool isOnTouchDevice();
  41. //==============================================================================
  42. enum class AutoScale
  43. {
  44. scaled,
  45. unscaled,
  46. useDefault
  47. };
  48. constexpr bool autoScaleOptionAvailable =
  49. #if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE
  50. true;
  51. #else
  52. false;
  53. #endif
  54. AutoScale getAutoScaleValueForPlugin (const String&);
  55. void setAutoScaleValueForPlugin (const String&, AutoScale);
  56. bool shouldAutoScalePlugin (const PluginDescription&);
  57. void addPluginAutoScaleOptionsSubMenu (AudioPluginInstance*, PopupMenu&);
  58. constexpr const char* processUID = "juceaudiopluginhost";
  59. //==============================================================================
  60. class MainHostWindow : public DocumentWindow,
  61. public MenuBarModel,
  62. public ApplicationCommandTarget,
  63. public ChangeListener,
  64. public FileDragAndDropTarget
  65. {
  66. public:
  67. //==============================================================================
  68. MainHostWindow();
  69. ~MainHostWindow() override;
  70. //==============================================================================
  71. void closeButtonPressed() override;
  72. void changeListenerCallback (ChangeBroadcaster*) override;
  73. bool isInterestedInFileDrag (const StringArray& files) override;
  74. void fileDragEnter (const StringArray& files, int, int) override;
  75. void fileDragMove (const StringArray& files, int, int) override;
  76. void fileDragExit (const StringArray& files) override;
  77. void filesDropped (const StringArray& files, int, int) override;
  78. void menuBarActivated (bool isActive) override;
  79. StringArray getMenuBarNames() override;
  80. PopupMenu getMenuForIndex (int topLevelMenuIndex, const String& menuName) override;
  81. void menuItemSelected (int menuItemID, int topLevelMenuIndex) override;
  82. ApplicationCommandTarget* getNextCommandTarget() override;
  83. void getAllCommands (Array<CommandID>&) override;
  84. void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
  85. bool perform (const InvocationInfo&) override;
  86. void tryToQuitApplication();
  87. void createPlugin (const PluginDescriptionAndPreference&, Point<int> pos);
  88. void addPluginsToMenu (PopupMenu&);
  89. PluginDescriptionAndPreference getChosenType (int menuID) const;
  90. std::unique_ptr<GraphDocumentComponent> graphHolder;
  91. private:
  92. //==============================================================================
  93. static bool isDoublePrecisionProcessingEnabled();
  94. static bool isAutoScalePluginWindowsEnabled();
  95. static void updatePrecisionMenuItem (ApplicationCommandInfo& info);
  96. static void updateAutoScaleMenuItem (ApplicationCommandInfo& info);
  97. void showAudioSettings();
  98. int getIndexChosenByMenu (int menuID) const;
  99. //==============================================================================
  100. AudioDeviceManager deviceManager;
  101. AudioPluginFormatManager formatManager;
  102. std::vector<PluginDescription> internalTypes;
  103. KnownPluginList knownPluginList;
  104. KnownPluginList::SortMethod pluginSortMethod;
  105. Array<PluginDescriptionAndPreference> pluginDescriptionsAndPreference;
  106. class PluginListWindow;
  107. std::unique_ptr<PluginListWindow> pluginListWindow;
  108. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainHostWindow)
  109. };