ff_layout
Layout classes for JUCE
 All Classes Files Functions Variables Enumerations Enumerator
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
LayoutItem Class Reference

LayoutItems are used to store links to components to layout. More...

+ Inheritance diagram for LayoutItem:

Classes

class  Listener
 The LayoutItem::Listener will be called, whenever the bounds of a LayoutItem are changed. More...
 

Public Types

enum  ItemType {
  Invalid = 0, ComponentItem, LabeledComponentItem, SplitterItem,
  SpacerItem, LineItem, SubLayout
}
 
enum  Orientation {
  Unknown = 0, LeftToRight, TopDown, RightToLeft,
  BottomUp
}
 

Public Member Functions

 LayoutItem (LayoutItem::Orientation o)
 Create an empty layout as root node. More...
 
 LayoutItem (juce::ValueTree state)
 Instanciate a LayoutItem from it's state. More...
 
virtual ~LayoutItem ()
 
bool isValid ()
 Return if the layout item has a valid type. More...
 
void setOrientation (const Orientation, juce::UndoManager *undo=nullptr)
 Changes the orientation of the layout. More...
 
Orientation getOrientation () const
 Returns the orientation including direction. More...
 
bool isHorizontal () const
 Returns true if orientation is leftToRight or rightToLeft. More...
 
bool isVertical () const
 Returns true if orientation is topDown or BottomUp. More...
 
int isOverlay () const
 If overlay is set the item will be placed over an earlier defined item. More...
 
void setIsOverlay (const int overlay)
 
float getOverlayWidth () const
 Overlay width and overlay height are given in relative sizes to the referenced item. More...
 
void setOverlayWidth (float w)
 Overlay width and overlay height are given in relative sizes to the referenced item. More...
 
float getOverlayHeight () const
 Overlay width and overlay height are given in relative sizes to the referenced item. More...
 
void setOverlayHeight (float h)
 Overlay width and overlay height are given in relative sizes to the referenced item. More...
 
int getOverlayJustification () const
 overlayJustification defines, where the item is placed inside the referenced item More...
 
void setOverlayJustification (int j)
 overlayJustification defines, where the item is placed inside the referenced item More...
 
juce::Component * getComponent () const
 Return the managed component. More...
 
juce::String getComponentID () const
 Return the componentID. More...
 
bool hasComponent () const
 Returns true, if a component is set and available as pointer. More...
 
juce::Component * getWrappedComponent () const
 Return the wrapped component as pointer. More...
 
void setComponent (juce::Component *ptr, bool owned=false, juce::UndoManager *undo=nullptr)
 Replace the component pointer. More...
 
LayoutItem::SharedLayoutData * getOrCreateData (juce::UndoManager *undo=nullptr)
 Get or create a shared layout data blob. More...
 
bool isSpacerItem () const
 
bool isComponentItem () const
 
bool isSplitterItem () const
 
bool isSubLayout () const
 
void setLabelText (const juce::String &text, juce::UndoManager *undo=nullptr)
 Set the text for an automatically recreated Label as property. More...
 
void getStretch (float &w, float &h) const
 Return the stretch value of an item. More...
 
void setStretch (float w, float h, juce::UndoManager *undo=nullptr)
 Used to set stretch factors for the wrapped component. More...
 
void setMinimumWidth (const int w, juce::UndoManager *undo=nullptr)
 Set constraints to the items size. More...
 
void setMaximumWidth (const int w, juce::UndoManager *undo=nullptr)
 Set the maximum width. More...
 
void setMinimumHeight (const int h, juce::UndoManager *undo=nullptr)
 Set the minimum height. More...
 
void setMaximumHeight (const int h, juce::UndoManager *undo=nullptr)
 Set the maximum height. More...
 
int getMinimumWidth () const
 Returns the minimum width. More...
 
int getMaximumWidth () const
 Returns the maximum width. More...
 
int getMinimumHeight () const
 Returns the minimum height. More...
 
int getMaximumHeight () const
 Returns the maximum height. More...
 
virtual void getSizeLimits (int &minW, int &maxW, int &minH, int &maxH)
 Return the size limits of the item. More...
 
