25class CaptureMouseImpl :
public CapturedMouseInterface {};
58 child->parent_ =
this;
67 if (parent_ ==
nullptr) {
70 auto it = std::find_if(std::begin(parent_->
children_),
73 return this == that.get();
97 return text(
"Not implemented component");
108 if (child->OnEvent(event)) {
121 child->OnAnimation(params);
130 if (child->Focusable()) {
143 if (child->Focusable()) {
153 return parent_ ==
nullptr || parent_->
ActiveChild().get() ==
this;
162 const auto* current =
this;
163 while (current && current->Active()) {
164 current = current->parent_;
197 return event.screen_->CaptureMouse();
199 return std::make_unique<CaptureMouseImpl>();
It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ft...
virtual bool Focusable() const
Return true when the component contains focusable elements. The non focusable Components will be skip...
bool Focused() const
Returns if the elements if focused by the user. True when the ComponentBase is focused by the user....
CapturedMouse CaptureMouse(const Event &event)
Take the CapturedMouse if available. There is only one component of them. It represents a component t...
void Add(Component children)
Add a child. @param child The child to be attached.
virtual Element Render()
Draw the component. Build a ftxui::Element to be drawn on the ftxi::Screen representing this ftxui::C...
void TakeFocus()
Configure all the ancestors to give focus to this component.
bool Active() const
Returns if the element if the currently active child of its parent.
virtual Component ActiveChild()
Return the currently Active child.
void DetachAllChildren()
Remove all children.
virtual void SetActiveChild(ComponentBase *child)
Make the |child| to be the "active" one.
size_t ChildCount() const
Returns the number of children.
ComponentBase * Parent() const
Return the parent ComponentBase, or nul if any.
virtual bool OnEvent(Event)
Called in response to an event.
void Detach()
Detach this child from its parent.
Component & ChildAt(size_t i)
Access the child at index i.
virtual void OnAnimation(animation::Params ¶ms)
Called in response to an animation event.
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::shared_ptr< Node > Element
std::shared_ptr< ComponentBase > Component
Element text(std::wstring text)
Display a piece of unicode text.
Represent an event. It can be key press event, a terminal resize, or more ...
ScreenInteractive * screen_