CPGen
C++ project generator
Loading...
Searching...
No Matches
ComponentGroup.hpp
Go to the documentation of this file.
1#pragma once
2
10#include <memory>
11#include <string>
12#include <vector>
13
25class ComponentGroup : public Component {
26public:
33 explicit ComponentGroup(std::string title, std::string icon = "");
34
43 void addChild(std::unique_ptr<Component> child);
44
50 [[nodiscard]] std::string render() const override;
51
63 bool handleInput(Defs::Key key) override;
64
73 void setFocused(bool focused) override;
74
75private:
86 bool moveFocus(int dir);
87
88 std::string m_title;
89 std::string m_icon;
90 std::vector<std::unique_ptr<Component>>
91 m_children;
92 size_t m_focused_index = 0;
93};
Abstract base class for all TUI components.
A container widget that groups and lays out child Component objects.
Definition ComponentGroup.hpp:25
void setFocused(bool focused) override
Propagate focus state changes to the currently focused child.
Definition ComponentGroup.cpp:19
void addChild(std::unique_ptr< Component > child)
Append a child component to the bottom of the group.
Definition ComponentGroup.cpp:15
bool handleInput(Defs::Key key) override
Handle a key event, routing it to the focused child or managing focus.
Definition ComponentGroup.cpp:109
std::string render() const override
Render the group and all its children as a multi-line ANSI string.
Definition ComponentGroup.cpp:53
Abstract base for all TUI widgets.
Definition Component.hpp:38
std::variant< char, Special > Key
A single keypress from stdin, represented as either a printable character or a Special control key.
Definition Defs.hpp:45