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.

173 lines
6.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #pragma once
  19. #include "../Plugins/PluginGraph.h"
  20. class MainHostWindow;
  21. //==============================================================================
  22. /**
  23. A panel that displays and edits a PluginGraph.
  24. */
  25. class GraphEditorPanel : public Component,
  26. public ChangeListener,
  27. private Timer
  28. {
  29. public:
  30. GraphEditorPanel (PluginGraph& graph);
  31. ~GraphEditorPanel() override;
  32. void createNewPlugin (const PluginDescription&, Point<int> position);
  33. void paint (Graphics&) override;
  34. void resized() override;
  35. void mouseDown (const MouseEvent&) override;
  36. void mouseUp (const MouseEvent&) override;
  37. void mouseDrag (const MouseEvent&) override;
  38. void changeListenerCallback (ChangeBroadcaster*) override;
  39. //==============================================================================
  40. void updateComponents();
  41. //==============================================================================
  42. void showPopupMenu (Point<int> position);
  43. //==============================================================================
  44. void beginConnectorDrag (AudioProcessorGraph::NodeAndChannel source,
  45. AudioProcessorGraph::NodeAndChannel dest,
  46. const MouseEvent&);
  47. void dragConnector (const MouseEvent&);
  48. void endDraggingConnector (const MouseEvent&);
  49. //==============================================================================
  50. PluginGraph& graph;
  51. private:
  52. struct PluginComponent;
  53. struct ConnectorComponent;
  54. struct PinComponent;
  55. OwnedArray<PluginComponent> nodes;
  56. OwnedArray<ConnectorComponent> connectors;
  57. std::unique_ptr<ConnectorComponent> draggingConnector;
  58. std::unique_ptr<PopupMenu> menu;
  59. PluginComponent* getComponentForPlugin (AudioProcessorGraph::NodeID) const;
  60. ConnectorComponent* getComponentForConnection (const AudioProcessorGraph::Connection&) const;
  61. PinComponent* findPinAt (Point<float>) const;
  62. //==============================================================================
  63. Point<int> originalTouchPos;
  64. void timerCallback() override;
  65. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphEditorPanel)
  66. };
  67. //==============================================================================
  68. /**
  69. A panel that embeds a GraphEditorPanel with a midi keyboard at the bottom.
  70. It also manages the graph itself, and plays it.
  71. */
  72. class GraphDocumentComponent : public Component,
  73. public DragAndDropTarget,
  74. public DragAndDropContainer,
  75. private ChangeListener
  76. {
  77. public:
  78. GraphDocumentComponent (AudioPluginFormatManager& formatManager,
  79. AudioDeviceManager& deviceManager,
  80. KnownPluginList& pluginList);
  81. ~GraphDocumentComponent() override;
  82. //==============================================================================
  83. void createNewPlugin (const PluginDescription&, Point<int> position);
  84. void setDoublePrecision (bool doublePrecision);
  85. bool closeAnyOpenPluginWindows();
  86. //==============================================================================
  87. std::unique_ptr<PluginGraph> graph;
  88. void resized() override;
  89. void unfocusKeyboardComponent();
  90. void releaseGraph();
  91. //==============================================================================
  92. bool isInterestedInDragSource (const SourceDetails&) override;
  93. void itemDropped (const SourceDetails&) override;
  94. //==============================================================================
  95. std::unique_ptr<GraphEditorPanel> graphPanel;
  96. std::unique_ptr<MidiKeyboardComponent> keyboardComp;
  97. //==============================================================================
  98. void showSidePanel (bool isSettingsPanel);
  99. void hideLastSidePanel();
  100. BurgerMenuComponent burgerMenu;
  101. private:
  102. //==============================================================================
  103. AudioDeviceManager& deviceManager;
  104. KnownPluginList& pluginList;
  105. AudioProcessorPlayer graphPlayer;
  106. MidiKeyboardState keyState;
  107. MidiOutput* midiOutput = nullptr;
  108. struct TooltipBar;
  109. std::unique_ptr<TooltipBar> statusBar;
  110. class TitleBarComponent;
  111. std::unique_ptr<TitleBarComponent> titleBarComponent;
  112. //==============================================================================
  113. struct PluginListBoxModel;
  114. std::unique_ptr<PluginListBoxModel> pluginListBoxModel;
  115. ListBox pluginListBox;
  116. SidePanel mobileSettingsSidePanel { "Settings", 300, true };
  117. SidePanel pluginListSidePanel { "Plugins", 250, false };
  118. SidePanel* lastOpenedSidePanel = nullptr;
  119. //==============================================================================
  120. void changeListenerCallback (ChangeBroadcaster*) override;
  121. void init();
  122. void checkAvailableWidth();
  123. void updateMidiOutput();
  124. //==============================================================================
  125. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphDocumentComponent)
  126. };