#include <CustomLayout.h>
|
| std::function< Rectangle< int >(String componentType, Rectangle< int > currentBounds)> | getAutoLayoutBoundsFromType |
| | Used to look up what bounds should be used for a given component type when using auto layout. Returns default bounds if nothing is set for that type.
|
| |
| std::function< void()> | treeRedirected |
| |
CustomLayout is a component which can create resizable "slots" into which other components may be added as children. These slots and their bounds are saved to a ValueTree, whose reference may be overwritten using setLayoutTree(), to use a tree outside of this class for custom state recall, etc.
◆ CustomLayout()
| krotos::CustomLayout::CustomLayout |
( |
| ) |
|
Create a CustomLayout component. Add this to your parent just like any other component.
◆ ~CustomLayout()
| krotos::CustomLayout::~CustomLayout |
( |
| ) |
|
◆ addComponent() [1/2]
Add a component to the custom layout.
This will add the given component as a child to a resizable component within the CustomLayout.
- Parameters
-
| component | The component to add to the CustomLayout |
| bounds | The starting bounds of the component. |
◆ addComponent() [2/2]
| void krotos::CustomLayout::addComponent |
( |
Component & | component, |
|
|
ValueTree | slot ) |
Add a component from a given slot tree.
This will search for an existing slot that matches the given tree and add the component to that, or create a new one if no slot is found.
A slot tree is created when a new slot is added to the CustomLayout. The most likely circumstance where a singular slot tree may exist outside of the custom layout would be if the layoutTree reference has been re-assigned, for instance, to hand over layout state management to external control.
- See also
- setLayoutTree
- Parameters
-
| component | The component to add to the CustomLayout |
| slot | The slot tree for that component. A slot tree is created when a new component is added to the layout. |
◆ addSlot()
| void krotos::CustomLayout::addSlot |
( |
const String & | name, |
|
|
const Rectangle< int > & | bounds ) |
|
private |
Creates a new slot with the given name and bounds. The slot is created as a ValueTree node, and added to the layoutTree. Then, layoutTree listener picks up this change, and creates a resizable slot to which child components may be added.
- See also
- createAndAddResizableComponent
◆ componentMovedOrResized()
| void krotos::CustomLayout::componentMovedOrResized |
( |
Component & | component, |
|
|
bool | wasMoved, |
|
|
bool | wasResized ) |
|
overrideprivate |
Save new bounds to the layoutTree a component is moved or resized.
◆ configureAutoLayout()
| void krotos::CustomLayout::configureAutoLayout |
( |
FlexBox | flexboxSettings, |
|
|
FlexItem::Margin | margin ) |
◆ createAndAddResizableComponent()
| Component * krotos::CustomLayout::createAndAddResizableComponent |
( |
String | name, |
|
|
Rectangle< int > | bounds ) |
|
private |
Internal function to create and add a resizable component to the CustomLayout with a given name and bounds. Returns a pointer to the object, whose lifetime is managed by an internal OwnedArray.
◆ getLayoutTree()
| ValueTree & krotos::CustomLayout::getLayoutTree |
( |
| ) |
|
Returns a reference to the active layoutTree.
◆ isAutoLayoutActive()
| bool krotos::CustomLayout::isAutoLayoutActive |
( |
| ) |
|
|
inline |
◆ isEditModeActive()
| bool krotos::CustomLayout::isEditModeActive |
( |
| ) |
|
|
inline |
◆ paint()
| void krotos::CustomLayout::paint |
( |
Graphics & | | ) |
|
|
inlineoverride |
◆ removeComponent()
| void krotos::CustomLayout::removeComponent |
( |
int | index | ) |
|
Remove a component from the CustomLayout. If the index is out-of-range, nothing will be changed Components may also be removed by removing their slot from the valuetree.
◆ resetLayoutTree()
| void krotos::CustomLayout::resetLayoutTree |
( |
const ValueTree & | layoutTree | ) |
|
Clears the current layout tree, then changes the refrence of the layout tree to the new incoming tree. Use this if you wish to replace the layout state with one saved externally from this class. i.e. Loading an externally saved layout tree from state.
- Parameters
-
| layoutTree | A layout tree. This should only be a layout tree already created and saved by the CustomLayout. |
◆ resized()
| void krotos::CustomLayout::resized |
( |
| ) |
|
|
override |
◆ saveLayout()
| void krotos::CustomLayout::saveLayout |
( |
| ) |
|
|
private |
Force save the current layout of components to the valuetree by iterating through all components and writing their bounds to the layoutTree.
◆ setAutoLayout()
| void krotos::CustomLayout::setAutoLayout |
( |
bool | isEnabled | ) |
|
|
inline |
Use this to enable / disable automatic laying out of slots using FlexBox. FlexBox settings must be configured via the configureAutoLayout function except Flex Order which is always based on height for now.
- See also
- configureAutoLayout, isAutoLayoutActive
◆ setEditModeActive()
| void krotos::CustomLayout::setEditModeActive |
( |
bool | isEditModeActive | ) |
|
Sets visbility of resizable borders on layout slots.
◆ setLayoutTree()
| void krotos::CustomLayout::setLayoutTree |
( |
const ValueTree & | layoutTree | ) |
|
|
inline |
Change the reference of the layoutTree. Use this if you wish to manage the CustomLayout state exernally from this class.
- Parameters
-
| layoutTree | A layout tree. This should only be a layout tree already created and saved by the CustomLayout. |
◆ valueTreeChildAdded()
| void krotos::CustomLayout::valueTreeChildAdded |
( |
ValueTree & | parentTree, |
|
|
ValueTree & | childWhichHasBeenAdded ) |
|
overrideprivate |
◆ valueTreeChildRemoved()
| void krotos::CustomLayout::valueTreeChildRemoved |
( |
ValueTree & | parentTree, |
|
|
ValueTree & | childWhichHasBeenRemoved, |
|
|
int | indexFromWhichChildWasRemoved ) |
|
overrideprivate |
◆ valueTreePropertyChanged()
| void krotos::CustomLayout::valueTreePropertyChanged |
( |
ValueTree & | treeWhosePropertyHasChanged, |
|
|
const Identifier & | property ) |
|
overrideprivate |
◆ valueTreeRedirected()
| void krotos::CustomLayout::valueTreeRedirected |
( |
ValueTree & | treeWhichHasBeenChanged | ) |
|
|
private |
◆ DefaultSize
| const Rectangle< int > krotos::CustomLayout::DefaultSize = Rectangle<int>{50, 50, 100, 100} |
|
static |
◆ FileExtension
| const String krotos::CustomLayout::FileExtension = "clf" |
|
static |
◆ getAutoLayoutBoundsFromType
| std::function<Rectangle<int>(String componentType, Rectangle<int> currentBounds)> krotos::CustomLayout::getAutoLayoutBoundsFromType |
Used to look up what bounds should be used for a given component type when using auto layout. Returns default bounds if nothing is set for that type.
◆ m_autoLayout
| bool krotos::CustomLayout::m_autoLayout {false} |
|
private |
◆ m_components
| OwnedArray<Component> krotos::CustomLayout::m_components |
|
private |
◆ m_editable
| bool krotos::CustomLayout::m_editable {false} |
|
private |
◆ m_flexMargin
| FlexItem::Margin krotos::CustomLayout::m_flexMargin {0.0f} |
|
private |
◆ m_flexSettings
| FlexBox krotos::CustomLayout::m_flexSettings |
|
private |
◆ m_layoutTree
| ValueTree krotos::CustomLayout::m_layoutTree |
|
private |
◆ treeRedirected
| std::function<void()> krotos::CustomLayout::treeRedirected |
Assign this to do something after the layout tree has been redirected. For instance, after it has been made a child of a different ValueTree.
The documentation for this class was generated from the following files: