Merge dom and component focus (#978)

Instead of two levels of focus with `focus` and `selected`, use a recursive
level. The components set the one "active" and hbox/vbox/dbox 

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
Ayaan
2025-03-19 20:03:05 +05:30
committed by GitHub
parent 8519e9b0f3
commit b0e087ecef
38 changed files with 431 additions and 341 deletions

View File

@@ -98,7 +98,7 @@ class VerticalContainer : public ContainerBase {
public:
using ContainerBase::ContainerBase;
Element Render() override {
Element OnRender() override {
Elements elements;
elements.reserve(children_.size());
for (auto& it : children_) {
@@ -182,7 +182,7 @@ class HorizontalContainer : public ContainerBase {
public:
using ContainerBase::ContainerBase;
Element Render() override {
Element OnRender() override {
Elements elements;
elements.reserve(children_.size());
for (auto& it : children_) {
@@ -218,7 +218,7 @@ class TabContainer : public ContainerBase {
public:
using ContainerBase::ContainerBase;
Element Render() override {
Element OnRender() override {
const Component active_child = ActiveChild();
if (active_child) {
return active_child->Render();
@@ -244,7 +244,7 @@ class StackedContainer : public ContainerBase {
: ContainerBase(std::move(children), nullptr) {}
private:
Element Render() final {
Element OnRender() final {
Elements elements;
for (auto& child : children_) {
elements.push_back(child->Render());
@@ -334,7 +334,7 @@ Component Vertical(Components children) {
/// children_2,
/// children_3,
/// children_4,
/// });
/// }, &selected_children);
/// ```
Component Vertical(Components children, int* selector) {
return std::make_shared<VerticalContainer>(std::move(children), selector);
@@ -355,7 +355,7 @@ Component Vertical(Components children, int* selector) {
/// children_2,
/// children_3,
/// children_4,
/// }, &selected_children);
/// });
/// ```
Component Horizontal(Components children) {
return Horizontal(std::move(children), nullptr);