libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
TuiLayout Class Referenceabstract

Abstract base class for TUI layout managers. More...

#include <layout.h>

Inheritance diagram for TuiLayout:
Collaboration diagram for TuiLayout:

Public Member Functions

 TuiLayout (ObjectBase *parent=nullptr)
 
virtual void addWidget (TuiWidget *widget)
 Adds a widget to this layout.
 
void removeWidget (TuiWidget *widget)
 Removes a widget from this layout.
 
virtual void addLayout (TuiLayout *layout)
 Adds a nested layout.
 
void setMargins (int top, int right, int bottom, int left)
 Sets the margins (top, right, bottom, left).
 
void setMargins (int margin)
 Sets uniform margins.
 
void setSpacing (int spacing)
 Sets the spacing between items.
 
int spacing () const
 Returns the spacing.
 
void margins (int &top, int &right, int &bottom, int &left) const
 Returns the margins.
 
virtual void calculateLayout (const Rect2Di32 &available)=0
 Calculates and applies the layout to the given rectangle.
 
virtual Size2Di32 sizeHint () const
 Returns the preferred size for this layout based on its children.
 
const List< TuiWidget * > & widgets () const
 Returns the list of managed widgets.
 
const List< TuiLayout * > & layouts () const
 Returns the list of sub-layouts.
 
- Public Member Functions inherited from ObjectBase
 ObjectBase (ObjectBase *p=nullptr)
 Default ObjectBase constructor.
 
virtual ~ObjectBase ()
 Destructor. Emits aboutToDestroy, detaches from parent, and destroys children.
 
ObjectBaseparent () const
 Returns the parent object, if one. nullptr if none.
 
void setParent (ObjectBase *p)
 Sets the parent of this object. If the object already has a parent, it will be removed as a child from the old parent and added as a child to the new one.
 
const ObjectBaseListchildList () const
 Returns a list of children of this object.
 
template<typename... Args>
int registerSlot (Slot< Args... > *slot)
 Registers a slot with this object and assigns it an ID.
 
EventLoopeventLoop () const
 Returns the EventLoop this object is affiliated with.
 
void moveToThread (EventLoop *loop)
 Changes the EventLoop affinity of this object.
 
int startTimer (unsigned int intervalMs, bool singleShot=false)
 Starts a timer on this object's EventLoop.
 
void stopTimer (int timerId)
 Stops a timer previously started with startTimer().
 
template<typename... Args>
PROMEKI_NAMESPACE_BEGIN void connect (Signal< Args... > *signal, Slot< Args... > *slot)
 

Protected Member Functions

Rect2Di32 contentRect (const Rect2Di32 &available) const
 Returns the content rect after subtracting margins.
 
- Protected Member Functions inherited from ObjectBase
ObjectBasesignalSender ()
 Returns the ObjectBase that emitted the signal currently being handled.
 
virtual void event (Event *e)
 Called by EventLoop to deliver events to this object.
 
virtual void timerEvent (TimerEvent *e)
 Called when a timer fires for this object.
 

Protected Attributes

List< TuiWidget * > _widgets
 
List< TuiLayout * > _layouts
 

Additional Inherited Members

- Public Types inherited from ObjectBase
using SlotVariantFunc = std::function< void(const VariantList &)>
 Function type for invoking a slot with a list of Variants.
 
- Static Public Member Functions inherited from ObjectBase
static const MetaInfometaInfo ()
 Returns the MetaInfo for the ObjectBase class.
 
template<typename... Args>
static void connect (Signal< Args... > *signal, Slot< Args... > *slot)
 connects a signal and slot together. This function assumes both the signal and slot exist in a ObjectBase or derived object
 
- Public Attributes inherited from ObjectBase
Signal< ObjectBase * > aboutToDestroySignal = Signal< ObjectBase * >(this, aboutToDestroySignalName)
 
- Static Public Attributes inherited from ObjectBase
static constexpr const charaboutToDestroySignalName = PROMEKI_STRINGIFY( aboutToDestroy ) "(" PROMEKI_STRINGIFY_ARGS( ObjectBase * ) ")"
 
static SignalMeta aboutToDestroySignalMeta = SignalMeta(metaInfo(), aboutToDestroySignalName)
 

Detailed Description

Abstract base class for TUI layout managers.

A layout positions child widgets within the available rectangle. Layouts can be nested by adding sub-layouts.

Member Function Documentation

◆ addLayout()

virtual void TuiLayout::addLayout ( TuiLayout layout)
virtual

Adds a nested layout.

Reimplemented in TuiBoxLayout.

◆ addWidget()

virtual void TuiLayout::addWidget ( TuiWidget widget)
virtual

Adds a widget to this layout.

Reimplemented in TuiBoxLayout.

◆ calculateLayout()

virtual void TuiLayout::calculateLayout ( const Rect2Di32 available)
pure virtual

Calculates and applies the layout to the given rectangle.

Parameters
availableThe available rectangle.

Implemented in TuiBoxLayout, and TuiGridLayout.

◆ sizeHint()

virtual Size2Di32 TuiLayout::sizeHint ( ) const
virtual

Returns the preferred size for this layout based on its children.

Reimplemented in TuiBoxLayout.


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