28class CaptureMouseImpl :
public CapturedMouseInterface {};
55 if (parent_ ==
nullptr) {
60 if (child.get() ==
this) {
72 child->parent_ =
this;
80 if (parent_ ==
nullptr) {
83 auto it = std::find_if(std::begin(parent_->
children_),
86 return this == that.get();
114 class Wrapper :
public Node {
116 bool active_ =
false;
118 Wrapper(
Element child,
bool active)
119 :
Node({std::move(child)}), active_(active) {}
121 void SetBox(
Box box)
override {
123 children_[0]->SetBox(box);
126 void ComputeRequirement()
override {
127 Node::ComputeRequirement();
128 requirement_.focused.component_active = active_;
132 return std::make_shared<Wrapper>(std::move(element),
Active());
143 return text(
"Componente no implementado");
153 if (child->OnEvent(event)) {
165 child->OnAnimation(params);
173 if (child->Focusable()) {
185 if (child->Focusable()) {
194 return parent_ ==
nullptr || parent_->
ActiveChild().get() ==
this;
202 const auto* current =
this;
203 while (current && current->Active()) {
204 current = current->parent_;
223 parent->SetActiveChild(child);
233 return event.screen_->CaptureMouse();
235 return std::make_unique<CaptureMouseImpl>();
virtual bool Focusable() const
Devuelve verdadero cuando el componente contiene elementos enfocables. Los componentes no enfocables ...
bool Focused() const
Devuelve si el elemento está enfocado por el usuario. Verdadero cuando el ComponentBase está enfocado...
CapturedMouse CaptureMouse(const Event &event)
Toma el CapturedMouse si está disponible. Solo hay un componente de ellos. Representa un componente q...
void Add(Component children)
Agrega un hijo. @param child El hijo a adjuntar.
Element Render()
Dibuja el componente. Construye un ftxui::Element para ser dibujado en la ftxui::Screen representando...
void TakeFocus()
Configura todos los ancestros para dar foco a este componente.
bool Active() const
Devuelve si el elemento es el hijo actualmente activo de su padre.
ScreenInteractive * screen_
virtual Component ActiveChild()
Devuelve el hijo actualmente activo.
void DetachAllChildren()
Elimina todos los hijos.
virtual void SetActiveChild(ComponentBase *child)
Hace que |child| sea el activo.
int Index() const
Devuelve el índice del componente en su padre. -1 si no tiene padre.
size_t ChildCount() const
Devuelve el número de hijos.
ComponentBase * Parent() const
Devuelve el ComponentBase padre, o nulo si no tiene.
virtual Element OnRender()
Dibuja el componente. Construye un ftxui::Element para ser dibujado en la ftxui::Screen representando...
virtual bool OnEvent(Event)
Llamado en respuesta a un evento.
void Detach()
Desvincula este hijo de su padre.
Component & ChildAt(size_t i)
Accede al hijo en el índice i.
virtual void OnAnimation(animation::Params ¶ms)
Llamado en respuesta a un evento de animación.
Implementa el renderizado de sí mismo como ftxui::Element. Implementa la navegación por teclado respo...
Representa un evento. Puede ser un evento de pulsación de tecla, un redimensionamiento de terminal,...
Node es la clase base para todos los elementos en el árbol DOM.
Element text(std::wstring text)
Muestra un fragmento de texto Unicode.
Box es una estructura que representa un área rectangular en un espacio 2D.
El espacio de nombres ftxui::animation:: de FTXUI.
El espacio de nombres ftxui:: de FTXUI.
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::shared_ptr< Node > Element
std::shared_ptr< ComponentBase > Component