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.

145 lines
4.8KB

  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 (AudioPluginFormatManager& formatManager,
  64. AudioDeviceManager* deviceManager);
  65. ~GraphDocumentComponent();
  66. //==============================================================================
  67. void createNewPlugin (const PluginDescription* desc, int x, int y);
  68. //==============================================================================
  69. FilterGraph graph;
  70. //==============================================================================
  71. void resized();
  72. private:
  73. //==============================================================================
  74. AudioDeviceManager* deviceManager;
  75. AudioProcessorPlayer graphPlayer;
  76. MidiKeyboardState keyState;
  77. GraphEditorPanel* graphPanel;
  78. Component* keyboardComp;
  79. Component* statusBar;
  80. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphDocumentComponent)
  81. };
  82. //==============================================================================
  83. /** A desktop window containing a plugin's UI. */
  84. class PluginWindow : public DocumentWindow
  85. {
  86. public:
  87. enum WindowFormatType
  88. {
  89. Normal = 0,
  90. Generic,
  91. Programs,
  92. Parameters
  93. };
  94. PluginWindow (Component* pluginEditor, AudioProcessorGraph::Node*, WindowFormatType);
  95. ~PluginWindow();
  96. static PluginWindow* getWindowFor (AudioProcessorGraph::Node*, WindowFormatType);
  97. static void closeCurrentlyOpenWindowsFor (const uint32 nodeId);
  98. static void closeAllCurrentlyOpenWindows();
  99. void moved() override;
  100. void closeButtonPressed() override;
  101. private:
  102. AudioProcessorGraph::Node* owner;
  103. WindowFormatType type;
  104. float getDesktopScaleFactor() const override { return 1.0f; }
  105. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginWindow)
  106. };
  107. #endif // __GRAPHEDITORPANEL_JUCEHEADER__