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.

117 lines
3.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. #include "FilterGraph.h"
  21. //==============================================================================
  22. /**
  23. A panel that displays and edits a FilterGraph.
  24. */
  25. class GraphEditorPanel : public Component,
  26. public ChangeListener
  27. {
  28. public:
  29. GraphEditorPanel (FilterGraph& graph);
  30. ~GraphEditorPanel();
  31. void createNewPlugin (const PluginDescription&, Point<int> position);
  32. void paint (Graphics&) override;
  33. void mouseDown (const MouseEvent&) override;
  34. void resized() override;
  35. void changeListenerCallback (ChangeBroadcaster*) override;
  36. void updateComponents();
  37. //==============================================================================
  38. void beginConnectorDrag (AudioProcessorGraph::NodeAndChannel source,
  39. AudioProcessorGraph::NodeAndChannel dest,
  40. const MouseEvent&);
  41. void dragConnector (const MouseEvent&);
  42. void endDraggingConnector (const MouseEvent&);
  43. //==============================================================================
  44. FilterGraph& graph;
  45. private:
  46. struct FilterComponent;
  47. struct ConnectorComponent;
  48. struct PinComponent;
  49. OwnedArray<FilterComponent> nodes;
  50. OwnedArray<ConnectorComponent> connectors;
  51. ScopedPointer<ConnectorComponent> draggingConnector;
  52. FilterComponent* getComponentForFilter (AudioProcessorGraph::NodeID) const;
  53. ConnectorComponent* getComponentForConnection (const AudioProcessorGraph::Connection&) const;
  54. PinComponent* findPinAt (Point<float>) const;
  55. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphEditorPanel)
  56. };
  57. //==============================================================================
  58. /**
  59. A panel that embeds a GraphEditorPanel with a midi keyboard at the bottom.
  60. It also manages the graph itself, and plays it.
  61. */
  62. class GraphDocumentComponent : public Component
  63. {
  64. public:
  65. GraphDocumentComponent (AudioPluginFormatManager& formatManager,
  66. AudioDeviceManager& deviceManager);
  67. ~GraphDocumentComponent();
  68. //==============================================================================
  69. void createNewPlugin (const PluginDescription&, Point<int> position);
  70. void setDoublePrecision (bool doublePrecision);
  71. bool closeAnyOpenPluginWindows();
  72. //==============================================================================
  73. ScopedPointer<FilterGraph> graph;
  74. void resized();
  75. void unfocusKeyboardComponent();
  76. void releaseGraph();
  77. ScopedPointer<GraphEditorPanel> graphPanel;
  78. ScopedPointer<MidiKeyboardComponent> keyboardComp;
  79. private:
  80. //==============================================================================
  81. AudioDeviceManager& deviceManager;
  82. AudioProcessorPlayer graphPlayer;
  83. MidiKeyboardState keyState;
  84. struct TooltipBar;
  85. ScopedPointer<TooltipBar> statusBar;
  86. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphDocumentComponent)
  87. };