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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_CONCERTINAPANEL_H_INCLUDED
  18. #define JUCE_CONCERTINAPANEL_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A panel which holds a vertical stack of components which can be expanded
  22. and contracted.
  23. Each section has its own header bar which can be dragged up and down
  24. to resize it, or double-clicked to fully expand that section.
  25. */
  26. class JUCE_API ConcertinaPanel : public Component
  27. {
  28. public:
  29. /** Creates an empty concertina panel.
  30. You can call addPanel() to add some components to it.
  31. */
  32. ConcertinaPanel();
  33. /** Destructor. */
  34. ~ConcertinaPanel();
  35. /** Adds a component to the panel.
  36. @param insertIndex the index at which this component will be inserted, or
  37. -1 to append it to the end of the list.
  38. @param component the component that will be shown
  39. @param takeOwnership if true, then the ConcertinaPanel will take ownership
  40. of the content component, and will delete it later when
  41. it's no longer needed. If false, it won't delete it, and
  42. you must make sure it doesn't get deleted while in use.
  43. */
  44. void addPanel (int insertIndex, Component* component, bool takeOwnership);
  45. /** Removes one of the panels.
  46. If the takeOwnership flag was set when the panel was added, then
  47. this will also delete the component.
  48. */
  49. void removePanel (Component* panelComponent);
  50. /** Returns the number of panels.
  51. @see getPanel
  52. */
  53. int getNumPanels() const noexcept;
  54. /** Returns one of the panels.
  55. @see getNumPanels()
  56. */
  57. Component* getPanel (int index) const noexcept;
  58. /** Resizes one of the panels.
  59. The panelComponent must point to a valid panel component.
  60. If animate is true, the panels will be animated into their new positions;
  61. if false, they will just be immediately resized.
  62. */
  63. bool setPanelSize (Component* panelComponent, int newHeight, bool animate);
  64. /** Attempts to make one of the panels full-height.
  65. The panelComponent must point to a valid panel component.
  66. If this component has had a maximum size set, then it will be
  67. expanded to that size. Otherwise, it'll fill as much of the total
  68. space as possible.
  69. */
  70. bool expandPanelFully (Component* panelComponent, const bool animate);
  71. /** Sets a maximum size for one of the panels. */
  72. void setMaximumPanelSize (Component* panelComponent, int maximumSize);
  73. /** Sets the height of the header section for one of the panels. */
  74. void setPanelHeaderSize (Component* panelComponent, int headerSize);
  75. //==============================================================================
  76. /** This abstract base class is implemented by LookAndFeel classes. */
  77. struct JUCE_API LookAndFeelMethods
  78. {
  79. virtual ~LookAndFeelMethods() {}
  80. virtual void drawConcertinaPanelHeader (Graphics&, const Rectangle<int>& area,
  81. bool isMouseOver, bool isMouseDown, ConcertinaPanel&, Component&) = 0;
  82. };
  83. private:
  84. void resized() override;
  85. class PanelHolder;
  86. struct PanelSizes;
  87. friend class PanelHolder;
  88. friend struct PanelSizes;
  89. friend struct ContainerDeletePolicy<PanelSizes>;
  90. friend struct ContainerDeletePolicy<PanelHolder>;
  91. ScopedPointer<PanelSizes> currentSizes;
  92. OwnedArray<PanelHolder> holders;
  93. ComponentAnimator animator;
  94. int headerHeight;
  95. int indexOfComp (Component*) const noexcept;
  96. PanelSizes getFittedSizes() const;
  97. void applyLayout (const PanelSizes&, bool animate);
  98. void setLayout (const PanelSizes&, bool animate);
  99. void panelHeaderDoubleClicked (Component*);
  100. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ConcertinaPanel)
  101. };
  102. #endif // JUCE_CONCERTINAPANEL_H_INCLUDED