void setPaddingTop (const int p, juce::UndoManager *undo=nullptr)
 Set a padding value for the wrapped component or item to it's calculated top bounds. More...
 
void setPaddingLeft (const int p, juce::UndoManager *undo=nullptr)
 Set a padding value for the wrapped component or item to it's calculated left bounds. More...
 
void setPaddingRight (const int p, juce::UndoManager *undo=nullptr)
 Set a padding value for the wrapped component or item to it's calculated right bounds. More...
 
void setPaddingBottom (const int p, juce::UndoManager *undo=nullptr)
 Set a padding value for the wrapped component or item to it's calculated bottom bounds. More...
 
void setPadding (const int p, juce::UndoManager *undo=nullptr)
 Set one value to all bounaries. More...
 
int getPaddingTop () const
 Returns the padding value for the wrapped component or item to it's calculated top bounds. More...
 
int getPaddingLeft () const
 Returns the padding value for the wrapped component or item to it's calculated left bounds. More...
 
int getPaddingRight () const
 Returns the padding value for the wrapped component or item to it's calculated right bounds. More...
 
int getPaddingBottom () const
 Returns the padding value for the wrapped component or item to it's calculated bottom bounds. More...
 
void setFixedWidth (const int w, juce::UndoManager *undo=nullptr)
 Sets fixed width as minimum width = maximum width. More...
 
void setFixedHeight (const int h, juce::UndoManager *undo=nullptr)
 Sets fixed height as minimum height = maximum height. More...
 
void setFixedSize (const int w, const int h, juce::UndoManager *undo=nullptr)
 Convenience method to set fixed width and height in one call. More...
 
void setAspectRatio (const float ratio, juce::UndoManager *undo=nullptr)
 Set an aspect ratio to constrain the bounds. More...
 
float getAspectRatio () const
 Set an aspect ratio to constrain the bounds. More...
 
void setItemParameters (float inStretchX, float inStretchY, int inMinWidth, int inMinHeight, int inMaxWidth, int inMaxHeight, int inPaddingTop, int inPaddingLeft, int inPaddingRight, int inPaddingBottom, float inAspectRatio, juce::UndoManager *undo=nullptr)
 Convenience method to set all parameters in one line. More...
 
void constrainBounds (juce::Rectangle< int > &bounds, bool &changedWidth, bool &changedHeight, bool preferVertical)
 Applies the size constraints to the items. More...
 
void setItemBounds (juce::Rectangle< int > b)
 This property is dynamically calculated each time updateGeometry is called. More...
 
void setItemBounds (int x, int y, int w, int h)
 Convenience method to save creation of a rectangle struct. More...
 
juce::Rectangle< int > getItemBounds () const
 returns the calculated bounds of the item or layout. More...
 
juce::Rectangle< int > getPaddedItemBounds () const
 Returns the computed bounds reduced by the specified padding of the item. More...
 
void setBoundsAreFinal (bool final)
 set the flag that the bounds are adapted with size limits and shall not change This is computed on each updateGeometry and should not be set More...
 
bool getBoundsAreFinal () const
 This is computed on each updateGeometry and should not be set. More...
 
void setWrappedComponentID (const juce::String &name, bool setComp)
 Set the wrapped components componentID and the item's componentID property. More...
 
virtual void fixUpLayoutItems ()
 Chance for LayoutItems to fix properties that might have changed for saving. More...
 
virtual void realize (juce::ValueTree &node, juce::Component *owningComponent, Layout *layout)
 Hook to component or create an owned component. More...
 
void addListener (Listener *newListener)
 Registers a listener to receive events when this button's state changes. More...
 
void removeListener (Listener *listener)
 Removes a previously-registered button listener. More...
 
void callListenersCallback (juce::Rectangle< int > newBounds)
 Call the callbacks of LayoutItem::Listeners. More...
 
void callListenersCallback (float relativePosition, bool final)
 Call the callbacks of LayoutItem::Listeners when splitter moved. More...
 

Static Public Member Functions

static Orientation getOrientationFromName (juce::Identifier name)
 
static juce::Identifier getNameFromOrientation (LayoutItem::Orientation o)
 
