foleys_gui_magic
WYSWYG editor for JUCE GUIs including Visualisers
Public Member Functions | Public Attributes | Protected Attributes | List of all members
GuiItem Class Referenceabstract

The GuiItem class will draw borders and descriptions around widgets, if defined. More...

+ Inheritance diagram for GuiItem:

Public Member Functions

 GuiItem (MagicGUIBuilder &builder, juce::ValueTree node)
 
 ~GuiItem () override
 
virtual juce::Component * getWrappedComponent ()=0
 Allows accessing the Component inside that GuiItem. More...
 
virtual void update ()=0
 In update() the ValueTree properties should be used to set all properties to the component. More...
 
virtual void updateColours ()
 Set colours in the wrapped Component to the value from the stylesheet and palette. More...
 
virtual std::vector< SettablePropertygetSettableProperties () const
 Override this to return each settable option the designer should be able to configure on your component. More...
 
void setColourTranslation (std::vector< std::pair< juce::String, int >> mapping)
 For each factory you can register a translation table, which will forward the colours from the Stylesheet to the Components. More...
 
juce::StringArray getColourNames () const
 Return the names of configurable colours. More...
 
virtual juce::String getControlledParameterID (juce::Point< int >)
 Returns the parameterID that is controlled from this component. More...
 
juce::var getProperty (const juce::Identifier &property)
 Look up a value through the DOM and CSS. More...
 
MagicGUIStategetMagicState ()
 
virtual GuiItemfindGuiItemWithId (const juce::String &name)
 Lookup a Component through the tree. More...
 
void updateInternal ()
 Reread properties from the config ValueTree. More...
 
void paint (juce::Graphics &g) final
 
void resized () override
 
virtual bool isContainer () const
 
virtual void createSubComponents ()
 
virtual void updateLayout ()
 This will trigger a recalculation of the children layout regardless of resized. More...
 
LayoutType getParentsLayoutType () const
 Returns the layout type this item is managed by. More...
 
void configureFlexBoxItem (const juce::ValueTree &node)
 Parse the values and set it to the FlexBox::Item for layouting. More...
 
void configurePosition (const juce::ValueTree &node)
 
juce::Rectangle< int > resolvePosition (juce::Rectangle< int > parent)
 Calculates the position according to the parent area. More...
 
juce::Rectangle< int > getClientBounds () const
 Returns the bounds of the wrapped Component. More...
 
juce::String getTabCaption (const juce::String &defaultName) const
 
juce::Colour getTabColour () const
 
juce::FlexItem & getFlexItem ()
 
void itemDragEnter (const juce::DragAndDropTarget::SourceDetails &details) override
 
void itemDragExit (const juce::DragAndDropTarget::SourceDetails &details) override
 
void paintOverChildren (juce::Graphics &g) override
 
virtual GuiItemfindGuiItem (const juce::ValueTree &node)
 Seeks recursively for a GuiItem. More...
 
bool isInterestedInDragSource (const juce::DragAndDropTarget::SourceDetails &dragSourceDetails) override
 
void itemDropped (const juce::DragAndDropTarget::SourceDetails &dragSourceDetails) override
 

Public Attributes

MagicGUIBuildermagicBuilder
 

Protected Attributes

juce::ValueTree configNode
 
Decorator decorator
 
juce::FlexItem flexItem { juce::FlexItem (*this).withFlex (1.0f) }
 
std::vector< std::pair< juce::String, int > > colourTranslation
 

Detailed Description

The GuiItem class will draw borders and descriptions around widgets, if defined.

It also owns the Component and the Attachment, in case the Component is connected to an AudioProcessorValueTreeState.

Constructor & Destructor Documentation

◆ GuiItem()

GuiItem ( MagicGUIBuilder builder,
juce::ValueTree  node 
)

◆ ~GuiItem()

~GuiItem ( )
override

Member Function Documentation

◆ getWrappedComponent()

virtual juce::Component* getWrappedComponent ( )
pure virtual

Allows accessing the Component inside that GuiItem.

Don't keep this pointer!

Implemented in Container, ListBoxItem, MidiLearnItem, LevelMeterItem, KeyboardItem, XYDraggerItem, PlotItem, LabelItem, ToggleButtonItem, TextButtonItem, ComboBoxItem, and SliderItem.

Referenced by GuiItem::resized(), and GuiItem::updateColours().

◆ update()

virtual void update ( )
pure virtual

In update() the ValueTree properties should be used to set all properties to the component.

You can use the magicBuilder to resolve properties from CSS. The Colours will be handled by default.

Implemented in Container, ListBoxItem, MidiLearnItem, LevelMeterItem, KeyboardItem, XYDraggerItem, PlotItem, LabelItem, ToggleButtonItem, TextButtonItem, ComboBoxItem, and SliderItem.

Referenced by GuiItem::updateInternal().

◆ updateColours()

