52 propertyComps.clear();
79 int getPreferredHeight()
const
96 void setOpen (
bool open)
110 void refreshAll()
const
126 if (e.
y < titleHeight)
145 void updateLayout (
int width)
159 void refreshAll()
const
171 SectionComponent* getSectionWithNonEmptyName (
int targetIndex)
const noexcept
176 if (
section->getName().isNotEmpty())
201void PropertyPanel::init()
203 messageWhenEmpty =
TRANS (
"(nothing selected)");
206 viewport.
setViewedComponent (propertyHolderComponent =
new PropertyHolderComponent());
220 g.
setColour (Colours::black.withAlpha (0.5f));
230 updatePropHolderLayout();
238 propertyHolderComponent->sections.clear();
239 updatePropHolderLayout();
245 return propertyHolderComponent->sections.size() == 0;
250 return propertyHolderComponent->
getHeight();
260 updatePropHolderLayout();
279 updatePropHolderLayout();
282void PropertyPanel::updatePropHolderLayout()
const
285 propertyHolderComponent->updateLayout (maxWidth);
291 propertyHolderComponent->updateLayout (
newMaxWidth);
297 propertyHolderComponent->refreshAll();
305 for (
auto*
section : propertyHolderComponent->sections)
307 if (
section->getName().isNotEmpty())
316 if (
auto* s = propertyHolderComponent->getSectionWithNonEmptyName (sectionIndex))
324 if (
auto* s = propertyHolderComponent->getSectionWithNonEmptyName (sectionIndex))
330 if (
auto* s = propertyHolderComponent->getSectionWithNonEmptyName (sectionIndex))
336 if (
auto* s = propertyHolderComponent->getSectionWithNonEmptyName (sectionIndex))
338 propertyHolderComponent->sections.removeObject (s);
339 updatePropHolderLayout();
346 auto xml = std::make_unique<XmlElement> (
"PROPERTYPANELSTATE");
351 for (
auto s : sections)
355 auto* e = xml->createNewChildElement (
"SECTION");
356 e->setAttribute (
"name", s);
357 e->setAttribute (
"open",
isSectionOpen (sections.indexOf (s)) ? 1 : 0);
372 setSectionOpen (sections.indexOf (e->getStringAttribute (
"name")),
373 e->getBoolAttribute (
"open"));
393 return messageWhenEmpty;
Holds a resizable array of primitive or copy-by-value objects.
The base class for all JUCE user-interface objects.
void setFocusContainerType(FocusContainerType containerType) noexcept
Sets whether this component is a container for components that can have their focus traversed,...
int getHeight() const noexcept
Returns the component's height in pixels.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
void repaint()
Marks the whole component as needing to be redrawn.
Component() noexcept
Creates a component.
@ keyboardFocusContainer
The component will act as a top-level component within which keyboard focus is passed around.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
void setSize(int newWidth, int newHeight)
Changes the size of the component.
int getWidth() const noexcept
Returns the component's width in pixels.
LookAndFeel & getLookAndFeel() const noexcept
Finds the appropriate look-and-feel to use for this component.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
virtual void setVisible(bool shouldBeVisible)
Makes the component visible or invisible.
String getName() const noexcept
Returns the name of this component.
A graphics context, used for drawing a component or image.
void drawText(const String &text, int x, int y, int width, int height, Justification justificationType, bool useEllipsesIfTooBig=true) const
Draws a line of text within a specified rectangle.
void setFont(const Font &newFont)
Changes the font to use for subsequent text-drawing functions.
void setColour(Colour newColour)
Changes the current drawing colour.
@ centred
Indicates that the item should be centred vertically and horizontally.
Contains position and status information about a mouse event.
int getMouseDownX() const noexcept
Returns the x coordinate of the last place that a mouse was pressed.
const int x
The x-position of the mouse when the event occurred.
const int y
The y-position of the mouse when the event occurred.
int getNumberOfClicks() const noexcept
For a click event, the number of times the mouse was clicked in succession.
An array designed for holding objects.
void paint(Graphics &) override
Components can override this method to draw their content.
StringArray getSectionNames() const
Returns a list of all the names of sections in the panel.
void setSectionEnabled(int sectionIndex, bool shouldBeEnabled)
Enables or disables one of the sections.
bool isEmpty() const
Returns true if the panel contains no properties.
std::unique_ptr< XmlElement > getOpennessState() const
Saves the current state of open/closed sections so it can be restored later.
int getTotalContentHeight() const
Returns the height that the panel needs in order to display all of its content without scrolling.
bool isSectionOpen(int sectionIndex) const
Returns true if the section at this index is currently open.
void setSectionOpen(int sectionIndex, bool shouldBeOpen)
Opens or closes one of the sections.
void removeSection(int sectionIndex)
Remove one of the sections using the section index.
void resized() override
Called when this component's size has been changed.
void addSection(const String §ionTitle, const Array< PropertyComponent * > &newPropertyComponents, bool shouldSectionInitiallyBeOpen=true, int indexToInsertAt=-1, int extraPaddingBetweenComponents=0)
Adds a set of properties to the panel.
PropertyPanel()
Creates an empty property panel.
const String & getMessageWhenEmpty() const noexcept
Returns the message that is displayed when there are no properties.
~PropertyPanel() override
Destructor.
void setMessageWhenEmpty(const String &newMessage)
Sets a message to be displayed when there are no properties in the panel.
void clear()
Deletes all property components from the panel.
void refreshAll() const
Calls the refresh() method of all PropertyComponents in the panel.
void addProperties(const Array< PropertyComponent * > &newPropertyComponents, int extraPaddingBetweenComponents=0)
Adds a set of properties to the panel.
void restoreOpennessState(const XmlElement &newState)
Restores a previously saved arrangement of open/closed sections.
A special array for holding a list of strings.
void add(String stringToAdd)
Appends a string at the end of the array.
int getViewPositionX() const noexcept
Returns the position within the child component of the top-left of its visible area.
void setViewPosition(int xPixelsOffset, int yPixelsOffset)
Changes the position of the viewed component.
int getViewPositionY() const noexcept
Returns the position within the child component of the top-left of its visible area.
int getMaximumVisibleWidth() const
Returns the width available within this component for the contents.
void setViewedComponent(Component *newViewedComponent, bool deleteComponentWhenNoLongerNeeded=true)
Sets the component that this viewport will contain and scroll around.
Used to build a tree of elements representing an XML document.
Iterator< GetNextElementWithTagName > getChildWithTagNameIterator(StringRef name) const
Allows iterating children of an XmlElement with a specific tag using range-for syntax.
bool hasTagName(StringRef possibleTagName) const noexcept
Tests whether this element has a particular tag name.
int getIntAttribute(StringRef attributeName, int defaultReturnValue=0) const
Returns the value of a named attribute as an integer.
#define TRANS(stringLiteral)
Uses the LocalisedStrings class to translate the given string literal.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
void paint(Graphics &) override
Components can override this method to draw their content.
void resized() override
Called when this component's size has been changed.
void lookAndFeelChanged() override
Called to let the component react to a change in the look-and-feel setting.
void mouseDoubleClick(const MouseEvent &e) override
Called when a mouse button has been double-clicked on a component.
void mouseUp(const MouseEvent &e) override
Called when a mouse button is released.
void paint(Graphics &g) override
Components can override this method to draw their content.