terminalgui  0.1.0
Widgets for your terminal, powered by Qt! Create textual GUI (TUI) in your console easily.
tglayout.h
1 #pragma once
2 
3 #include "utils/tghelpers.h"
4 
5 namespace Tg {
6 class Widget;
7 
16 class Layout
17 {
18 public:
24  enum class Type {
26  None,
34  Column,
40  Row,
43  Grid
44  //Form?
45  };
46 
47  Layout() {}
48  virtual ~Layout() {}
49 
53  Type type() const;
54 
61  Widget *parent() const;
62 
68  void setParent(Widget *parent);
69 
74  virtual void doLayout();
75 
80  SizeOvershoot overshoot() const;
81 
82 protected:
86  Layout(const Type type);
87 
92  SizeOvershoot _overshoot = Overshoot::None;
93 
98  Widget *_parent = nullptr;
99 
104 };
105 }
Tg::Layout::doLayout
virtual void doLayout()
Lays out children of Widget (parent).
Definition: tglayout.cpp:21
Tg::Layout::_parent
Widget * _parent
Parent Widget.
Definition: tglayout.h:98
Tg::Layout::Type::Column
@ Column
Tg::Overshoot::None
@ None
Tg::Layout::type
Type type() const
Returns the Type of this Layout.
Definition: tglayout.cpp:6
Tg::Layout
Helper class for Widget, manages positions and sizes of Widget's children.
Definition: tglayout.h:17
Tg::Layout::Type
Type
Type of a Layout.
Definition: tglayout.h:24
Tg
All Terminal GUI classes (both core and widgets) are defined within the Tg namespace.
Definition: tgcolor.h:6
Tg::Widget
Base class for all widgets in a Terminal Gui application.
Definition: tgwidget.h:64
Tg::Layout::Type::Grid
@ Grid
Tg::Layout::_type
const Type _type
Type of a Layout.
Definition: tglayout.h:103
Tg::Layout::_overshoot
SizeOvershoot _overshoot
Indicates whether children of Widget cannot fit the Widget, and in which direction they fail to fit.
Definition: tglayout.h:92
Tg::Layout::Type::None
@ None
Does not perform any adjustment of child Widgets.
Tg::Layout::Type::ChildFillsParent
@ ChildFillsParent
A single child Widget will fill the entirety of parent Widget.
Tg::Layout::Type::Row
@ Row
Tg::Layout::overshoot
SizeOvershoot overshoot() const
Read this after calling doLayout() to check if all child widgets fit nicely onto parent.
Definition: tglayout.cpp:40
Tg::Layout::setParent
void setParent(Widget *parent)
Sets the parent Widget.
Definition: tglayout.cpp:16
Tg::Layout::parent
Widget * parent() const
Returns the parent Widget - on which Layout is working to resize and position it's children.
Definition: tglayout.cpp:11