CPGen
C++ project generator
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ComponentGroup Class Reference

A container widget that groups and lays out child Component objects. More...

#include <ComponentGroup.hpp>

Inheritance diagram for ComponentGroup:
Inheritance graph
[legend]
Collaboration diagram for ComponentGroup:
Collaboration graph
[legend]

Public Member Functions

 ComponentGroup (std::string title, std::string icon="")
 Construct a ComponentGroup with a title and an optional icon.
 
void addChild (std::unique_ptr< Component > child)
 Append a child component to the bottom of the group.
 
std::string render () const override
 Render the group and all its children as a multi-line ANSI string.
 
bool handleInput (Defs::Key key) override
 Handle a key event, routing it to the focused child or managing focus.
 
void setFocused (bool focused) override
 Propagate focus state changes to the currently focused child.
 
- Public Member Functions inherited from Component
 Component ()=default
 
virtual ~Component ()=default
 Virtual destructor — components are always owned via base-class pointer.
 
 Component (const Component &)=delete
 Non-copyable (unique ownership).
 
Componentoperator= (const Component &)=delete
 Non-copyable (unique ownership).
 
 Component (Component &&)=delete
 Non-movable.
 
Componentoperator= (Component &&)=delete
 Non-movable.
 
bool isFocused () const
 Return whether this component currently has keyboard focus.
 

Additional Inherited Members

- Protected Attributes inherited from Component
bool m_is_focused
 Current focus state, managed by setFocused.
 

Detailed Description

A container widget that groups and lays out child Component objects.

Renders itself as a fixed-width bordered box with a title (and optional icon) in the top border. Child components are stacked vertically inside the box. The group tracks an internal focus index and routes Defs::Special::Up / Defs::Special::Down to cycle focus between children; all other keys are forwarded to the currently focused child.

Constructor & Destructor Documentation

◆ ComponentGroup()

ComponentGroup::ComponentGroup ( std::string  title,
std::string  icon = "" 
)
explicit

Construct a ComponentGroup with a title and an optional icon.

Parameters
titleDisplayed in the top border of the group box.
iconOptional Nerd Font / Unicode glyph prepended to the title. Defaults to an empty string (no icon).

Member Function Documentation

◆ addChild()

void ComponentGroup::addChild ( std::unique_ptr< Component child)

Append a child component to the bottom of the group.

Ownership is transferred to the group. The first child added automatically receives focus when the group itself gains focus.

Parameters
childThe component to add.

◆ handleInput()

bool ComponentGroup::handleInput ( Defs::Key  key)
overridevirtual

Handle a key event, routing it to the focused child or managing focus.

Parameters
keyThe key to process.
Returns
true if the key was consumed (either by focus movement or by a child).

Implements Component.

◆ render()

std::string ComponentGroup::render ( ) const
overridevirtual

Render the group and all its children as a multi-line ANSI string.

Returns
Box border + one rendered child per line, all padded to the fixed width.

Implements Component.

Here is the call graph for this function:

◆ setFocused()

void ComponentGroup::setFocused ( bool  focused)
overridevirtual

Propagate focus state changes to the currently focused child.

When the group gains focus, the child at m_focused_index is also focused. When focus is removed from the group, all children are unfocused.

Parameters
focusedtrue to grant focus, false to remove it.

Reimplemented from Component.


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