diff --git a/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp b/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp index aee1c82e63..ab207c4da4 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp +++ b/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp @@ -30,9 +30,11 @@ struct PropertyPanel::SectionComponent : public Component { SectionComponent (const String& sectionTitle, const Array& newProperties, - bool sectionIsOpen) + bool sectionIsOpen, + int extraPadding) : Component (sectionTitle), - isOpen (sectionIsOpen) + isOpen (sectionIsOpen), + padding (extraPadding) { lookAndFeelChanged(); @@ -63,7 +65,7 @@ struct PropertyPanel::SectionComponent : public Component for (auto* propertyComponent : propertyComps) { propertyComponent->setBounds (1, y, getWidth() - 2, propertyComponent->getPreferredHeight()); - y = propertyComponent->getBottom(); + y = propertyComponent->getBottom() + padding; } } @@ -78,10 +80,16 @@ struct PropertyPanel::SectionComponent : public Component { auto y = titleHeight; - if (isOpen) + auto numComponents = propertyComps.size(); + + if (numComponents > 0 && isOpen) + { for (auto* propertyComponent : propertyComps) y += propertyComponent->getPreferredHeight(); + y += (numComponents - 1) * padding; + } + return y; } @@ -122,6 +130,7 @@ struct PropertyPanel::SectionComponent : public Component OwnedArray propertyComps; int titleHeight; bool isOpen; + int padding; JUCE_DECLARE_NON_COPYABLE (SectionComponent) }; @@ -241,26 +250,32 @@ int PropertyPanel::getTotalContentHeight() const return propertyHolderComponent->getHeight(); } -void PropertyPanel::addProperties (const Array& newProperties) +void PropertyPanel::addProperties (const Array& newProperties, + int extraPaddingBetweenComponents) { if (isEmpty()) repaint(); - propertyHolderComponent->insertSection (-1, new SectionComponent (String(), newProperties, true)); + propertyHolderComponent->insertSection (-1, new SectionComponent ({}, newProperties, true, extraPaddingBetweenComponents)); updatePropHolderLayout(); } void PropertyPanel::addSection (const String& sectionTitle, const Array& newProperties, bool shouldBeOpen, - int indexToInsertAt) + int indexToInsertAt, + int extraPaddingBetweenComponents) { jassert (sectionTitle.isNotEmpty()); if (isEmpty()) repaint(); - propertyHolderComponent->insertSection (indexToInsertAt, new SectionComponent (sectionTitle, newProperties, shouldBeOpen)); + propertyHolderComponent->insertSection (indexToInsertAt, new SectionComponent (sectionTitle, + newProperties, + shouldBeOpen, + extraPaddingBetweenComponents)); + updatePropHolderLayout(); } diff --git a/modules/juce_gui_basics/properties/juce_PropertyPanel.h b/modules/juce_gui_basics/properties/juce_PropertyPanel.h index 94bafef89a..b1272839ad 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyPanel.h +++ b/modules/juce_gui_basics/properties/juce_PropertyPanel.h @@ -65,7 +65,8 @@ public: These properties are added without them being inside a named section. If you want them to be kept together in a collapsible section, use addSection() instead. */ - void addProperties (const Array& newPropertyComponents); + void addProperties (const Array& newPropertyComponents, + int extraPaddingBetweenComponents = 0); /** Adds a set of properties to the panel. @@ -81,7 +82,8 @@ public: void addSection (const String& sectionTitle, const Array& newPropertyComponents, bool shouldSectionInitiallyBeOpen = true, - int indexToInsertAt = -1); + int indexToInsertAt = -1, + int extraPaddingBetweenComponents = 0); /** Calls the refresh() method of all PropertyComponents in the panel */ void refreshAll() const;