Envision
A visual programming IDE for object-oriented languages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
Visualization::SequentialLayoutFormElement Class Reference

The sequential layout element can display a list of items either horizontally or vertically. More...

Inheritance diagram for Visualization::SequentialLayoutFormElement:
Visualization::SuperLayoutElement< SequentialLayoutFormElement, LayoutFormElement > Visualization::SuperFormElement< NewFormElement, BaseFormElement >

Classes

struct  ItemData
 

Public Types

using IntGetterFunction = std::function< int(Item *item)>
 
using ListNodeGetterFunction = std::function< Model::List *(Item *item)>
 
using ListOfItemsGetterFunction = std::function< QList< Item * >(Item *item)>
 
using ListOfNodesGetterFunction = std::function< QList< Model::Node * >(Item *item)>
 
using StretchableWhenEmptyGetterFunction = std::function< bool(const Item *item)>
 

Public Member Functions

 SequentialLayoutFormElement ()=default
 
 SequentialLayoutFormElement (const SequentialLayoutFormElement &other)
 
virtual ~SequentialLayoutFormElement ()
 
virtual SequentialLayoutFormElementclone () const override
 
virtual void computeSize (Item *item, int availableWidth, int availableHeight) override
 
virtual void destroyChildItems (Item *item, QList< const Item *const DeclarativeItemBase::* > handledChildren) override
 
bool elementOrChildHasFocus (Item *item) const override
 
int focusedElementIndex (const Item *item) const
 Returns the index of the focused element for the specified item. More...
 
bool isEmpty (const Item *item) const override
 
template<typename T >
T * itemAt (const Item *item, int itemIndex) const
 Returns the item at itemIndex for this item. More...
 
int length (const Item *item) const
 Returns the length of the displayed list of items for this item. More...
 
SequentialLayoutFormElementoperator= (const SequentialLayoutFormElement &)=delete
 
virtual QList< ItemRegionregions (DeclarativeItemBase *item, int parentX, int parentY) override
 
SequentialLayoutFormElementsetAlignment (LayoutStyle::Alignment alignment)
 Sets the alignment. More...
 
SequentialLayoutFormElementsetForward (bool forward)
 Defines if this layout should be displayed forwards (true) or backwards (false). More...
 
SequentialLayoutFormElementsetHorizontal ()
 Sets this sequential layout to be horizontal, also sets the alignment to the default (bottom) More...
 
virtual void setItemPositions (Item *item, int parentX, int parentY) override
 
SequentialLayoutFormElementsetListNode (ListNodeGetterFunction listNodeGetter)
 Sets the getter (listNodeGetter) for getting a node of type List, from which the list of items to render in the sequential layout can be computed. More...
 
SequentialLayoutFormElementsetListOfItems (ListOfItemsGetterFunction itemListGetter)
 Sets the getter (itemListGetter) for getting a list of items to render in the sequential layout. More...
 
SequentialLayoutFormElementsetListOfNodes (ListOfNodesGetterFunction nodeListGetter)
 Sets the getter (nodeListGetter) for getting a list of nodes, from which the list of items to render in the sequential layout can be computed. More...
 
SequentialLayoutFormElementsetMinHeightGetter (IntGetterFunction minHeightGetter)
 Sets the minimum height to minHeight. More...
 
SequentialLayoutFormElementsetMinWidthGetter (IntGetterFunction minWidthGetter)
 Sets the minimum width to minWidth. More...
 
SequentialLayoutFormElementsetOrientation (Qt::Orientation orientation)
 Sets the orientation of this sequential layout. More...
 
SequentialLayoutFormElementsetSpaceBetweenElements (int space)
 Sets what the space between two elements in the sequential layout should be. More...
 
SequentialLayoutFormElementsetSpaceBetweenElements (std::function< int(Item *item)> spaceBetweenElementsGetter)
 Sets a getter (spaceBetweenElementsGetter) for getting the appropriate space between two elements dynamically while rendering. More...
 
