Lysa UI  0.0
Lysa UI —UI components for the Lysa Engine
Grid Class Reference

Detailed Description

A grid of GridCell.

+ Inheritance diagram for Grid:

Public Member Functions

 Grid (uint32 rows=0, uint32 columns=0)
 
void setResources (const std::string &resCell)
 
auto getRowCount () const
 
auto getColumnCount () const
 
uint32 addRow (float height=AUTO_SIZE)
 
uint32 addColumn (float width=AUTO_SIZE)
 
void insertRow (uint32 index, float height=AUTO_SIZE)
 
void insertColumn (uint32 index, float width=AUTO_SIZE)
 
void removeRow (uint32 index)
 
void removeColumn (uint32 index)
 
void removeAllRows ()
 
void clear ()
 
void setRowHeight (uint32 row, float height)
 
float getRowHeight (uint32 row) const
 
void setColumnWidth (uint32 column, float width)
 
float getColumnWidth (uint32 column) const
 
float getRowRealHeight (uint32 row) const
 
float getColumnRealWidth (uint32 column) const
 
float getRowPosition (uint32 row) const
 
float getColumnPosition (uint32 column) const
 
std::shared_ptr< GridCellgetCell (uint32 row, uint32 column) const
 
std::shared_ptr< GridCellgetCellAt (float x, float y) const
 
const auto & getCells () const
 
bool merge (uint32 row, uint32 column, uint32 rowSpan, uint32 columnSpan)
 
void split (uint32 row, uint32 column)
 
void swapRows (uint32 first, uint32 second)
 
void moveRow (uint32 from, uint32 to)
 
void reorderRows (const std::vector< uint32 > &order)
 
void setGridColor (const float4 &color)
 
auto getGridColor () const
 
auto hasGridColor () const
 
void resetGridColor ()
 
void setGridVisible (bool visible=true)
 
auto isGridVisible () const
 
Rect getClientRect () const
 
void onResize () override
 
- Public Member Functions inherited from Panel
 Panel ()
 
- Public Member Functions inherited from Widget
 Widget (Type type=WIDGET)
 
 ~Widget () override
 
Type getType () const
 
bool isVisible () const
 
void setVisible (bool show=true)
 
bool isEnabled () const
 
void setEnabled (bool isEnabled=true)
 
virtual void setPos (float x, float y)
 
float getWidth () const
 
float getHeight () const
 
float getRequestedWidth () const
 
float getRequestedHeight () const
 
virtual void setSize (float width, float height)
 
void setWidth (const float width)
 
void setHeight (const float height)
 
const Rect & getRect () const
 
void setRect (float x, float y, float width, float height)
 
void setRect (const Rect &rect)
 
float getAspectRatio () const
 
Alignment getAlignment () const
 
void setAlignment (Alignment alignment)
 
std::shared_ptr< Font > getFont () const
 
void setFont (const std::shared_ptr< Font > &font)
 
float getFontScale () const
 
virtual void setFontScale (float fontScale)
 
bool isFocused () const
 
Widget * getParent () const
 
void setOverlap (const bool overlap)
 
template<typename T , typename... Args>
std::shared_ptr< T > create (const std::string &resource, const Alignment alignment, Args &&...args)
 
template<typename T , typename... Args>
std::shared_ptr< T > create (const Alignment alignment, Args &&...args)
 
template<typename T >
std::shared_ptr< T > add (std::shared_ptr< T > child, const Alignment alignment=Alignment::NONE, const std::string &resource="", const bool overlap=false)
 
template<typename T >
std::shared_ptr< T > addPopup (std::shared_ptr< T > child, const std::string &resource="")
 
template<typename T >
std::shared_ptr< T > addAfter (std::shared_ptr< T > child, const std::shared_ptr< Widget > &after, const Alignment alignment, const std::string &resource="", const bool overlap=false)
 
virtual void remove (const std::shared_ptr< Widget > &child)
 
virtual void removeAll ()
 
void setPadding (float padding)
 
float getPadding () const
 
float getVBorder () const
 
float getHBorder () const
 
void setVBorder (float size)
 
void setHBorder (float size)
 
bool isDrawBackground () const
 
void setDrawBackground (bool drawBackground)
 
bool isPushed () const
 
bool isPointed () const
 
bool isFreezed () const
 
bool isRedrawOnMouseEvent () const
 
bool isOverlapping () const
 
Rect getChildrenRect () const
 
void setFreezed (const bool f)
 
void setPushed (const bool p)
 
void refresh ()
 
void setResource (std::shared_ptr< UIResource > res)
 
uint32 getGroupIndex () const
 