static
LayoutItem::SharedLayoutData * 
getOrCreateData (juce::ValueTree &node, juce::UndoManager *undo=nullptr)
 Get or create a shared layout data blob for state node. More...
 
static LayoutItem makeSubLayout (juce::ValueTree &parent, Orientation orientation, int idx=-1, juce::UndoManager *undo=nullptr)
 create a sub layout under the node parent with the given orientation. More...
 
static LayoutItem makeChildComponent (juce::ValueTree &parent, juce::Component *component, bool owned=false, int idx=-1, juce::UndoManager *undo=nullptr)
 create a component container under the node parent. More...
 
static LayoutItem makeLabeledChildComponent (juce::ValueTree &parent, juce::Component *component, juce::String text, LayoutItem::Orientation o=LayoutItem::TopDown, bool owned=false, int idx=-1, juce::UndoManager *undo=nullptr)
 create a sub layout under the node parent with a child component and a label component. More...
 
static LayoutSplitter makeChildSplitter (juce::ValueTree &parent, float position, int idx=-1, juce::UndoManager *undo=nullptr)
 create a splitter under the node parent. More...
 
static LayoutItem makeChildSpacer (juce::ValueTree &parent, float stretchX=1.0, float stretchY=1.0, int idx=-1, juce::UndoManager *undo=nullptr)
 create a spacer under the node parent. More...
 
static void removeComponent (juce::ValueTree &parent, juce::Component *c, juce::UndoManager *undo=nullptr)
 Remove a component item from a specific layout level. More...
 
static juce::ValueTree getLayoutItem (juce::ValueTree &node, juce::Component *)
 Retrieve the LayoutItem for a component. More...
 
static juce::ValueTree getLayoutItem (juce::ValueTree &node, juce::String &componentID)
 Retrieve the LayoutItem for a component by componentID. More...
 
static void paintBounds (const juce::ValueTree &node, juce::Graphics &g)
 paint the bounds of the item and sub items for debugging More...
 
static int updateGeometry (juce::ValueTree &node, juce::Rectangle< int > bounds)
 Recompute the geometry of all components. More...
 
static int updateGeometry (juce::ValueTree &node, juce::Rectangle< int > bounds, int start, int end)
 Recompute the geometry of all components. More...
 
static void getStretch (const juce::ValueTree &node, float &w, float &h, int start=0, int end=-1)
 Cummulates all stretch factors inside the nested layout. More...
 
static void getSizeLimits (const juce::ValueTree &node, int &minW, int &maxW, int &minH, int &maxH, int start, int end)
 Compute size limits over all child nodes. More...
 

Public Attributes

juce::ValueTree state
 The layout item's node in the ValueTree. More...
 

Static Public Attributes

static const juce::Identifier itemTypeInvalid
 
static const juce::Identifier itemTypeComponent
 
static const juce::Identifier itemTypeBuilder
 
static const juce::Identifier itemTypeLabeledComponent
 
static const juce::Identifier itemTypeSplitter
 
static const juce::Identifier itemTypeSpacer
 
static const juce::Identifier itemTypeLine
 
static const juce::Identifier itemTypeSubLayout
 
static const juce::Identifier orientationUnknown
 
static const juce::Identifier orientationLeftToRight
 
static const juce::Identifier orientationTopDown
 
static const juce::Identifier orientationRightToLeft
 
static const juce::Identifier orientationBottomUp
 
static const juce::Identifier propStretchX
 
static const juce::Identifier propStretchY
 
static const juce::Identifier propMinWidth
 
static const juce::Identifier propMaxWidth
 
static const juce::Identifier propMinHeight
 
static const juce::Identifier propMaxHeight
 
static const juce::Identifier propAspectRatio
 
static const juce::Identifier propPaddingTop
 
static const juce::Identifier propPaddingLeft
 
static const juce::Identifier propPaddingRight
 
static const juce::Identifier propPaddingBottom
 
static const juce::Identifier propOrientation
 
static const juce::Identifier propLayoutBounds
 
static const juce::Identifier propOverlay
 
static const juce::Identifier propOverlayWidth
 
