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.

174 lines
6.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. class MainHostWindow;
  21. //==============================================================================
  22. /**
  23. A panel that displays and edits a PluginGraph.
  24. */
  25. class GraphEditorPanel : public Component,
  26. public ChangeListener,
  27. private Timer
  28. {
  29. public:
  30. //==============================================================================
  31. GraphEditorPanel (PluginGraph& graph);
  32. ~GraphEditorPanel() override;
  33. void createNewPlugin (const PluginDescriptionAndPreference&, Point<int> position);
  34. void paint (Graphics&) override;
  35. void resized() override;
  36. void mouseDown (const MouseEvent&) override;
  37. void mouseUp (const MouseEvent&) override;
  38. void mouseDrag (const MouseEvent&) override;
  39. void changeListenerCallback (ChangeBroadcaster*) override;
  40. //==============================================================================
  41. void updateComponents();
  42. //==============================================================================
  43. void showPopupMenu (Point<int> position);
  44. //==============================================================================
  45. void beginConnectorDrag (AudioProcessorGraph::NodeAndChannel source,
  46. AudioProcessorGraph::NodeAndChannel dest,
  47. const MouseEvent&);
  48. void dragConnector (const MouseEvent&);
  49. void endDraggingConnector (const MouseEvent&);
  50. //==============================================================================
  51. PluginGraph& graph;
  52. private:
  53. struct PluginComponent;
  54. struct ConnectorComponent;
  55. struct PinComponent;
  56. OwnedArray<PluginComponent> nodes;
  57. OwnedArray<ConnectorComponent> connectors;
  58. std::unique_ptr<ConnectorComponent> draggingConnector;
  59. std::unique_ptr<PopupMenu> menu;
  60. PluginComponent* getComponentForPlugin (AudioProcessorGraph::NodeID) const;
  61. ConnectorComponent* getComponentForConnection (const AudioProcessorGraph::Connection&) const;
  62. PinComponent* findPinAt (Point<float>) const;
  63. //==============================================================================
  64. Point<int> originalTouchPos;
  65. void timerCallback() override;
  66. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphEditorPanel)
  67. };
  68. //==============================================================================
  69. /**
  70. A panel that embeds a GraphEditorPanel with a midi keyboard at the bottom.
  71. It also manages the graph itself, and plays it.
  72. */
  73. class GraphDocumentComponent : public Component,
  74. public DragAndDropTarget,
  75. public DragAndDropContainer,
  76. private ChangeListener
  77. {
  78. public:
  79. GraphDocumentComponent (AudioPluginFormatManager& formatManager,
  80. AudioDeviceManager& deviceManager,
  81. KnownPluginList& pluginList);
  82. ~GraphDocumentComponent() override;
  83. //==============================================================================
  84. void createNewPlugin (const PluginDescriptionAndPreference&, Point<int> position);
  85. void setDoublePrecision (bool doublePrecision);
  86. bool closeAnyOpenPluginWindows();
  87. //==============================================================================
  88. std::unique_ptr<PluginGraph> graph;
  89. void resized() override;
  90. void unfocusKeyboardComponent();
  91. void releaseGraph();
  92. //==============================================================================
  93. bool isInterestedInDragSource (const SourceDetails&) override;
  94. void itemDropped (const SourceDetails&) override;
  95. //==============================================================================
  96. std::unique_ptr<GraphEditorPanel> graphPanel;
  97. std::unique_ptr<MidiKeyboardComponent> keyboardComp;
  98. //==============================================================================
  99. void showSidePanel (bool isSettingsPanel);
  100. void hideLastSidePanel();
  101. BurgerMenuComponent burgerMenu;
  102. private:
  103. //==============================================================================
  104. AudioDeviceManager& deviceManager;
  105. KnownPluginList& pluginList;
  106. AudioProcessorPlayer graphPlayer;
  107. MidiKeyboardState keyState;
  108. MidiOutput* midiOutput = nullptr;
  109. struct TooltipBar;
  110. std::unique_ptr<TooltipBar> statusBar;
  111. class TitleBarComponent;
  112. std::unique_ptr<TitleBarComponent> titleBarComponent;
  113. //==============================================================================
  114. struct PluginListBoxModel;
  115. std::unique_ptr<PluginListBoxModel> pluginListBoxModel;
  116. ListBox pluginListBox;
  117. SidePanel mobileSettingsSidePanel { "Settings", 300, true };
  118. SidePanel pluginListSidePanel { "Plugins", 250, false };
  119. SidePanel* lastOpenedSidePanel = nullptr;
  120. //==============================================================================
  121. void changeListenerCallback (ChangeBroadcaster*) override;
  122. void init();
  123. void checkAvailableWidth();
  124. void updateMidiOutput();
  125. //==============================================================================
  126. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphDocumentComponent)
  127. };