SequentialLayoutFormElementsetStretchableWhenEmpty (StretchableWhenEmptyGetterFunction stretchableWhenEmpty)
 Sets whether this form should be stretchable if it has no elements. More...
 
SequentialLayoutFormElementsetVertical ()
 Sets this sequential layout to be vertical, also sets the alignment to the default (left) More...
 
virtual bool sizeDependsOnParent (const Item *item) const override
 
virtual void synchronizeWithItem (Item *item) override
 
- Public Member Functions inherited from Visualization::SuperLayoutElement< SequentialLayoutFormElement, LayoutFormElement >
SequentialLayoutFormElementsetHasCursorWhenEmpty (std::function< bool(Item *item)> hasCursorWhenEmptyGetter)
 Sets a getter (cursorWhenEmptyGetter) for checking if the element should have cursors when empty dynamically while rendering. More...
 
SequentialLayoutFormElementsetNoBoundaryCursors (std::function< bool(Item *item)> noBoundaryCursorsGetter)
 Sets a getter (noBoundaryCursorsGetter) for checking if the element should not have any boundary cursors dynamically while rendering. More...
 
SequentialLayoutFormElementsetNoInnerCursors (std::function< bool(Item *item)> noInnerCursorsGetter)
 Sets a getter (noInnerCursorsGetter) for checking if the element should not have any inner cursors dynamically while rendering. More...
 
SequentialLayoutFormElementsetNotLocationEquivalentCursors (std::function< bool(Item *item)> notLocationEquivalentCursorsGetter)
 Sets a getter (notLocationEquivalentGetter) for checking if the element's cursors are not location equivalent dynamically while rendering. More...
 
- Public Member Functions inherited from Visualization::SuperFormElement< NewFormElement, BaseFormElement >
NewFormElement * setBottomMargin (int bottom)
 Sets the bottom margin of this form element. More...
 
NewFormElement * setLeftMargin (int left)
 Sets the left margin of this form element. More...
 
NewFormElement * setMargins (int left, int top, int right, int bottom)
 Sets the left, top, right and bottom margins to the respective values. More...
 
NewFormElement * setMargins (int margin)
 Sets all the margins of this form element to the value specified as margin. More...
 
NewFormElement * setRightMargin (int right)
 Sets the right margin of this form element. More...
 
NewFormElement * setTopMargin (int top)
 Sets the top margin of this form element. More...
 

Private Member Functions

ItemDatadataForItem (const Item *item) const
 Returns the cached item list for this item. More...
 
int spaceBetweenElements (Item *item)
 Computes the space between elements from the getter and the previously set space. More...
 
void synchronizeWithItems (Item *item, const QList< Item * > &items)
 Synchronizes the old list of items for this item with the new list of items. More...
 
void synchronizeWithNodes (Item *item, const QList< Model::Node * > &nodes)
 Synchronizes the old list of items for this item with the new list of nodes. More...
 

Private Attributes

LayoutStyle::Alignment alignment_ {LayoutStyle::Alignment::Bottom}
 
int defaultSpaceBetweenElements_ {0}
 
bool forward_ {true}
 
QHash< const Item *, ItemData * > itemData_ {}
 
ListOfItemsGetterFunction itemListGetter_ {}
 
ListNodeGetterFunction listNodeGetter_ {}
 
IntGetterFunction minHeightGetter_ {}
 
IntGetterFunction minWidthGetter_ {}
 
ListOfNodesGetterFunction nodeListGetter_ {}
 
Qt::Orientation orientation_ {Qt::Horizontal}
 
std::function< int(Item *item)> spaceBetweenElementsGetter_ {}
 
StretchableWhenEmptyGetterFunction stretchableWhenEmpty_ {}
 

Detailed Description

The sequential layout element can display a list of items either horizontally or vertically.

It can directly be given a getter for a list of items, or alternatively a list of nodes or a node of type Model::List, out of which the list of items then can be constructed by rendering each node with its default visualization.

Member Typedef Documentation

◆ IntGetterFunction

◆ ListNodeGetterFunction