static const juce::Identifier propOverlayHeight
 
static const juce::Identifier propOverlayJustification
 
static const juce::Identifier propComponentID
 
static const juce::Identifier propComponentName
 
static const juce::Identifier propLabelText
 
static const juce::Identifier propLabelFontSize
 
static const juce::Identifier propLabelJustification
 
static const juce::Identifier propGroupName
 
static const juce::Identifier propGroupText
 
static const juce::Identifier propGroupJustification
 

Detailed Description

LayoutItems are used to store links to components to layout.

Also information like size hints and stretch factors are stored in the LayoutItems. To create a new node in the layout use the static makeChildComponent and similar methods. To interact with an item simply create one on the stack from it's state in the ValueTree, e.g.:

LayoutItem item (myLayout.state);
item.setOrientation (TopDown);
See Also
makeSubLayout, makeChildComponent, makeChildSplitter, makeChildSpacer

Member Enumeration Documentation

Enumerator
Invalid 
ComponentItem 
LabeledComponentItem 
SplitterItem 
SpacerItem 
LineItem 
SubLayout 
Enumerator
Unknown 
LeftToRight 
TopDown 
RightToLeft 
BottomUp 

Constructor & Destructor Documentation

LayoutItem::LayoutItem ( LayoutItem::Orientation  o)

Create an empty layout as root node.

Is created in the Layout constructor.

LayoutItem::LayoutItem ( juce::ValueTree  state)

Instanciate a LayoutItem from it's state.

To create a new item use the static methods

See Also
make
virtual LayoutItem::~LayoutItem ( )
virtual

Member Function Documentation

bool LayoutItem::isValid ( )

Return if the layout item has a valid type.

A component item not pointing to a valid component is also considered invalid

void LayoutItem::setOrientation ( const Orientation  ,
juce::UndoManager *  undo = nullptr 
)

Changes the orientation of the layout.

Orientation LayoutItem::getOrientation ( ) const

Returns the orientation including direction.

If you are only intersted if horizontal or vertical

See Also
isHorizontal and
isVertival
static Orientation LayoutItem::getOrientationFromName ( juce::Identifier  name)
static
static juce::Identifier LayoutItem::getNameFromOrientation ( LayoutItem::Orientation  o)
static
bool LayoutItem::isHorizontal ( ) const

Returns true if orientation is leftToRight or rightToLeft.

bool LayoutItem::isVertical ( ) const

Returns true if orientation is topDown or BottomUp.

int LayoutItem::isOverlay ( ) const

If overlay is set the item will be placed over an earlier defined item.

Possible values are

  • 0: normal (default) - no overlay
  • 1: previous item
  • 2: parent item
void LayoutItem::setIsOverlay ( const int  overlay)
float LayoutItem::getOverlayWidth ( ) const

Overlay width and overlay height are given in relative sizes to the referenced item.

See Also
isOverlay
void LayoutItem::setOverlayWidth ( float  w)

Overlay width and overlay height are given in relative sizes to the referenced item.

See Also
isOverlay
float LayoutItem::getOverlayHeight ( ) const

Overlay width and overlay height are given in relative sizes to the referenced item.

See Also
isOverlay
void LayoutItem::setOverlayHeight ( float  h)

Overlay width and overlay height are given in relative sizes to the referenced item.

See Also
isOverlay
int LayoutItem::getOverlayJustification ( ) const

overlayJustification defines, where the item is placed inside the referenced item

void LayoutItem::setOverlayJustification ( int  j)

overlayJustification defines, where the item is placed inside the referenced item

juce::Component* LayoutItem::getComponent ( ) const

Return the managed component.

Tries first the ownedComponent and then the wrappedComponent.

juce::String LayoutItem::getComponentID ( ) const

Return the componentID.

This is taken from the properties, not the actual component

bool LayoutItem::hasComponent ( ) const

Returns true, if a component is set and available as pointer.

juce::Component* LayoutItem::getWrappedComponent ( ) const

Return the wrapped component as pointer.

void LayoutItem::setComponent ( juce::Component *  ptr,
bool  owned = false,
juce::UndoManager *  undo = nullptr 
)

