mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-04 06:14:36 +08:00
Exposed components begin/end
Allows iteration over a components children. Updated Remove function to conform to vector::erase
This commit is contained in:

committed by
ArthurSonzogni

parent
2c087f1832
commit
95feb62442
@@ -29,10 +29,14 @@ class ComponentBase {
|
||||
// ComponentBase hierarchy.
|
||||
ComponentBase* Parent();
|
||||
void Add(Component children);
|
||||
void Remove(std::size_t idx);
|
||||
void Remove(Components::iterator child);
|
||||
// Renders the component.
|
||||
virtual Element Render();
|
||||
|
||||
// Iterate over component children
|
||||
Components::iterator begin();
|
||||
Components::iterator end();
|
||||
|
||||
// Handles an event.
|
||||
// By default, reduce on children with a lazy OR.
|
||||
//
|
||||
|
@@ -44,10 +44,24 @@ void ComponentBase::Add(Component 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);
|
||||
void ComponentBase::Remove(Components::iterator child) {
|
||||
children_.erase(child);
|
||||
}
|
||||
|
||||
/// @brief Obtain an iterator to the first child
|
||||
/// @ingroup component
|
||||
Components::iterator ComponentBase::begin() {
|
||||
return children_.begin();
|
||||
}
|
||||
|
||||
/// @brief Obtain an iterator to one after the last child
|
||||
/// @ingroup component
|
||||
Components::iterator ComponentBase::end() {
|
||||
return children_.end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @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