Audio plugin host https://kx.studio/carla
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.

146 lines
5.8KB

  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. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. A panel which holds a vertical stack of components which can be expanded
  24. and contracted.
  25. Each section has its own header bar which can be dragged up and down
  26. to resize it, or double-clicked to fully expand that section.
  27. */
  28. class JUCE_API ConcertinaPanel : public Component
  29. {
  30. public:
  31. /** Creates an empty concertina panel.
  32. You can call addPanel() to add some components to it.
  33. */
  34. ConcertinaPanel();
  35. /** Destructor. */
  36. ~ConcertinaPanel();
  37. /** Adds a component to the panel.
  38. @param insertIndex the index at which this component will be inserted, or
  39. -1 to append it to the end of the list.
  40. @param component the component that will be shown
  41. @param takeOwnership if true, then the ConcertinaPanel will take ownership
  42. of the content component, and will delete it later when
  43. it's no longer needed. If false, it won't delete it, and
  44. you must make sure it doesn't get deleted while in use.
  45. */
  46. void addPanel (int insertIndex, Component* component, bool takeOwnership);
  47. /** Removes one of the panels.
  48. If the takeOwnership flag was set when the panel was added, then
  49. this will also delete the component.
  50. */
  51. void removePanel (Component* panelComponent);
  52. /** Returns the number of panels.
  53. @see getPanel
  54. */
  55. int getNumPanels() const noexcept;
  56. /** Returns one of the panels.
  57. @see getNumPanels()
  58. */
  59. Component* getPanel (int index) const noexcept;
  60. /** Resizes one of the panels.
  61. The panelComponent must point to a valid panel component.
  62. If animate is true, the panels will be animated into their new positions;
  63. if false, they will just be immediately resized.
  64. */
  65. bool setPanelSize (Component* panelComponent, int newHeight, bool animate);
  66. /** Attempts to make one of the panels full-height.
  67. The panelComponent must point to a valid panel component.
  68. If this component has had a maximum size set, then it will be
  69. expanded to that size. Otherwise, it'll fill as much of the total
  70. space as possible.
  71. */
  72. bool expandPanelFully (Component* panelComponent, bool animate);
  73. /** Sets a maximum size for one of the panels. */
  74. void setMaximumPanelSize (Component* panelComponent, int maximumSize);
  75. /** Sets the height of the header section for one of the panels. */
  76. void setPanelHeaderSize (Component* panelComponent, int headerSize);
  77. /** Sets a custom header Component for one of the panels.
  78. @param panelComponent the panel component to add the custom header to.
  79. @param customHeaderComponent the custom component to use for the panel header.
  80. This can be nullptr to clear the custom header component
  81. and just use the standard LookAndFeel panel.
  82. @param takeOwnership if true, then the PanelHolder will take ownership
  83. of the custom header component, and will delete it later when
  84. it's no longer needed. If false, it won't delete it, and
  85. you must make sure it doesn't get deleted while in use.
  86. */
  87. void setCustomPanelHeader (Component* panelComponent, Component* customHeaderComponent, bool takeOwnership);
  88. //==============================================================================
  89. /** This abstract base class is implemented by LookAndFeel classes. */
  90. struct JUCE_API LookAndFeelMethods
  91. {
  92. virtual ~LookAndFeelMethods() {}
  93. virtual void drawConcertinaPanelHeader (Graphics&, const Rectangle<int>& area,
  94. bool isMouseOver, bool isMouseDown,
  95. ConcertinaPanel&, Component&) = 0;
  96. };
  97. private:
  98. void resized() override;
  99. class PanelHolder;
  100. struct PanelSizes;
  101. friend class PanelHolder;
  102. friend struct PanelSizes;
  103. friend struct ContainerDeletePolicy<PanelSizes>;
  104. friend struct ContainerDeletePolicy<PanelHolder>;
  105. ScopedPointer<PanelSizes> currentSizes;
  106. OwnedArray<PanelHolder> holders;
  107. ComponentAnimator animator;
  108. int headerHeight;
  109. int indexOfComp (Component*) const noexcept;
  110. PanelSizes getFittedSizes() const;
  111. void applyLayout (const PanelSizes&, bool animate);
  112. void setLayout (const PanelSizes&, bool animate);
  113. void panelHeaderDoubleClicked (Component*);
  114. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ConcertinaPanel)
  115. };
  116. } // namespace juce