Replace the component pointer.

If owned is set to true, the component will be destroyed, when the item is destroyed or another component or nullptr is set. It is always only one pointer present, each call to setComponent removes the other variant.

static LayoutItem::SharedLayoutData* LayoutItem::getOrCreateData ( juce::ValueTree &  node,
juce::UndoManager *  undo = nullptr 
)
static

Get or create a shared layout data blob for state node.

See Also
SharedLayoutData
LayoutItem::SharedLayoutData* LayoutItem::getOrCreateData ( juce::UndoManager *  undo = nullptr)

Get or create a shared layout data blob.

See Also
SharedLayoutData
bool LayoutItem::isSpacerItem ( ) const

References itemTypeSpacer, and state.

bool LayoutItem::isComponentItem ( ) const

References itemTypeComponent, and state.

bool LayoutItem::isSplitterItem ( ) const

References itemTypeSplitter, and state.

bool LayoutItem::isSubLayout ( ) const

References itemTypeSubLayout, and state.

void LayoutItem::setLabelText ( const juce::String &  text,
juce::UndoManager *  undo = nullptr 
)

Set the text for an automatically recreated Label as property.

void LayoutItem::getStretch ( float &  w,
float &  h 
) const

Return the stretch value of an item.

void LayoutItem::setStretch ( float  w,
float  h,
juce::UndoManager *  undo = nullptr 
)

Used to set stretch factors for the wrapped component.

The space is distributed according the sum of stretch factors. For sub layouts, if you want to use the cummulated stretch of the child items, set this to a negative value. This is the default for new created sub layouts.

Referenced by setItemParameters().

void LayoutItem::setMinimumWidth ( const int  w,
juce::UndoManager *  undo = nullptr 
)

Set constraints to the items size.

In doubt the minimum size is used. Constraints work only in that direction the layout operates (horizontally/vertically). For a fixed size set the same value to minimum and maximum. To remove a constraint set it to -1.

Referenced by setFixedWidth(), and setItemParameters().

void LayoutItem::setMaximumWidth ( const int  w,
juce::UndoManager *  undo = nullptr 
)

Set the maximum width.

See Also
setMinimumWidth

Referenced by setFixedWidth(), and setItemParameters().

void LayoutItem::setMinimumHeight ( const int  h,
juce::UndoManager *  undo = nullptr 
)

Set the minimum height.

See Also
setMinimumWidth

Referenced by setFixedHeight(), and setItemParameters().

void LayoutItem::setMaximumHeight ( const int  h,
juce::UndoManager *  undo = nullptr 
)

Set the maximum height.

See Also
setMinimumWidth

Referenced by setFixedHeight(), and setItemParameters().

int LayoutItem::getMinimumWidth ( ) const

Returns the minimum width.

int LayoutItem::getMaximumWidth ( ) const

Returns the maximum width.

int LayoutItem::getMinimumHeight ( ) const

Returns the minimum height.

int LayoutItem::getMaximumHeight ( ) const

Returns the maximum height.

virtual void LayoutItem::getSizeLimits ( int &  minW,
int &  maxW,
int &  minH,
int &  maxH 
)
virtual

Return the size limits of the item.

You can use this method to cummulate the limits. if you don't want that, it is your responsibility to set the parameters to no limit (i.e. a negative value) before calling this method

void LayoutItem::setPaddingTop ( const int  p,
juce::UndoManager *  undo = nullptr 
)

Set a padding value for the wrapped component or item to it's calculated top bounds.

Referenced by setItemParameters(), and setPadding().

void LayoutItem::setPaddingLeft ( const int  p,
juce::UndoManager *  undo = nullptr 
)

Set a padding value for the wrapped component or item to it's calculated left bounds.

Referenced by setItemParameters(), and setPadding().

void LayoutItem::setPaddingRight ( const int  p,
juce::UndoManager *  undo = nullptr 
)

Set a padding value for the wrapped component or item to it's calculated right bounds.

Referenced by setItemParameters(), and setPadding().

void LayoutItem::setPaddingBottom ( const int  p,
juce::UndoManager *  undo = nullptr 
)

Set a padding value for the wrapped component or item to it's calculated bottom bounds.

Referenced by setItemParameters(), and setPadding().

void LayoutItem::setPadding ( const int  p,
juce::UndoManager *  undo = nullptr 
)

Set one value to all bounaries.

References setPaddingBottom(), setPaddingLeft(), setPaddingRight(), and setPaddingTop().

int LayoutItem::getPaddingTop ( ) const

Returns the padding value for the wrapped component or item to it's calculated top bounds.

int LayoutItem::getPaddingLeft ( ) const

Returns the padding value for the wrapped component or item to it's calculated left bounds.

int LayoutItem::getPaddingRight ( ) const

Returns the padding value for the wrapped component or item to it's calculated right bounds.

int LayoutItem::getPaddingBottom ( ) const

Returns the padding value for the wrapped component or item to it's calculated bottom bounds.

void LayoutItem::setFixedWidth ( const int  w,
juce::UndoManager *  undo = nullptr 
)

Sets fixed width as minimum width = maximum width.

References setMaximumWidth(), and setMinimumWidth().

Referenced by setFixedSize().

void LayoutItem::setFixedHeight ( const int  h,
juce::UndoManager *  undo = nullptr 
)

Sets fixed height as minimum height = maximum height.

References setMaximumHeight(), and setMinimumHeight().

Referenced by setFixedSize().

void LayoutItem::setFixedSize ( const int  w,
const int  h,
juce::UndoManager *  undo = nullptr 
)

Convenience method to set fixed width and height in one call.

References setFixedHeight(), and setFixedWidth().

void LayoutItem::setAspectRatio ( const float  ratio,
juce::UndoManager *  undo = nullptr 
)

Set an aspect ratio to constrain the bounds.

Referenced by setItemParameters().

float LayoutItem::getAspectRatio ( ) const

Set an aspect ratio to constrain the bounds.

void LayoutItem::setItemParameters ( float  inStretchX,
float  inStretchY,
int  inMinWidth,
int  inMinHeight,
int  inMaxWidth,
int  inMaxHeight,
int  inPaddingTop,
int  inPaddingLeft,
int  inPaddingRight,
int  inPaddingBottom,
float  inAspectRatio,
juce::UndoManager *  undo = nullptr 
)
static LayoutItem LayoutItem::makeSubLayout ( juce::ValueTree &  parent,
Orientation  orientation,
int  idx = -1,
juce::UndoManager *  undo = nullptr 
)
static

create a sub layout under the node parent with the given orientation.

Parameters
parentthe node in the hierarchical layout structure
orientationof the child nodes
idxthe position in the sequence of already present nodes. If -1 the item is appended at the end
undothe UndoManager for the ValueTree, so changes can be rolled back
static LayoutItem LayoutItem::makeChildComponent ( juce::ValueTree &  parent,
juce::Component *  component,
bool  owned = false,
int  idx = -1,
juce::UndoManager *  undo = nullptr 
)
static

create a component container under the node parent.

Parameters
parentthe node in the hierarchical layout structure
componentto be sized and moved by the layout
ownedif set to true the layout takes ownership of the component and will destroy it when the layout or this specific node is destroyed
idxthe position in the sequence of already present nodes. If -1 the item is appended at the end
undothe UndoManager for the ValueTree, so changes can be rolled back
static LayoutItem LayoutItem::makeLabeledChildComponent ( juce::ValueTree &  parent,
juce::Component *  component,
juce::String  text,
LayoutItem::Orientation  o = LayoutItem::TopDown,
bool  owned = false,
int  idx = -1,
juce::UndoManager *  undo = nullptr 
)
static

create a sub layout under the node parent with a child component and a label component.

Parameters
parentthe node in the hierarchical layout structure
componentto be sized and moved by the layout
textto be displayed beneath the component
ois the orientation to define, on what side to put the text
ownedif set to true the layout takes ownership of the component and will destroy it when the layout or this specific node is destroyed
idxthe position in the sequence of already present nodes. If -1 the item is appended at the end
undothe UndoManager for the ValueTree, so changes can be rolled back
static LayoutSplitter LayoutItem::makeChildSplitter ( juce::ValueTree &  parent,
float  position,
int  idx = -1,
juce::UndoManager *  undo = nullptr 
)
static

