terminalgui  0.1.0
Widgets for your terminal, powered by Qt! Create textual GUI (TUI) in your console easily.
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Tg::Layout Class Reference

Helper class for Widget, manages positions and sizes of Widget's children. More...

#include <tglayout.h>

Inheritance diagram for Tg::Layout:
Inheritance graph
[legend]
Collaboration diagram for Tg::Layout:
Collaboration graph
[legend]

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.
 
Widgetparent () 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...
 

Detailed Description

Helper class for Widget, manages positions and sizes of Widget's children.

When subclassing, reimplement doLayout().

Note
Currently, all child Widgets will be sized equally by the layout. Stretch and size hint functionality from QtWidgets are not implemented.

Member Enumeration Documentation

◆ Type

enum Tg::Layout::Type
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.

Todo:
Improve description (and implementation... ;-))

Member Function Documentation

◆ doLayout()

void Tg::Layout::doLayout ( )
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.

◆ parent()

Tg::Widget * Tg::Layout::parent ( ) const

Returns the parent Widget - on which Layout is working to resize and position it's children.

See also
setParent

◆ setParent()

void Tg::Layout::setParent ( Tg::Widget parent)

Sets the parent Widget.

See also
parent

Member Data Documentation

◆ _parent

Widget* Tg::Layout::_parent = nullptr
protected

Parent Widget.

Layout will work on correct positioning and resizing of this Widget's children when doLayout() is called.

◆ _type

const Type Tg::Layout::_type = Type::None
protected

Type of a Layout.

Each subclass sets it's own Type.


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