void updateColours ( )
virtual

Set colours in the wrapped Component to the value from the stylesheet and palette.

Reimplemented in RootItem, and Container.

References GuiItem::colourTranslation, GuiItem::configNode, GuiItem::decorator, GuiItem::getWrappedComponent(), GuiItem::magicBuilder, and Decorator::updateColours().

Referenced by GuiItem::updateInternal().

◆ getSettableProperties()

virtual std::vector<SettableProperty> getSettableProperties ( ) const
virtual

Override this to return each settable option the designer should be able to configure on your component.

Reimplemented in ListBoxItem, LevelMeterItem, XYDraggerItem, PlotItem, LabelItem, ToggleButtonItem, TextButtonItem, ComboBoxItem, and SliderItem.

◆ setColourTranslation()

void setColourTranslation ( std::vector< std::pair< juce::String, int >>  mapping)

◆ getColourNames()

juce::StringArray getColourNames ( ) const

Return the names of configurable colours.

References GuiItem::colourTranslation.

◆ getControlledParameterID()

virtual juce::String getControlledParameterID ( juce::Point< int >  )
virtual

Returns the parameterID that is controlled from this component.

To allow multiple return values depending of the position where the drop arrived there is the drop position supplied.

Reimplemented in SliderItem.

Referenced by GuiItem::itemDragEnter(), and GuiItem::itemDropped().

◆ getProperty()

juce::var getProperty ( const juce::Identifier &  property)

◆ getMagicState()

MagicGUIState & getMagicState ( )

◆ findGuiItemWithId()

GuiItem * findGuiItemWithId ( const juce::String &  name)
virtual

Lookup a Component through the tree.

It will return the first with that id regardless if there is another one. We discourage using that function, because that Component can be deleted and recreated at any time without notice.

Reimplemented in Container.

◆ updateInternal()

void updateInternal ( )

◆ paint()

void paint ( juce::Graphics &  g)
final

◆ resized()

void resized ( )
override

◆ isContainer()

virtual bool isContainer ( ) const
virtual

Reimplemented in Container.

◆ createSubComponents()

virtual void createSubComponents ( )
virtual

Reimplemented in Container.

◆ updateLayout()

void updateLayout ( )
virtual

This will trigger a recalculation of the children layout regardless of resized.

Reimplemented in Container.

References GuiItem::resized().

◆ getParentsLayoutType()

LayoutType getParentsLayoutType ( ) const

Returns the layout type this item is managed by.

References foleys::Contents.

◆ configureFlexBoxItem()

void configureFlexBoxItem ( const juce::ValueTree &  node)

Parse the values and set it to the FlexBox::Item for layouting.

References GuiItem::flexItem.

Referenced by GuiItem::updateInternal().

◆ configurePosition()

void configurePosition ( const juce::ValueTree &  node)

◆ resolvePosition()

juce::Rectangle< int > resolvePosition ( juce::Rectangle< int >  parent)

Calculates the position according to the parent area.

◆ getClientBounds()

juce::Rectangle< int > getClientBounds ( ) const

Returns the bounds of the wrapped Component.

This is the GuiItems bounds reduced by margin, padding and the caption, if one was set.

References Decorator::ClientBounds::client, GuiItem::decorator, and Decorator::getClientBounds().

Referenced by GuiItem::resized(), and Container::updateLayout().

◆ getTabCaption()

juce::String getTabCaption ( const juce::String &  defaultName) const

◆ getTabColour()

juce::Colour getTabColour ( ) const

◆ getFlexItem()

juce::FlexItem& getFlexItem ( )

References GuiItem::flexItem.

◆ itemDragEnter()

void itemDragEnter ( const juce::DragAndDropTarget::SourceDetails &  details)
override

◆ itemDragExit()

void itemDragExit ( const juce::DragAndDropTarget::SourceDetails &  details)
override

◆ paintOverChildren()

void paintOverChildren ( juce::Graphics &  g)
override

◆ findGuiItem()

GuiItem * findGuiItem ( const juce::ValueTree &  node)
virtual

Seeks recursively for a GuiItem.

Reimplemented in Container.

References GuiItem::configNode.

◆ isInterestedInDragSource()

bool isInterestedInDragSource ( const juce::DragAndDropTarget::SourceDetails &  dragSourceDetails)
override

◆ itemDropped()

void itemDropped ( const juce::DragAndDropTarget::SourceDetails &  dragSourceDetails)
override

Member Data Documentation

◆ magicBuilder

MagicGUIBuilder& magicBuilder

◆ configNode

juce::ValueTree configNode
protected

◆ decorator

Decorator decorator
protected

◆ flexItem

juce::FlexItem flexItem { juce::FlexItem (*this).withFlex (1.0f) }
protected

◆ colourTranslation

std::vector<std::pair<juce::String, int> > colourTranslation
protected

The documentation for this class was generated from the following files: