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.

169 lines
5.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 "../Filters/FilterGraph.h"
  21. class MainHostWindow;
  22. //==============================================================================
  23. /**
  24. A panel that displays and edits a FilterGraph.
  25. */
  26. class GraphEditorPanel : public Component,
  27. public ChangeListener,
  28. private Timer
  29. {
  30. public:
  31. GraphEditorPanel (FilterGraph& graph);
  32. ~GraphEditorPanel();
  33. void createNewPlugin (const PluginDescription&, Point<int> position);
  34. void paint (Graphics&) override;
  35. void resized() override;
  36. void mouseDown (const MouseEvent&) override;
  37. void mouseUp (const MouseEvent&) override;
  38. void mouseDrag (const MouseEvent&) override;
  39. void changeListenerCallback (ChangeBroadcaster*) override;
  40. //==============================================================================
  41. void updateComponents();
  42. //==============================================================================
  43. void showPopupMenu (Point<int> position);
  44. //==============================================================================
  45. void beginConnectorDrag (AudioProcessorGraph::NodeAndChannel source,
  46. AudioProcessorGraph::NodeAndChannel dest,
  47. const MouseEvent&);
  48. void dragConnector (const MouseEvent&);
  49. void endDraggingConnector (const MouseEvent&);
  50. //==============================================================================
  51. FilterGraph& graph;
  52. private:
  53. struct FilterComponent;
  54. struct ConnectorComponent;
  55. struct PinComponent;
  56. OwnedArray<FilterComponent> nodes;
  57. OwnedArray<ConnectorComponent> connectors;
  58. std::unique_ptr<ConnectorComponent> draggingConnector;
  59. std::unique_ptr<PopupMenu> menu;
  60. FilterComponent* getComponentForFilter (AudioProcessorGraph::NodeID) const;
  61. ConnectorComponent* getComponentForConnection (const AudioProcessorGraph::Connection&) const;
  62. PinComponent* findPinAt (Point<float>) const;
  63. //==============================================================================
  64. Point<int> originalTouchPos;
  65. void timerCallback() override;
  66. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphEditorPanel)
  67. };
  68. //==============================================================================
  69. /**
  70. A panel that embeds a GraphEditorPanel with a midi keyboard at the bottom.
  71. It also manages the graph itself, and plays it.
  72. */
  73. class GraphDocumentComponent : public Component,
  74. public DragAndDropTarget,
  75. public DragAndDropContainer
  76. {
  77. public:
  78. GraphDocumentComponent (AudioPluginFormatManager& formatManager,
  79. AudioDeviceManager& deviceManager,
  80. KnownPluginList& pluginList);
  81. ~GraphDocumentComponent();
  82. //==============================================================================
  83. void createNewPlugin (const PluginDescription&, Point<int> position);
  84. void setDoublePrecision (bool doublePrecision);
  85. bool closeAnyOpenPluginWindows();
  86. //==============================================================================
  87. std::unique_ptr<FilterGraph> 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. struct TooltipBar;
  108. std::unique_ptr<TooltipBar> statusBar;
  109. class TitleBarComponent;
  110. std::unique_ptr<TitleBarComponent> titleBarComponent;
  111. //==============================================================================
  112. struct PluginListBoxModel;
  113. std::unique_ptr<PluginListBoxModel> pluginListBoxModel;
  114. ListBox pluginListBox;
  115. SidePanel mobileSettingsSidePanel { "Settings", 300, true };
  116. SidePanel pluginListSidePanel { "Plugins", 250, false };
  117. SidePanel* lastOpenedSidePanel = nullptr;
  118. //==============================================================================
  119. void init();
  120. void checkAvailableWidth();
  121. //==============================================================================
  122. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphDocumentComponent)
  123. };