void setGroupIndex (int32 index)
 
template<typename T >
getUserData () const
 
template<typename T >
std::shared_ptr< T > getPointerUserData () const
 
const std::any & getUserData () const
 
void setUserData (const std::any &data)
 
float getTransparency () const
 
void setTransparency (float alpha)
 
void resizeChildren ()
 
float getChildrenOffsetX () const
 
float getChildrenOffsetY () const
 
void setChildrenOffset (float x, float y)
 
std::shared_ptr< Widget > setFocus (bool focus=true)
 
virtual void onAttach ()
 
virtual void onDetach ()
 
virtual void onShow ()
 
virtual void onHide ()
 
virtual void onMove ()
 
virtual bool onKeyDown (Key key)
 
virtual bool onTextInput (const std::string &text)
 
virtual bool onKeyUp (Key key)
 
virtual bool onMouseDown (MouseButton button, float x, float y)
 
virtual bool onMouseUp (MouseButton button, float x, float y)
 
virtual bool onMouseMove (uint32 buttonsState, float x, float y)
 
virtual void onMouseLeave ()
 
virtual void onDisable ()
 
virtual void onEnable ()
 
virtual void onGotFocus ()
 
virtual void onLostFocus ()
 
bool getConsumeMouseEvent () const
 
void setConsumeMouseEvent (const bool consumeMouseEvent)
 
const std::list< std::shared_ptr< Widget > > & getChildren () const
 
bool hasChildren () const
 
void subscribe (const event_type &type, unique_id id, EventHandlerCallback callback)
 
void subscribe (const event_type &type, EventHandlerCallback callback)
 
void unsubscribe (unique_id id)
 
bool isAttached () const
 
WindowgetWindow () const
 
StylegetStyle () const
 
Vector2DRenderer & getRenderer () const
 
RenderingWindow & getRenderingWindow () const
 
WindowManagergetWindowManager () const
 

Static Public Attributes

static constexpr float AUTO_SIZE {0.0f}
 Height of a row or width of a column sharing the remaining space. More...
 

Additional Inherited Members

- Public Types inherited from Widget
enum  Type {
  WIDGET, PANEL, BOX, LINE,
  FRAME, BUTTON, TOGGLEBUTTON, RADIOBUTTON,
  CHECKBOX, CHECKMARK, CROSSMARK, ARROW,
  TEXT, TEXTEDIT, RICHTEXTAREA, SCROLLBAR,
  SLIDER, COLORSLIDER, COLORWHEEL, KNOB,
  TREEVIEW, IMAGE, POPUP, LIST,
  LISTBOX, SELECTION, PROGRESSBAR, SCROLLCONTAINER,
  MENU, MENUPANEL, MENUBOX, TABBAR,
  TABCONTAINER, DIALOG, FOLDABLECONTAINER, COLORPICKER,
  COLORPICKERBUTTON, SPINBOX, SPINBUTTONS, ICONIMAGE,
  ICONSVG, DROPDOWNLIST, TOOLTIP, GRIDCELL,
  GRID, TABLE
}
 
- Protected Member Functions inherited from Panel
 Panel (const Type type)
 
- Protected Attributes inherited from Widget
const Type type
 
Rect rect
 
float requestedWidth {0}
 
float requestedHeight {0}
 
float hborder {0}
 
float vborder {0}
 
float padding {0}
 
bool consumeMouseEvent {false}
 
bool overlap {false}
 
bool focused {false}
 
bool allowFocus {false}
 
bool allowChildren {true}
 
bool drawBackground {true}
 
bool moveChildrenOnPush {false}
 
bool scrollChildren {false}
 
bool skipInvisibleChildren {false}
 
bool redrawOnMouseEvent {false}
 
bool redrawOnMouseMove {false}
 
float transparency {1.0f}
 
Widget * parent {nullptr}
 
Alignment alignment {Alignment::NONE}
 
std::shared_ptr< UIResourceresource
 
std::list< std::shared_ptr< Widget > > children
 
bool mouseMoveOnFocus {false}
 
float childrenOffsetX {0}
 
float childrenOffsetY {0}
 

Constructor & Destructor Documentation

Grid ( uint32  rows = 0,
uint32  columns = 0 
)

Creates a grid.

The rows and the columns are created when the grid is added to a Window.

Parameters
rowsInitial number of rows, all sized with AUTO_SIZE.
columnsInitial number of columns, all sized with AUTO_SIZE.

Member Function Documentation

uint32 addColumn ( float  width = AUTO_SIZE)

Appends a column at the right of the grid.

Parameters
widthWidth of the column or AUTO_SIZE.
Returns
The index (0-based) of the added column.
uint32 addRow ( float  height = AUTO_SIZE)