◆ ListOfItemsGetterFunction

◆ ListOfNodesGetterFunction

◆ StretchableWhenEmptyGetterFunction

Constructor & Destructor Documentation

◆ SequentialLayoutFormElement() [1/2]

Visualization::SequentialLayoutFormElement::SequentialLayoutFormElement ( )
default

◆ SequentialLayoutFormElement() [2/2]

Visualization::SequentialLayoutFormElement::SequentialLayoutFormElement ( const SequentialLayoutFormElement other)

◆ ~SequentialLayoutFormElement()

Visualization::SequentialLayoutFormElement::~SequentialLayoutFormElement ( )
virtual

Member Function Documentation

◆ clone()

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::clone ( ) const
overridevirtual

◆ computeSize()

void Visualization::SequentialLayoutFormElement::computeSize ( Item item,
int  availableWidth,
int  availableHeight 
)
overridevirtual

◆ dataForItem()

SequentialLayoutFormElement::ItemData & Visualization::SequentialLayoutFormElement::dataForItem ( const Item item) const
private

Returns the cached item list for this item.

◆ destroyChildItems()

void Visualization::SequentialLayoutFormElement::destroyChildItems ( Item item,
QList< const Item *const DeclarativeItemBase::* >  handledChildren 
)
overridevirtual

◆ elementOrChildHasFocus()

bool Visualization::SequentialLayoutFormElement::elementOrChildHasFocus ( Item item) const
override

◆ focusedElementIndex()

int Visualization::SequentialLayoutFormElement::focusedElementIndex ( const Item item) const

Returns the index of the focused element for the specified item.

If no element is focused, returns -1. This method is very similar to the focsedElementIndex of SequentialLayout (layouts folder).

◆ isEmpty()

bool Visualization::SequentialLayoutFormElement::isEmpty ( const Item item) const
override

◆ itemAt()

template<typename T >
T * Visualization::SequentialLayoutFormElement::itemAt ( const Item item,
int  itemIndex 
) const

Returns the item at itemIndex for this item.

◆ length()

int Visualization::SequentialLayoutFormElement::length ( const Item item) const

Returns the length of the displayed list of items for this item.

◆ operator=()

SequentialLayoutFormElement& Visualization::SequentialLayoutFormElement::operator= ( const SequentialLayoutFormElement )
delete

◆ regions()

QList< ItemRegion > Visualization::SequentialLayoutFormElement::regions ( DeclarativeItemBase item,
int  parentX,
int  parentY 
)
overridevirtual

◆ setAlignment()

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setAlignment ( LayoutStyle::Alignment  alignment)
inline

Sets the alignment.

If it is not compatible with the layout's orientation, it will fall back to the default.

◆ setForward()

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setForward ( bool  forward)
inline

Defines if this layout should be displayed forwards (true) or backwards (false).

Example: forwards (default): |0|1|2|3| backwards: |3|2|1|0|

◆ setHorizontal()

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setHorizontal ( )
inline

Sets this sequential layout to be horizontal, also sets the alignment to the default (bottom)

◆ setItemPositions()

void Visualization::SequentialLayoutFormElement::setItemPositions ( Item item,
int  parentX,
int  parentY 
)
overridevirtual

◆ setListNode()

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setListNode ( ListNodeGetterFunction  listNodeGetter)
inline

Sets the getter (listNodeGetter) for getting a node of type List, from which the list of items to render in the sequential layout can be computed.

The items will be rendered with their default style.

◆ setListOfItems()

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setListOfItems ( ListOfItemsGetterFunction  itemListGetter)
inline

Sets the getter (itemListGetter) for getting a list of items to render in the sequential layout.

◆ setListOfNodes()

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setListOfNodes ( ListOfNodesGetterFunction  nodeListGetter)
inline

Sets the getter (nodeListGetter) for getting a list of nodes, from which the list of items to render in the sequential layout can be computed.

The items will be rendered with their default style.

◆ setMinHeightGetter()

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setMinHeightGetter ( IntGetterFunction  minHeightGetter)
inline

