UI_Lib  a1366e08a59cc549a65fa26081e6409aa12f26d5
This is a user interface library for graphical LCDs. It offers many different controls and indicators that can be nested depending on the element types.
Loading...
Searching...
No Matches
ContainerGrid Class Reference

Class for a container that is showing all items at a time in a fixed grid layout. More...

#include <ContainerGrid.h>

Inheritance diagram for ContainerGrid:
Container UIElement

Public Member Functions

 ContainerGrid (uint8_t maxNumItems=DEFAULT_MAX_CONTAINER_ITEMS, uint8_t maxGridRows=DEFAULT_MAX_CONTAINERGRID_ROWS, uint8_t maxGridColumns=DEFAULT_MAX_CONTAINERGRID_COLUMNS, bool showGridCells=false, bool autoSizingFillLast=true, uint16_t locX=0, uint16_t locY=0, uint16_t width=0, uint16_t height=0)
 Constructor of the ContainerGrid.
 
 ~ContainerGrid ()
 Destructor of the ContainerGrid.
 
virtual void Draw (bool redraw) override
 Method used for drawing of the ContainerGrid.
 
virtual bool KeyInput (Keys_t key) override
 Process the given key.
 
virtual bool TouchInput (uint16_t x, uint16_t y, TouchTypes touchType) override
 Process a touch input at the given point (x, y)
 
void InitItems ()
 This method selects the first UIElement in the container that is of UI_CONTROL type.
 
bool SetRowHeight (uint8_t rowIndex, uint16_t rowHeight)
 Set the height of a specific row.
 
bool SetColumnWidth (uint8_t columnIndex, uint16_t columnWidth)
 Set the width of a specific column.
 
bool AddItem (UIElement *item, uint8_t columnIndex, uint8_t rowIndex, GridCellAlignment_t cellAlignment=GRID_CELL_ALIGNMENT_MIDDLE, uint8_t columnSpan=1, uint8_t rowSpan=1)
 Add the item to the elements of this container and adapt the item location accordingly.
 
virtual void RecalculateDimensions () override
 Recalculate the Height and Width of the UIElement.
 
virtual void RecalculateLayout () override
 Recalculate the UIElement layout (containers update the X- and Y-Location of all their items, all other items can do other layout update stuff)
 
- Public Member Functions inherited from Container
 Container (uint8_t maxNumItems=DEFAULT_MAX_CONTAINER_ITEMS)
 Constructor of the Container.
 
 ~Container ()
 Destructor of the Container.
 
virtual void Draw ()
 Virtual method used for drawing of the container UIElement.
 
UIElementGetSelectedItem ()
 Get the selected item.
 
bool AddItem (UIElement *item)
 Add a new element to the container and activate it as active child.
 
void ClearAllItems ()
 Clear all items in the container.
 
bool NextItem ()
 Select the next item in the container.
 
bool PreviousItem ()
 Select the previous item in the container.
 
bool NextControlItem ()
 Select the next item in the container that is of UI_CONTROL type.
 
bool PreviousControlItem ()
 Select the previous item in the container that is of UI_CONTROL type.
 
void GetItemsBoundingBox (uint16_t *x, uint16_t *y, uint16_t *w, uint16_t *h)
 Get a bounding box around all items in the Container.
 
- Public Member Functions inherited from UIElement
 UIElement (UIElementType type)
 Constructor of the UIElement.
 
 UIElement (uint16_t locX, uint16_t locY, UIElementType type)
 Constructor of the UIElement.
 
bool HitTest (uint16_t x, uint16_t y)
 Check if the given point (x, y) is inside this UIElement.
 

Private Attributes

uint8_t _maxGridRows
 Maximum number of rows, each container grid can hold.
 
uint8_t _maxGridColumns
 Maximum number of columns, each container grid can hold.
 
bool _showGridCells
 Enable this to draw the grid cells.
 
bool _autoSizingFillLast
 If true, keep all columns or rows as small as possible except the last one set to auto size; if false, evenly increase the size of all columns or rows set to auto size.
 
uint16_t * _initialRowHeights
 Heights for the individual rows.
 
uint16_t * _initialColumnWidths
 Widths for the individual columns.
 
uint16_t * _rowHeights
 Heights for the individual rows.
 
uint16_t * _columnWidths
 Widths for the individual columns.
 
GridItemConfig_itemConfiguration
 Configuration data for all items inside the grid.
 

Additional Inherited Members

- Public Attributes inherited from UIElement
UIElementType Type
 Element type (control, indicator, container)
 
uint16_t LocX
 X Location of the upper left corner of the UIElement.
 
uint16_t LocY
 Y Location of the upper left corner of the UIElement.
 
uint16_t Width
 Drawing width of the UIElement.
 
uint16_t Height
 Drawing height of the UIElement.
 
bool Visible
 The UIElement is only drawn if the visibility is set to true.
 
bool IsInEditMode
 Is the UIElement in edit mode?
 
UIElementParent
 Parent UIElement that this UIElement belongs to.
 
UIElementActiveChild
 Child element that is currently active (receiving all key inputs).
 
- Protected Attributes inherited from Container
uint8_t _maxNumItems
 Maximum number of items, each container can hold.
 
UIElement ** _items
 Array holding pointers to all UIElement that are items of the container.
 
uint8_t _numItems
 Number of items in the container (number of valid items in the _items array).
 
uint8_t _selectedItemIndex
 Index of the selected container item.
 
- Protected Attributes inherited from UIElement
bool _lastDrawnVisible
 The Visible value that was last drawn.
 