Appends a row at the bottom of the grid.

Parameters
heightHeight of the row or AUTO_SIZE.
Returns
The index (0-based) of the added row.
void clear ( )

Removes all the rows, all the columns and all the cells.

std::shared_ptr<GridCell> getCell ( uint32  row,
uint32  column 
) const

Returns the cell displaying a given position spans included or nullptr for an invalid position.

std::shared_ptr<GridCell> getCellAt ( float  x,
float  y 
) const

Returns the cell displayed at a given position of the UI or nullptr.

const auto& getCells ( ) const
inline

Returns all the cells of the grid in creation order.

Rect getClientRect ( ) const

Returns the rectangle of the grid without its borders & padding.

auto getColumnCount ( ) const
inline

Returns the number of columns.

float getColumnPosition ( uint32  column) const

Returns the X coordinate of the left border of a column.

float getColumnRealWidth ( uint32  column) const

Returns the width currently used by a column AUTO_SIZE columns included.

float getColumnWidth ( uint32  column) const

Returns the width requested for a column or AUTO_SIZE.

auto getGridColor ( ) const
inline

Returns the color set with setGridColor().

auto getRowCount ( ) const
inline

Returns the number of rows.

float getRowHeight ( uint32  row) const

Returns the height requested for a row or AUTO_SIZE.

float getRowPosition ( uint32  row) const

Returns the Y coordinate of the bottom border of a row.

float getRowRealHeight ( uint32  row) const

Returns the height currently used by a row AUTO_SIZE rows included.

auto hasGridColor ( ) const
inline

Returns true if a color was set with setGridColor().

void insertColumn ( uint32  index,
float  width = AUTO_SIZE 
)

Inserts a column (the columns at its right being shifted right).

The cells spanning across the insertion point are split.

Parameters
indexIndex of the inserted column clamped to the number of columns.
widthWidth of the column, or AUTO_SIZE.
void insertRow ( uint32  index,
float  height = AUTO_SIZE 
)

Inserts a row (the rows below being shifted down).

The cells spanning across the insertion point are split.

Parameters
indexIndex of the inserted row clamped to the number of rows.
heightHeight of the row, or AUTO_SIZE.
auto isGridVisible ( ) const
inline

Returns true if the lines between the cells are drawn.

bool merge ( uint32  row,
uint32  column,
uint32  rowSpan,
uint32  columnSpan 
)

Merges a rectangle of cells into the cell at its top-left position.

Parameters
rowRow of the top-left position of the rectangle.
columnColumn of the top-left position of the rectangle.
rowSpanNumber of rows of the rectangle.
columnSpanNumber of columns of the rectangle.
Returns
False if the rectangle is not inside the grid.
void moveRow ( uint32  from,
uint32  to 
)

Moves a row to another index with the widgets it displays and its height.

Does nothing if a cell spans several rows.

void onResize ( )
overridevirtual

Event called after a size change.

Reimplemented from lysa::ui::Widget::onResize()

void removeAllRows ( )

Removes all the rows & the cells they display.

void removeColumn ( uint32  index)

Removes a column & the cells it displays (the columns at its right being shifted left).

The cells spanning across the removed column are split.

void removeRow ( uint32  index)

Removes a row & the cells it displays (the rows below being shifted up).

The cells spanning across the removed row are split.

void reorderRows ( const std::vector< uint32 > &  order)

Reorders all the rows with the widgets they display and their heights.

Does nothing if a cell spans several rows.

Parameters
orderIndexes of the current rows in their new display order.
void resetGridColor ( )

Draws the lines between the cells with the color of the Style.

void setColumnWidth ( uint32  column,
float  width 
)

Sets the width of a column or AUTO_SIZE to share the remaining space.

void setGridColor ( const float4 &  color)

Sets the color of the lines drawn between the cells.

void setGridVisible ( bool  visible = true)

Shows or hides the lines drawn between the cells.

void setResources ( const std::string &  resCell)

Sets the UI resources of the widgets created by the grid.

void setRowHeight ( uint32  row,
float  height 
)

Sets the height of a ro, or AUTO_SIZE to share the remaining space.

void split ( uint32  row,
uint32  column 
)

Removes the span of the cell displaying a given position.

The positions previously covered by the span get new empty cells.

void swapRows ( uint32  first,
uint32  second 
)

Exchanges two rows with the widgets they display and their heights.

Does nothing if a cell spans several rows.

Member Data Documentation

constexpr float AUTO_SIZE {0.0f}
staticconstexpr

Height of a row or width of a column sharing the remaining space.