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

This class allows the arrangement of elements in a grid. More...

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

Public Member Functions

 GridLayoutFormElement ()
 
 GridLayoutFormElement (const GridLayoutFormElement &other)
 
virtual ~GridLayoutFormElement ()
 
virtual GridLayoutFormElementclone () const override
 
virtual void computeSize (Item *item, int availableWidth, int availableHeight) override
 Sets if the element has a cursor if it is empty to cursorWhenEmpty. More...
 
QPoint focusedElement2DIndex (Item *item) const
 Returns the 2D index of the focused element for the specified item. More...
 
int focusedElementIndex (Item *item) const
 Returns the index of the focused element for the specified item. More...
 
const Visualization::ItemitemAt (DeclarativeItemBase *item, int index) const
 Asserts that this is a linear grid and returns the item at index. More...
 
int length (Item *item) const
 Asserts that this is a linear grid and returns the length. More...
 
GridLayoutFormElementoperator= (const GridLayoutFormElement &)=delete
 
GridLayoutFormElementput (int column, int row, FormElement *element)
 Puts the element at column and row in the grid. More...
 
virtual QList< ItemRegionregions (DeclarativeItemBase *item, int parentX, int parentY) override
 
GridLayoutFormElementsetCellAlignment (LayoutStyle::Alignment horizontalAlignment, LayoutStyle::Alignment verticalAlignment)
 Sets the horizontal and vertical alignment to horizontalAlignment and verticalAlignment respectively for the cell where the last element was added. More...
 
GridLayoutFormElementsetCellHorizontalAlignment (LayoutStyle::Alignment horizontalAlignment)
 Sets the horizontal alignment to horizontalAlignment for the cell where the last element was added. More...
 
GridLayoutFormElementsetCellSpanning (int columnSpan, int rowSpan)
 Set the cell spanning of the cell where the last element was added. More...
 
GridLayoutFormElementsetCellVerticalAlignment (LayoutStyle::Alignment verticalAlignment)
 Sets the vertical alignment to verticalAlignment for the cell where the last element was added. More...
 
GridLayoutFormElementsetColumnHorizontalAlignment (int column, LayoutStyle::Alignment horizontalAlignment)
 Sets the horizontal alignment to horizontalAlignment for all the cells in the specified column. More...
 
GridLayoutFormElementsetColumnStretchFactor (int column, float stretchFactor)
 Sets the stretch factor of this column to stretchFactor. More...
 
GridLayoutFormElementsetColumnStretchFactors (float stretchFactor)
 Sets the stretch factor of all columns to stretchFactor. More...
 
GridLayoutFormElementsetHorizontalAlignment (LayoutStyle::Alignment horizontalAlignment)
 Sets the horizontal alignment to horizontalAlignment for all the cells in the grid. More...
 
GridLayoutFormElementsetHorizontalSpacing (int spaceBetweenColumns)
 Sets the horizontal spacing to spaceBetweenColumns. More...
 
GridLayoutFormElementsetRowStretchFactor (int row, float stretchFactor)
 Sets the stretch factor of this row to stretchFactor. More...
 
GridLayoutFormElementsetRowStretchFactors (float stretchFactor)
 Sets the stretch factor of all rows to stretchFactor. More...
 
GridLayoutFormElementsetRowVerticalAlignment (int row, LayoutStyle::Alignment verticalAlignment)
 Sets the vertical alignment to verticalAlignment for all the cells in the specified row. More...
 
GridLayoutFormElementsetSpacing (int spaceBetweenColumns, int spaceBetweenRows)
 Sets the horizontal and the vertical spacing to spaceBetweenColumns and spaceBetweenRows respectively. More...
 
GridLayoutFormElementsetSpacing (int spacing)
 Sets the horizontal and the vertical spacing to the same value. More...
 
GridLayoutFormElementsetStretchFactors (float stretchFactor)
 Sets the stretch factor of all columns and rows to stretchFactor. More...
 
GridLayoutFormElementsetVerticalAlignment (LayoutStyle::Alignment verticalAlignment)
 Sets the vertical alignment to verticalAlignment for all the cells in the grid. More...
 
GridLayoutFormElementsetVerticalSpacing (int spaceBetweenRows)
 Sets the vertical spacing to spaceBetweenRows. More...
 
