mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-24 01:54:22 +00:00
Added a way to specify some space between PropertyComponents in a PropertyPanel
This commit is contained in:
parent
9032f589eb
commit
0f975ee482
2 changed files with 27 additions and 10 deletions
|
|
@ -30,9 +30,11 @@ struct PropertyPanel::SectionComponent : public Component
|
|||
{
|
||||
SectionComponent (const String& sectionTitle,
|
||||
const Array<PropertyComponent*>& 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<PropertyComponent> 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<PropertyComponent*>& newProperties)
|
||||
void PropertyPanel::addProperties (const Array<PropertyComponent*>& 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<PropertyComponent*>& 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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<PropertyComponent*>& newPropertyComponents);
|
||||
void addProperties (const Array<PropertyComponent*>& newPropertyComponents,
|
||||
int extraPaddingBetweenComponents = 0);
|
||||
|
||||
/** Adds a set of properties to the panel.
|
||||
|
||||
|
|
@ -81,7 +82,8 @@ public:
|
|||
void addSection (const String& sectionTitle,
|
||||
const Array<PropertyComponent*>& 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue