terminalgui
0.1.0
Widgets for your terminal, powered by Qt! Create textual GUI (TUI) in your console easily.
|
Helper class for Widget, manages positions and sizes of Widget's children. More...
#include <tglayout.h>
Public Types | |
enum | Type { Type::None, Type::ChildFillsParent, Type::Column, Type::Row, Type::Grid } |
Type of a Layout. More... | |
Public Member Functions | |
Type | type () const |
Returns the Type of this Layout. | |
Widget * | parent () const |
Returns the parent Widget - on which Layout is working to resize and position it's children. More... | |
void | setParent (Widget *parent) |
Sets the parent Widget. More... | |
virtual void | doLayout () |
Lays out children of Widget (parent). More... | |
SizeOvershoot | overshoot () const |
Read this after calling doLayout() to check if all child widgets fit nicely onto parent. | |
Protected Member Functions | |
Layout (const Type type) | |
Constructor used by subclasses to set Layout type they implement. | |
Protected Attributes | |
SizeOvershoot | _overshoot = Overshoot::None |
Indicates whether children of Widget cannot fit the Widget, and in which direction they fail to fit. | |
Widget * | _parent = nullptr |
Parent Widget. More... | |
const Type | _type = Type::None |
Type of a Layout. More... | |
Helper class for Widget, manages positions and sizes of Widget's children.
When subclassing, reimplement doLayout().
|
strong |
Type of a Layout.
Each Layout subclass has a distinct Layout::Type.
Default is Type::None, used by main Layout class.
Enumerator | |
---|---|
None | Does not perform any adjustment of child Widgets. |
ChildFillsParent | A single child Widget will fill the entirety of parent Widget. |
Column | Each child Widget will be put below previous one in a single column. All Widgets are as wide as the parent Widget. For example, when a Widget has 3 children, it will have 3 "rows", each occupying 33% of parent Widget's height. All 3 children will be as wide as the parent Widget. |
Row | Each child Widget will be put after previous one in a single row. All Widgets are as high as the parent Widget. For example, when a Widget has 3 children, it will have 3 "columns", each occupying 33% of parent Widget's width. All 3 children will be as high as the parent Widget. |
Grid | Each child Widget will be put in a same-sized grid item.
|
|
virtual |
Lays out children of Widget (parent).
It stretches first child to fill the whole widget.
Reimplemented in Tg::GridLayout, Tg::ChildFillsParentLayout, Tg::ColumnLayout, and Tg::RowLayout.
Tg::Widget * Tg::Layout::parent | ( | ) | const |
void Tg::Layout::setParent | ( | Tg::Widget * | parent | ) |
|
protected |
Parent Widget.
Layout will work on correct positioning and resizing of this Widget's children when doLayout() is called.
|
protected |
Type of a Layout.
Each subclass sets it's own Type.