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.

166 lines
5.8KB

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