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.

142 lines
4.6KB

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