mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-23 03:10:01 +08:00
Handle empty container.
This commit is contained in:
parent
620f70c3e5
commit
a366c9b9e2
@ -38,6 +38,8 @@ bool Container::OnEvent(Event event) {
|
||||
}
|
||||
|
||||
Component* Container::ActiveChild() {
|
||||
if (children_.size() == 0)
|
||||
return nullptr;
|
||||
return children_[*selector_ % children_.size()];
|
||||
}
|
||||
|
||||
@ -91,6 +93,8 @@ Element Container::VerticalRender() {
|
||||
Elements elements;
|
||||
for(auto& it : children_)
|
||||
elements.push_back(it->Render());
|
||||
if (elements.size() == 0)
|
||||
return text(L"Empty container");
|
||||
return vbox(std::move(elements));
|
||||
}
|
||||
|
||||
@ -98,11 +102,16 @@ Element Container::HorizontalRender() {
|
||||
Elements elements;
|
||||
for(auto& it : children_)
|
||||
elements.push_back(it->Render());
|
||||
if (elements.size() == 0)
|
||||
return text(L"Empty container");
|
||||
return hbox(std::move(elements));
|
||||
}
|
||||
|
||||
Element Container::TabRender() {
|
||||
return ActiveChild()->Render();
|
||||
Component* active_child = ActiveChild();
|
||||
if (active_child)
|
||||
return active_child->Render();
|
||||
return text(L"Empty container");
|
||||
}
|
||||
|
||||
} // namespace ftxui
|
||||
|
Loading…
Reference in New Issue
Block a user