mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-01 12:49:54 +08:00
Allows components to remove a child by index.
This commit is contained in:

committed by
ArthurSonzogni

parent
9b7ddb1130
commit
2c087f1832
@@ -29,7 +29,7 @@ class ComponentBase {
|
||||
// ComponentBase hierarchy.
|
||||
ComponentBase* Parent();
|
||||
void Add(Component children);
|
||||
|
||||
void Remove(std::size_t idx);
|
||||
// Renders the component.
|
||||
virtual Element Render();
|
||||
|
||||
|
@@ -41,6 +41,13 @@ void ComponentBase::Add(Component child) {
|
||||
children_.push_back(std::move(child));
|
||||
}
|
||||
|
||||
/// @brief Remove a child.
|
||||
/// @@param idx The child index to be removed.
|
||||
/// @ingroup component
|
||||
void ComponentBase::Remove(std::size_t idx) {
|
||||
children_.erase(children_.begin()+idx);
|
||||
}
|
||||
|
||||
/// @brief Draw the component.
|
||||
/// Build a ftxui::Element to be drawn on the ftxi::Screen representing this
|
||||
/// ftxui::ComponentBase.
|
||||
|
Reference in New Issue
Block a user