Sets the minimum height to minHeight.

◆ setMinWidthGetter()

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setMinWidthGetter ( IntGetterFunction  minWidthGetter)
inline

Sets the minimum width to minWidth.

◆ setOrientation()

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setOrientation ( Qt::Orientation  orientation)
inline

Sets the orientation of this sequential layout.

Also sets the alignment to the default (bottom for horizontal, left for vertical).

◆ setSpaceBetweenElements() [1/2]

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setSpaceBetweenElements ( int  space)
inline

Sets what the space between two elements in the sequential layout should be.

◆ setSpaceBetweenElements() [2/2]

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setSpaceBetweenElements ( std::function< int(Item *item)>  spaceBetweenElementsGetter)
inline

Sets a getter (spaceBetweenElementsGetter) for getting the appropriate space between two elements dynamically while rendering.

If this getter is set, anything set with the setSpaceBetweenElements(int) will be ignored.

◆ setStretchableWhenEmpty()

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setStretchableWhenEmpty ( StretchableWhenEmptyGetterFunction  stretchableWhenEmpty)
inline

Sets whether this form should be stretchable if it has no elements.

◆ setVertical()

SequentialLayoutFormElement * Visualization::SequentialLayoutFormElement::setVertical ( )
inline

Sets this sequential layout to be vertical, also sets the alignment to the default (left)

◆ sizeDependsOnParent()

bool Visualization::SequentialLayoutFormElement::sizeDependsOnParent ( const Item item) const
overridevirtual

◆ spaceBetweenElements()

int Visualization::SequentialLayoutFormElement::spaceBetweenElements ( Item item)
private

Computes the space between elements from the getter and the previously set space.

◆ synchronizeWithItem()

void Visualization::SequentialLayoutFormElement::synchronizeWithItem ( Item item)
overridevirtual

◆ synchronizeWithItems()

void Visualization::SequentialLayoutFormElement::synchronizeWithItems ( Item item,
const QList< Item * > &  items 
)
private

Synchronizes the old list of items for this item with the new list of items.

◆ synchronizeWithNodes()

void Visualization::SequentialLayoutFormElement::synchronizeWithNodes ( Item item,
const QList< Model::Node * > &  nodes 
)
private

Synchronizes the old list of items for this item with the new list of nodes.

Member Data Documentation

◆ alignment_

LayoutStyle::Alignment Visualization::SequentialLayoutFormElement::alignment_ {LayoutStyle::Alignment::Bottom}
private

◆ defaultSpaceBetweenElements_

int Visualization::SequentialLayoutFormElement::defaultSpaceBetweenElements_ {0}
private

◆ forward_

bool Visualization::SequentialLayoutFormElement::forward_ {true}
private

◆ itemData_

QHash<const Item*, ItemData*> Visualization::SequentialLayoutFormElement::itemData_ {}
mutableprivate

◆ itemListGetter_

ListOfItemsGetterFunction Visualization::SequentialLayoutFormElement::itemListGetter_ {}
private

◆ listNodeGetter_

ListNodeGetterFunction Visualization::SequentialLayoutFormElement::listNodeGetter_ {}
private

◆ minHeightGetter_

IntGetterFunction Visualization::SequentialLayoutFormElement::minHeightGetter_ {}
private

◆ minWidthGetter_

IntGetterFunction Visualization::SequentialLayoutFormElement::minWidthGetter_ {}
private

◆ nodeListGetter_

ListOfNodesGetterFunction Visualization::SequentialLayoutFormElement::nodeListGetter_ {}
private

◆ orientation_

Qt::Orientation Visualization::SequentialLayoutFormElement::orientation_ {Qt::Horizontal}
private

◆ spaceBetweenElementsGetter_

std::function<int(Item* item)> Visualization::SequentialLayoutFormElement::spaceBetweenElementsGetter_ {}
private

◆ stretchableWhenEmpty_

StretchableWhenEmptyGetterFunction Visualization::SequentialLayoutFormElement::stretchableWhenEmpty_ {}
private