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.

juce_ConcertinaPanel.h 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. A panel which holds a vertical stack of components which can be expanded
  23. and contracted.
  24. Each section has its own header bar which can be dragged up and down
  25. to resize it, or double-clicked to fully expand that section.
  26. @tags{GUI}
  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() override;
  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() = default;
  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. std::unique_ptr<PanelSizes> currentSizes;
  102. OwnedArray<PanelHolder> holders;
  103. ComponentAnimator animator;
  104. int headerHeight;
  105. int indexOfComp (Component*) const noexcept;
  106. PanelSizes getFittedSizes() const;
  107. void applyLayout (const PanelSizes&, bool animate);
  108. void setLayout (const PanelSizes&, bool animate);
  109. void panelHeaderDoubleClicked (Component*);
  110. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ConcertinaPanel)
  111. };
  112. } // namespace juce