Audio plugin host https://kx.studio/carla
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.

155 lines
5.0KB

  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. #ifndef __GRAPHEDITORPANEL_JUCEHEADER__
  18. #define __GRAPHEDITORPANEL_JUCEHEADER__
  19. #include "FilterGraph.h"
  20. class FilterComponent;
  21. class ConnectorComponent;
  22. class PinComponent;
  23. class GraphEditorPanel;
  24. //==============================================================================
  25. /** A desktop window containing a plugin's UI. */
  26. class PluginWindow : public DocumentWindow
  27. {
  28. public:
  29. enum WindowFormatType
  30. {
  31. Normal = 0,
  32. Generic,
  33. Programs,
  34. Parameters
  35. };
  36. PluginWindow (GraphEditorPanel* const panel, Component* pluginEditor, AudioProcessorGraph::Node*, WindowFormatType);
  37. ~PluginWindow();
  38. void moved() override;
  39. void closeButtonPressed() override;
  40. private:
  41. AudioProcessorGraph::Node* owner;
  42. WindowFormatType type;
  43. float getDesktopScaleFactor() const override { return 1.0f; }
  44. GraphEditorPanel* const panel;
  45. friend class GraphEditorPanel;
  46. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginWindow)
  47. };
  48. //==============================================================================
  49. /**
  50. A panel that displays and edits a FilterGraph.
  51. */
  52. class GraphEditorPanel : public Component,
  53. public ChangeListener
  54. {
  55. public:
  56. GraphEditorPanel (FilterGraph& graph);
  57. ~GraphEditorPanel();
  58. void paint (Graphics& g);
  59. void mouseDown (const MouseEvent& e);
  60. void createNewPlugin (const PluginDescription* desc, int x, int y);
  61. FilterComponent* getComponentForFilter (uint32 filterID) const;
  62. ConnectorComponent* getComponentForConnection (const AudioProcessorGraph::Connection& conn) const;
  63. PinComponent* findPinAt (int x, int y) const;
  64. void resized();
  65. void changeListenerCallback (ChangeBroadcaster*);
  66. void updateComponents();
  67. //==============================================================================
  68. void beginConnectorDrag (uint32 sourceFilterID, int sourceFilterChannel,
  69. uint32 destFilterID, int destFilterChannel,
  70. const MouseEvent& e);
  71. void dragConnector (const MouseEvent& e);
  72. void endDraggingConnector (const MouseEvent& e);
  73. //==============================================================================
  74. Array <PluginWindow*> activePluginWindows;
  75. PluginWindow* getWindowFor (AudioProcessorGraph::Node*, PluginWindow::WindowFormatType);
  76. void closeCurrentlyOpenWindowsFor (const uint32 nodeId);
  77. void closeAllCurrentlyOpenWindows();
  78. //==============================================================================
  79. private:
  80. FilterGraph& graph;
  81. ScopedPointer<ConnectorComponent> draggingConnector;
  82. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphEditorPanel)
  83. };
  84. //==============================================================================
  85. /**
  86. A panel that embeds a GraphEditorPanel with a midi keyboard at the bottom.
  87. It also manages the graph itself, and plays it.
  88. */
  89. class GraphDocumentComponent : public Component
  90. {
  91. public:
  92. //==============================================================================
  93. GraphDocumentComponent (FilterGraph& graph);
  94. ~GraphDocumentComponent();
  95. //==============================================================================
  96. void createNewPlugin (const PluginDescription* desc, int x, int y);
  97. //==============================================================================
  98. FilterGraph& graph;
  99. //==============================================================================
  100. void resized();
  101. //==============================================================================
  102. void closeAllCurrentlyOpenWindows();
  103. MidiKeyboardState* getMidiState() noexcept;
  104. private:
  105. //==============================================================================
  106. MidiKeyboardState keyState;
  107. GraphEditorPanel* graphPanel;
  108. Component* keyboardComp;
  109. Component* statusBar;
  110. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphDocumentComponent)
  111. };
  112. #endif // __GRAPHEDITORPANEL_JUCEHEADER__