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.

136 lines
5.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 7 technical preview.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For the technical preview this file cannot be licensed commercially.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. #pragma once
  14. #include "../Plugins/PluginGraph.h"
  15. #include "GraphEditorPanel.h"
  16. //==============================================================================
  17. namespace CommandIDs
  18. {
  19. #if ! (JUCE_IOS || JUCE_ANDROID)
  20. static const int open = 0x30000;
  21. static const int save = 0x30001;
  22. static const int saveAs = 0x30002;
  23. static const int newFile = 0x30003;
  24. #endif
  25. static const int showPluginListEditor = 0x30100;
  26. static const int showAudioSettings = 0x30200;
  27. static const int aboutBox = 0x30300;
  28. static const int allWindowsForward = 0x30400;
  29. static const int toggleDoublePrecision = 0x30500;
  30. static const int autoScalePluginWindows = 0x30600;
  31. }
  32. //==============================================================================
  33. ApplicationCommandManager& getCommandManager();
  34. ApplicationProperties& getAppProperties();
  35. bool isOnTouchDevice();
  36. //==============================================================================
  37. enum class AutoScale
  38. {
  39. scaled,
  40. unscaled,
  41. useDefault
  42. };
  43. constexpr bool autoScaleOptionAvailable =
  44. #if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE
  45. true;
  46. #else
  47. false;
  48. #endif
  49. AutoScale getAutoScaleValueForPlugin (const String&);
  50. void setAutoScaleValueForPlugin (const String&, AutoScale);
  51. bool shouldAutoScalePlugin (const PluginDescription&);
  52. void addPluginAutoScaleOptionsSubMenu (AudioPluginInstance*, PopupMenu&);
  53. constexpr const char* processUID = "juceaudiopluginhost";
  54. //==============================================================================
  55. class MainHostWindow : public DocumentWindow,
  56. public MenuBarModel,
  57. public ApplicationCommandTarget,
  58. public ChangeListener,
  59. public FileDragAndDropTarget
  60. {
  61. public:
  62. //==============================================================================
  63. MainHostWindow();
  64. ~MainHostWindow() override;
  65. //==============================================================================
  66. void closeButtonPressed() override;
  67. void changeListenerCallback (ChangeBroadcaster*) override;
  68. bool isInterestedInFileDrag (const StringArray& files) override;
  69. void fileDragEnter (const StringArray& files, int, int) override;
  70. void fileDragMove (const StringArray& files, int, int) override;
  71. void fileDragExit (const StringArray& files) override;
  72. void filesDropped (const StringArray& files, int, int) override;
  73. void menuBarActivated (bool isActive) override;
  74. StringArray getMenuBarNames() override;
  75. PopupMenu getMenuForIndex (int topLevelMenuIndex, const String& menuName) override;
  76. void menuItemSelected (int menuItemID, int topLevelMenuIndex) override;
  77. ApplicationCommandTarget* getNextCommandTarget() override;
  78. void getAllCommands (Array<CommandID>&) override;
  79. void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
  80. bool perform (const InvocationInfo&) override;
  81. void tryToQuitApplication();
  82. void createPlugin (const PluginDescriptionAndPreference&, Point<int> pos);
  83. void addPluginsToMenu (PopupMenu&);
  84. PluginDescriptionAndPreference getChosenType (int menuID) const;
  85. std::unique_ptr<GraphDocumentComponent> graphHolder;
  86. private:
  87. //==============================================================================
  88. static bool isDoublePrecisionProcessingEnabled();
  89. static bool isAutoScalePluginWindowsEnabled();
  90. static void updatePrecisionMenuItem (ApplicationCommandInfo& info);
  91. static void updateAutoScaleMenuItem (ApplicationCommandInfo& info);
  92. void showAudioSettings();
  93. int getIndexChosenByMenu (int menuID) const;
  94. //==============================================================================
  95. AudioDeviceManager deviceManager;
  96. AudioPluginFormatManager formatManager;
  97. std::vector<PluginDescription> internalTypes;
  98. KnownPluginList knownPluginList;
  99. KnownPluginList::SortMethod pluginSortMethod;
  100. Array<PluginDescriptionAndPreference> pluginDescriptionsAndPreference;
  101. class PluginListWindow;
  102. std::unique_ptr<PluginListWindow> pluginListWindow;
  103. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainHostWindow)
  104. };