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.

139 lines
4.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-9 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_FILTERGRAPHEDITOR_JUCEHEADER__
  19. #define __JUCE_FILTERGRAPHEDITOR_JUCEHEADER__
  20. #include "FilterGraph.h"
  21. class FilterComponent;
  22. class ConnectorComponent;
  23. class PinComponent;
  24. //==============================================================================
  25. /**
  26. A panel that displays and edits a FilterGraph.
  27. */
  28. class GraphEditorPanel : public Component,
  29. public ChangeListener
  30. {
  31. public:
  32. GraphEditorPanel (FilterGraph& graph);
  33. ~GraphEditorPanel();
  34. void paint (Graphics& g);
  35. void mouseDown (const MouseEvent& e);
  36. void createNewPlugin (const PluginDescription* desc, int x, int y);
  37. FilterComponent* getComponentForFilter (const uint32 filterID) const;
  38. ConnectorComponent* getComponentForConnection (const AudioProcessorGraph::Connection& conn) const;
  39. PinComponent* findPinAt (const int x, const int y) const;
  40. void resized();
  41. void changeListenerCallback (ChangeBroadcaster*);
  42. void updateComponents();
  43. //==============================================================================
  44. void beginConnectorDrag (const uint32 sourceFilterID, const int sourceFilterChannel,
  45. const uint32 destFilterID, const int destFilterChannel,
  46. const MouseEvent& e);
  47. void dragConnector (const MouseEvent& e);
  48. void endDraggingConnector (const MouseEvent& e);
  49. //==============================================================================
  50. private:
  51. FilterGraph& graph;
  52. ConnectorComponent* draggingConnector;
  53. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphEditorPanel);
  54. };
  55. //==============================================================================
  56. /**
  57. A panel that embeds a GraphEditorPanel with a midi keyboard at the bottom.
  58. It also manages the graph itself, and plays it.
  59. */
  60. class GraphDocumentComponent : public Component
  61. {
  62. public:
  63. //==============================================================================
  64. GraphDocumentComponent (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. */
  85. class PluginWindow : public DocumentWindow
  86. {
  87. PluginWindow (Component* const uiComp,
  88. AudioProcessorGraph::Node* owner_,
  89. const bool isGeneric_);
  90. public:
  91. static PluginWindow* getWindowFor (AudioProcessorGraph::Node* node,
  92. bool useGenericView);
  93. static void closeCurrentlyOpenWindowsFor (const uint32 nodeId);
  94. static void closeAllCurrentlyOpenWindows();
  95. ~PluginWindow();
  96. void moved();
  97. void closeButtonPressed();
  98. private:
  99. AudioProcessorGraph::Node* owner;
  100. bool isGeneric;
  101. };
  102. #endif