virtual bool sizeDependsOnParent (const Item *item) const override
 
- Public Member Functions inherited from Visualization::SuperLayoutElement< GridLayoutFormElement, LayoutFormElement >
GridLayoutFormElementsetHasCursorWhenEmpty (std::function< bool(Item *item)> hasCursorWhenEmptyGetter)
 Sets a getter (cursorWhenEmptyGetter) for checking if the element should have cursors when empty dynamically while rendering. More...
 
GridLayoutFormElementsetNoBoundaryCursors (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...
 
GridLayoutFormElementsetNoInnerCursors (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...
 
GridLayoutFormElementsetNotLocationEquivalentCursors (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

void adjustSize (int containColumn, int containRow)
 Adjusts the dimensions of the grid, such that it contains the column with index containColumn and the row with index containColumn. More...
 
void computeOverallStretchFactors ()
 Recomputes and caches the sum of the column stretch factors and the row stretch factors respectively. More...
 

Private Attributes

QVector< QVector< LayoutStyle::Alignment > > cellHorizontalAlignmentGrid_ {}
 
QVector< QVector< LayoutStyle::Alignment > > cellVerticalAlignmentGrid_ {}
 
QVector< float > columnStretchFactors_ {}
 
QVector< LayoutStyle::AlignmentdefaultColumnHorizontalAlignments_ {}
 
float defaultColumnStretchFactor_ {}
 
LayoutStyle::Alignment defaultHorizontalAlignment_ {LayoutStyle::Alignment::Left}
 
float defaultRowStretchFactor_ {}
 
QVector< LayoutStyle::AlignmentdefaultRowVerticalAlignments_ {}
 
LayoutStyle::Alignment defaultVerticalAlignment_ {LayoutStyle::Alignment::Top}
 
QVector< QVector< FormElement * > > elementGrid_ {}
 
QPair< int, int > lastCell_ {QPair<int, int>(0, 0)}
 
int numColumns_ {1}
 
int numRows_ {1}
 
float overallColumnStretchFactor_ {}
 
float overallRowStretchFactor_ {}
 
QVector< float > rowStretchFactors_ {}
 
int spaceBetweenColumns_ {}
 
int spaceBetweenRows_ {}
 
QVector< QVector< QPair< int, int > > > spanGrid_ {}
 

Detailed Description

This class allows the arrangement of elements in a grid.

During its definition the grid is automatically resized to contain all the specified column and row indices.

The grid supports

Constructor & Destructor Documentation

◆ GridLayoutFormElement() [1/2]

Visualization::GridLayoutFormElement::GridLayoutFormElement ( )

◆ GridLayoutFormElement() [2/2]

Visualization::GridLayoutFormElement::GridLayoutFormElement ( const GridLayoutFormElement other)

◆ ~GridLayoutFormElement()

Visualization::GridLayoutFormElement::~GridLayoutFormElement ( )
virtual

Member Function Documentation

◆ adjustSize()

void Visualization::GridLayoutFormElement::adjustSize ( int  containColumn,
int  containRow 
)
private

Adjusts the dimensions of the grid, such that it contains the column with index containColumn and the row with index containColumn.

The grid dimensions can only grow.

◆ clone()

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

◆ computeOverallStretchFactors()

void Visualization::GridLayoutFormElement::computeOverallStretchFactors ( )
private

Recomputes and caches the sum of the column stretch factors and the row stretch factors respectively.

◆ computeSize()

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

Sets if the element has a cursor if it is empty to cursorWhenEmpty.

Is false by default. Also see SequentialLayoutStyle::hasCursorWhenEmpty().

◆ focusedElement2DIndex()

QPoint Visualization::GridLayoutFormElement::focusedElement2DIndex ( Item item) const

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

If no element is focused, returns -1 for both coordinates.

◆ focusedElementIndex()

int Visualization::GridLayoutFormElement::focusedElementIndex ( 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).

◆ itemAt()

const Visualization::Item * Visualization::GridLayoutFormElement::itemAt ( Visualization::DeclarativeItemBase item,
int  index 
) const

Asserts that this is a linear grid and returns the item at index.

If there is not an item but some compound FormElement at that place, that is also an assertion violation!

◆ length()

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

Asserts that this is a linear grid and returns the length.

◆ operator=()

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

◆ put()

GridLayoutFormElement * Visualization::GridLayoutFormElement::put ( int  column,
int  row,
FormElement element 
)

Puts the element at column and row in the grid.

If the element is already used elsewhere (is a form root, or has a parent) it is cloned and that clone is put in the grid instead.

Returns a pointer to this GridLayoutElement.

◆ regions()

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

◆ setCellAlignment()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setCellAlignment ( LayoutStyle::Alignment  horizontalAlignment,
LayoutStyle::Alignment  verticalAlignment 
)
inline

Sets the horizontal and vertical alignment to horizontalAlignment and verticalAlignment respectively for the cell where the last element was added.

Returns a pointer to this GridLayoutElement.

◆ setCellHorizontalAlignment()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setCellHorizontalAlignment ( LayoutStyle::Alignment  horizontalAlignment)
inline

Sets the horizontal alignment to horizontalAlignment for the cell where the last element was added.

Returns a pointer to this GridLayoutElement.

◆ setCellSpanning()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setCellSpanning ( int  columnSpan,
int  rowSpan 
)
inline

Set the cell spanning of the cell where the last element was added.

This means columnSpan x rowSpan cells will be merged into a new cell, of which the column and row of the last added cell is the top left corner. A default cell has a columnSpan and rowSpan of one each. Returns a pointer to this GridLayoutElement.

◆ setCellVerticalAlignment()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setCellVerticalAlignment ( LayoutStyle::Alignment  verticalAlignment)
inline

Sets the vertical alignment to verticalAlignment for the cell where the last element was added.

Returns a pointer to this GridLayoutElement.

◆ setColumnHorizontalAlignment()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setColumnHorizontalAlignment ( int  column,
LayoutStyle::Alignment  horizontalAlignment 
)
inline

Sets the horizontal alignment to horizontalAlignment for all the cells in the specified column.

Returns a pointer to this GridLayoutElement.

◆ setColumnStretchFactor()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setColumnStretchFactor ( int  column,
float  stretchFactor 
)
inline

Sets the stretch factor of this column to stretchFactor.

The stretch factor determines, how much of the additionally available space this column gets if there is any. By default this is 0, meaning the column does not stretch. If the stretch factor is bigger than zero, the column gets a portion of additional space computed by (stretchFactor) / (sum of all column stretch factors).

◆ setColumnStretchFactors()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setColumnStretchFactors ( float  stretchFactor)
inline

Sets the stretch factor of all columns to stretchFactor.

The stretch factor determines, how much of the additionally available space each column gets if there is any. By default this is 0, meaning the column does not stretch. If the stretch factor is bigger than zero, the column gets a portion of additional space computed by (stretchFactor) / (sum of all column stretch factors).

◆ setHorizontalAlignment()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setHorizontalAlignment ( LayoutStyle::Alignment  horizontalAlignment)
inline

Sets the horizontal alignment to horizontalAlignment for all the cells in the grid.

Returns a pointer to this GridLayoutElement.

◆ setHorizontalSpacing()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setHorizontalSpacing ( int  spaceBetweenColumns)
inline

Sets the horizontal spacing to spaceBetweenColumns.

Returns a pointer to this GridLayoutElement.

◆ setRowStretchFactor()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setRowStretchFactor ( int  row,
float  stretchFactor 
)
inline

Sets the stretch factor of this row to stretchFactor.

The stretch factor determines, how much of the additionally available space this row gets if there is any. By default this is 0, meaning the row does not stretch. If the stretch factor is bigger than zero, the row gets a portion of additional space computed by (stretchFactor) / (sum of all row stretch factors).

◆ setRowStretchFactors()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setRowStretchFactors ( float  stretchFactor)
inline

Sets the stretch factor of all rows to stretchFactor.

The stretch factor determines, how much of the additionally available space each row gets if there is any. By default this is 0, meaning the row does not stretch. If the stretch factor is bigger than zero, the row gets a portion of additional space computed by (stretchFactor) / (sum of all row stretch factors).

◆ setRowVerticalAlignment()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setRowVerticalAlignment ( int  row,
LayoutStyle::Alignment  verticalAlignment 
)
inline

Sets the vertical alignment to verticalAlignment for all the cells in the specified row.

Returns a pointer to this GridLayoutElement.

◆ setSpacing() [1/2]

GridLayoutFormElement * Visualization::GridLayoutFormElement::setSpacing ( int  spaceBetweenColumns,
int  spaceBetweenRows 
)
inline

Sets the horizontal and the vertical spacing to spaceBetweenColumns and spaceBetweenRows respectively.

Returns a pointer to this GridLayoutElement.

◆ setSpacing() [2/2]

GridLayoutFormElement * Visualization::GridLayoutFormElement::setSpacing ( int  spacing)
inline

Sets the horizontal and the vertical spacing to the same value.

Returns a pointer to this GridLayoutElement.

◆ setStretchFactors()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setStretchFactors ( float  stretchFactor)
inline

Sets the stretch factor of all columns and rows to stretchFactor.

The stretch factor determines, how much of the additionally available space each column/row gets if there is any. By default this is 0, meaning the column/row does not stretch. If the stretch factor is bigger than zero, the column/row gets a portion of additional space computed by (stretchFactor) / (sum of all column/row stretch factors).

◆ setVerticalAlignment()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setVerticalAlignment ( LayoutStyle::Alignment  verticalAlignment)
inline

Sets the vertical alignment to verticalAlignment for all the cells in the grid.

Returns a pointer to this GridLayoutElement.

◆ setVerticalSpacing()

GridLayoutFormElement * Visualization::GridLayoutFormElement::setVerticalSpacing ( int  spaceBetweenRows)
inline

Sets the vertical spacing to spaceBetweenRows.

Returns a pointer to this GridLayoutElement.

◆ sizeDependsOnParent()

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

Member Data Documentation

◆ cellHorizontalAlignmentGrid_

QVector<QVector<LayoutStyle::Alignment> > Visualization::GridLayoutFormElement::cellHorizontalAlignmentGrid_ {}
private

◆ cellVerticalAlignmentGrid_

QVector<QVector<LayoutStyle::Alignment> > Visualization::GridLayoutFormElement::cellVerticalAlignmentGrid_ {}
private

◆ columnStretchFactors_

QVector<float> Visualization::GridLayoutFormElement::columnStretchFactors_ {}
private

◆ defaultColumnHorizontalAlignments_

QVector<LayoutStyle::Alignment> Visualization::GridLayoutFormElement::defaultColumnHorizontalAlignments_ {}
private

◆ defaultColumnStretchFactor_

float Visualization::GridLayoutFormElement::defaultColumnStretchFactor_ {}
private

◆ defaultHorizontalAlignment_

LayoutStyle::Alignment Visualization::GridLayoutFormElement::defaultHorizontalAlignment_ {LayoutStyle::Alignment::Left}
private

◆ defaultRowStretchFactor_

float Visualization::GridLayoutFormElement::defaultRowStretchFactor_ {}
private

◆ defaultRowVerticalAlignments_

QVector<LayoutStyle::Alignment> Visualization::GridLayoutFormElement::defaultRowVerticalAlignments_ {}
private

◆ defaultVerticalAlignment_

LayoutStyle::Alignment Visualization::GridLayoutFormElement::defaultVerticalAlignment_ {LayoutStyle::Alignment::Top}
private

◆ elementGrid_

QVector<QVector<FormElement*> > Visualization::GridLayoutFormElement::elementGrid_ {}
private

◆ lastCell_

QPair<int, int> Visualization::GridLayoutFormElement::lastCell_ {QPair<int, int>(0, 0)}
private

◆ numColumns_

int Visualization::GridLayoutFormElement::numColumns_ {1}
private

◆ numRows_

int Visualization::GridLayoutFormElement::numRows_ {1}
private

◆ overallColumnStretchFactor_

float Visualization::GridLayoutFormElement::overallColumnStretchFactor_ {}
private

◆ overallRowStretchFactor_

float Visualization::GridLayoutFormElement::overallRowStretchFactor_ {}
private

◆ rowStretchFactors_

QVector<float> Visualization::GridLayoutFormElement::rowStretchFactors_ {}
private

◆ spaceBetweenColumns_

int Visualization::GridLayoutFormElement::spaceBetweenColumns_ {}
private

◆ spaceBetweenRows_

int Visualization::GridLayoutFormElement::spaceBetweenRows_ {}
private

◆ spanGrid_

QVector<QVector<QPair<int, int> > > Visualization::GridLayoutFormElement::spanGrid_ {}
private