create a splitter under the node parent.

The splitter has an owned component to be dragged around.

Parameters
parentthe node in the hierarchical layout structure
positionis a relative position where the splitter is placed initially
idxthe position in the sequence of already present nodes. If -1 the item is appended at the end
undothe UndoManager for the ValueTree, so changes can be rolled back
static LayoutItem LayoutItem::makeChildSpacer ( juce::ValueTree &  parent,
float  stretchX = 1.0,
float  stretchY = 1.0,
int  idx = -1,
juce::UndoManager *  undo = nullptr 
)
static

create a spacer under the node parent.

It simply leaves out space.

Parameters
parentthe node in the hierarchical layout structure
stretchXis a multiplier how many space the spacer wants to reserve in horizontal direction
stretchYis a multiplier how many space the spacer wants to reserve in vertical direction
idxthe position in the sequence of already present nodes. If -1 the item is appended at the end
undothe UndoManager for the ValueTree, so changes can be rolled back
static void LayoutItem::removeComponent ( juce::ValueTree &  parent,
juce::Component *  c,
juce::UndoManager *  undo = nullptr 
)
static

Remove a component item from a specific layout level.

static juce::ValueTree LayoutItem::getLayoutItem ( juce::ValueTree &  node,
juce::Component *   
)
static

Retrieve the LayoutItem for a component.

If the Component is not found in the Layout, an invalid ValueTree node is returned.

static juce::ValueTree LayoutItem::getLayoutItem ( juce::ValueTree &  node,
juce::String &  componentID 
)
static

Retrieve the LayoutItem for a component by componentID.

If the Component is not found in the Layout, an invalid ValueTree node is returned.

void LayoutItem::constrainBounds ( juce::Rectangle< int > &  bounds,
bool &  changedWidth,
bool &  changedHeight,
bool  preferVertical 
)

Applies the size constraints to the items.

set preferVertical to true to adapt height of the item or false to adapt the width.

void LayoutItem::setItemBounds ( juce::Rectangle< int >  b)

This property is dynamically calculated each time updateGeometry is called.

Setting this property on the root node lets you place the layout on a fixed position in the owningComponent. If it is set empty (i.e. size equals 0, 0) which is the default, the local bounds of the owningComponent are used as available space.

void LayoutItem::setItemBounds ( int  x,
int  y,
int  w,
int  h 
)

Convenience method to save creation of a rectangle struct.

See Also
setItemBounds
juce::Rectangle<int> LayoutItem::getItemBounds ( ) const

returns the calculated bounds of the item or layout.

Calling this on the root node returns only a valid rectangle, if it was set as fixed bounds.

juce::Rectangle<int> LayoutItem::getPaddedItemBounds ( ) const

Returns the computed bounds reduced by the specified padding of the item.

void LayoutItem::setBoundsAreFinal ( bool  final)

set the flag that the bounds are adapted with size limits and shall not change This is computed on each updateGeometry and should not be set

bool LayoutItem::getBoundsAreFinal ( ) const

This is computed on each updateGeometry and should not be set.

It means that the bounds are constrained and the update algorithm shall not change the item's size.

void LayoutItem::setWrappedComponentID ( const juce::String &  name,
bool  setComp 
)

Set the wrapped components componentID and the item's componentID property.

static void LayoutItem::paintBounds ( const juce::ValueTree &  node,
juce::Graphics &  g 
)
static

paint the bounds of the item and sub items for debugging

virtual void LayoutItem::fixUpLayoutItems ( )
virtual

Chance for LayoutItems to fix properties that might have changed for saving.

virtual void LayoutItem::realize ( juce::ValueTree &  node,
juce::Component *  owningComponent,
Layout layout 
)
virtual

Hook to component or create an owned component.

static int LayoutItem::updateGeometry ( juce::ValueTree &  node,
juce::Rectangle< int >  bounds 
)
static

Recompute the geometry of all components.

Recoursively recomputes all sub layouts.