Detailed Description

Class for a container that is showing all items at a time in a fixed grid layout.

Constructor & Destructor Documentation

◆ ContainerGrid()

ContainerGrid::ContainerGrid ( uint8_t maxNumItems = DEFAULT_MAX_CONTAINER_ITEMS,
uint8_t maxGridRows = DEFAULT_MAX_CONTAINERGRID_ROWS,
uint8_t maxGridColumns = DEFAULT_MAX_CONTAINERGRID_COLUMNS,
bool showGridCells = false,
bool autoSizingFillLast = true,
uint16_t locX = 0,
uint16_t locY = 0,
uint16_t width = 0,
uint16_t height = 0 )

Constructor of the ContainerGrid.

Parameters
maxNumItemsMaximum number of items, each container can hold. Lower this value if you don't need that much items to save memory.
maxGridRowsMaximum number of rows, each container grid can hold. Lower this value if you don't need that much items to save memory.
maxGridColumnsMaximum number of columns, each container grid can hold. Lower this value if you don't need that much items to save memory.
showGridCellsEnable this to draw the grid cells
autoSizingFillLastIf true, keep all columns or rows as small as possible except the last one set to auto size; if false, evenly increase the size of all columns or rows set to auto size
locXX Location of the upper left corner of the ContainerGrid
locYY Location of the upper left corner of the ContainerGrid
widthDrawing width of the ContainerGrid
heightDrawing height of the ContainerGrid

Member Function Documentation

◆ AddItem()

bool ContainerGrid::AddItem ( UIElement * item,
uint8_t columnIndex,
uint8_t rowIndex,
GridCellAlignment_t cellAlignment = GRID_CELL_ALIGNMENT_MIDDLE,
uint8_t columnSpan = 1,
uint8_t rowSpan = 1 )

Add the item to the elements of this container and adapt the item location accordingly.

Parameters
itemPointer to the UIElement that should be added to the container.
columnIndexIndex of the column to insert the item into.
rowIndexIndex of the row to insert the item into.
cellAlignmentAlignment for the cell.
columnSpanNumber of columns over which the item is placed (starting from column index)
rowSpanNumber of rows over which the item is placed (starting from row index)
Returns
true, if added; otherwise false (if container is full)

◆ Draw()

void ContainerGrid::Draw ( bool redraw)
overridevirtual

Method used for drawing of the ContainerGrid.

Implements UIElement.

◆ KeyInput()

bool ContainerGrid::KeyInput ( Keys_t key)
overridevirtual

Process the given key.

If this element doesn't support the key type, the key is forwarded to the parent. This is done until the key is processed or the root of the visual tree is reached.

Parameters
keyKey that should be processed. Supported keys are: KEYUP, KEYDOWN
Returns
true if the key was processed; false if not.

Reimplemented from Container.

◆ RecalculateDimensions()

void ContainerGrid::RecalculateDimensions ( )
overridevirtual

Recalculate the Height and Width of the UIElement.

Implements UIElement.

◆ RecalculateLayout()

void ContainerGrid::RecalculateLayout ( )
overridevirtual

Recalculate the UIElement layout (containers update the X- and Y-Location of all their items, all other items can do other layout update stuff)

RECALCULATE COLUMN WIDTHS * sort the item configurations ascending by column span

RECALCULATE ROW HEIGHTS * sort the item configurations ascending by row span

PLACE EACH ITEM INSIDE CONTAINER REGION

Reimplemented from UIElement.

◆ SetColumnWidth()

bool ContainerGrid::SetColumnWidth ( uint8_t columnIndex,
uint16_t columnWidth )

Set the width of a specific column.

0 if column sizes to the largest item.

Parameters
columnIndexIndex of the column to set.
columnWidthNew width for the column.
Returns
true, if set; otherwise false (if index is out of range)

◆ SetRowHeight()

bool ContainerGrid::SetRowHeight ( uint8_t rowIndex,
uint16_t rowHeight )

Set the height of a specific row.

0 if row sizes to the largest item.

Parameters
rowIndexIndex of the row to set.
rowHeightNew height for the row.
Returns
true, if set; otherwise false (if index is out of range)

◆ TouchInput()

bool ContainerGrid::TouchInput ( uint16_t x,
uint16_t y,
TouchTypes touchType )
overridevirtual

Process a touch input at the given point (x, y)

Parameters
xX-Coordinate of the touched point
yY-Coordinate of the touched point
touchTypeType of the touch
Returns
true if the touch was processed; false if not.

Reimplemented from UIElement.

Member Data Documentation

◆ _columnWidths

uint16_t* ContainerGrid::_columnWidths
private

Widths for the individual columns.

They are recalculated by the RecalculateLayout() method.

◆ _initialColumnWidths

uint16_t* ContainerGrid::_initialColumnWidths
private

Widths for the individual columns.

0 if column sizes to the largest item.

◆ _initialRowHeights

uint16_t* ContainerGrid::_initialRowHeights
private

Heights for the individual rows.

0 if row sizes to the largest item.

◆ _maxGridColumns

uint8_t ContainerGrid::_maxGridColumns
private

Maximum number of columns, each container grid can hold.

Lower this value if you don't need that much items to save memory.

◆ _maxGridRows

uint8_t ContainerGrid::_maxGridRows
private

Maximum number of rows, each container grid can hold.

Lower this value if you don't need that much items to save memory.

◆ _rowHeights

uint16_t* ContainerGrid::_rowHeights
private

Heights for the individual rows.

They are recalculated by the RecalculateLayout() method.


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