static int LayoutItem::updateGeometry ( juce::ValueTree &  node,
juce::Rectangle< int >  bounds,
int  start,
int  end 
)
static

Recompute the geometry of all components.

Recoursively recomputes all sub layouts.

static void LayoutItem::getStretch ( const juce::ValueTree &  node,
float &  w,
float &  h,
int  start = 0,
int  end = -1 
)
static

Cummulates all stretch factors inside the nested layout.

static void LayoutItem::getSizeLimits ( const juce::ValueTree &  node,
int &  minW,
int &  maxW,
int &  minH,
int &  maxH,
int  start,
int  end 
)
static

Compute size limits over all child nodes.

void LayoutItem::addListener ( Listener newListener)

Registers a listener to receive events when this button's state changes.

If the listener is already registered, this will not register it again.

See Also
removeListener
void LayoutItem::removeListener ( Listener listener)

Removes a previously-registered button listener.

See Also
addListener
void LayoutItem::callListenersCallback ( juce::Rectangle< int >  newBounds)

Call the callbacks of LayoutItem::Listeners.

void LayoutItem::callListenersCallback ( float  relativePosition,
bool  final 
)

Call the callbacks of LayoutItem::Listeners when splitter moved.

Member Data Documentation

juce::ValueTree LayoutItem::state

The layout item's node in the ValueTree.

You can use this to e.g. specify a position in the graph where to hang child nodes into. To manipulate rather use the methods implemented in LayoutItem

Referenced by isComponentItem(), isSpacerItem(), isSplitterItem(), and isSubLayout().

const juce::Identifier LayoutItem::itemTypeInvalid
static
const juce::Identifier LayoutItem::itemTypeComponent
static

Referenced by isComponentItem().

const juce::Identifier LayoutItem::itemTypeBuilder
static
const juce::Identifier LayoutItem::itemTypeLabeledComponent
static
const juce::Identifier LayoutItem::itemTypeSplitter
static

Referenced by isSplitterItem().

const juce::Identifier LayoutItem::itemTypeSpacer
static

Referenced by isSpacerItem().

const juce::Identifier LayoutItem::itemTypeLine
static
const juce::Identifier LayoutItem::itemTypeSubLayout
static

Referenced by isSubLayout().

const juce::Identifier LayoutItem::orientationUnknown
static
const juce::Identifier LayoutItem::orientationLeftToRight
static
const juce::Identifier LayoutItem::orientationTopDown
static
const juce::Identifier LayoutItem::orientationRightToLeft
static
const juce::Identifier LayoutItem::orientationBottomUp
static
const juce::Identifier LayoutItem::propStretchX
static
const juce::Identifier LayoutItem::propStretchY
static
const juce::Identifier LayoutItem::propMinWidth
static
const juce::Identifier LayoutItem::propMaxWidth
static
const juce::Identifier LayoutItem::propMinHeight
static
const juce::Identifier LayoutItem::propMaxHeight
static
const juce::Identifier LayoutItem::propAspectRatio
static
const juce::Identifier LayoutItem::propPaddingTop
static
const juce::Identifier LayoutItem::propPaddingLeft
static
const juce::Identifier LayoutItem::propPaddingRight
static
const juce::Identifier LayoutItem::propPaddingBottom
static
const juce::Identifier LayoutItem::propOrientation
static
const juce::Identifier LayoutItem::propLayoutBounds
static
const juce::Identifier LayoutItem::propOverlay
static
const juce::Identifier LayoutItem::propOverlayWidth
static
const juce::Identifier LayoutItem::propOverlayHeight
static
const juce::Identifier LayoutItem::propOverlayJustification
static
const juce::Identifier LayoutItem::propComponentID
static
const juce::Identifier LayoutItem::propComponentName
static
const juce::Identifier LayoutItem::propLabelText
static
const juce::Identifier LayoutItem::propLabelFontSize
static
const juce::Identifier LayoutItem::propLabelJustification
static
const juce::Identifier LayoutItem::propGroupName
static
const juce::Identifier LayoutItem::propGroupText
static
const juce::Identifier LayoutItem::propGroupJustification
static

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