Loading...
Searching...
No Matches
ComponentBase Class Reference

It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ftxui::Event. More...

## Public Member Functions

| ComponentBase (Components children)
virtual | ~ComponentBase ()
| ComponentBase ()=default
| ComponentBase (const ComponentBase &)=delete
| ComponentBase (ComponentBase &&)=delete
ComponentBase & | operator= (const ComponentBase &)=delete
ComponentBase & | operator= (ComponentBase &&)=delete
ComponentBase * | Parent () const
| Return the parent ComponentBase, or nul if any.
Component & | ChildAt (size_t i)
| Access the child at index i.
size_t | ChildCount () const
| Returns the number of children.
int | Index () const
| Return index of the component in its parent. -1 if no parent.
void | Add (Component children)
| Add a child. @param child The child to be attached.
void | Detach ()
| Detach this child from its parent.
void | DetachAllChildren ()
| Remove all children.
Element | Render ()
| Draw the component. Build a ftxui::Element to be drawn on the ftxui::Screen representing this ftxui::ComponentBase. Please override OnRender() to modify the rendering.
virtual Element | OnRender ()
| Draw the component. Build a ftxui::Element to be drawn on the ftxi::Screen representing this ftxui::ComponentBase. This function is means to be overridden.
virtual bool | OnEvent (Event)
| Called in response to an event.
virtual void | OnAnimation (animation::Params &params)
| Called in response to an animation event.
virtual Component | ActiveChild ()
| Return the currently Active child.
virtual bool | Focusable () const
| Return true when the component contains focusable elements. The non focusable Components will be skipped when navigating using the keyboard.
bool | Active () const
| Returns if the element if the currently active child of its parent.
bool | Focused () const
| Returns if the elements if focused by the user. True when the ComponentBase is focused by the user. An element is Focused when it is with all its ancestors the ActiveChild() of their parents, and it Focusable().
virtual void | SetActiveChild (ComponentBase *child)
| Make the |child| to be the "active" one.
void | SetActiveChild (Component child)
| Make the |child| to be the "active" one.
void | TakeFocus ()
| Configure all the ancestors to give focus to this component.

## Protected Member Functions

CapturedMouse | CaptureMouse (const Event &event)
| Take the CapturedMouse if available. There is only one component of them. It represents a component taking priority over others.

## Protected Attributes

Components | children_

## Detailed Description

It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ftxui::Event.

Examples
  examples/component/scrollbar.cpp, and examples/component/window.cpp.

Definition at line 30 of file component_base.hpp.

## Constructor & Destructor Documentation

## ComponentBase() [1/4]

ComponentBase | ( | Components | children | ) |

inline explicit

Definition at line 32 of file component_base.hpp.

## ~ComponentBase()

~ComponentBase | ( |  | ) |

virtual

Definition at line 31 of file component.cpp.

## ComponentBase() [2/4]

ComponentBase | ( |  | ) |

default

## ComponentBase() [3/4]

ComponentBase | ( | const ComponentBase & |  | ) |

delete

## ComponentBase() [4/4]

ComponentBase | ( | ComponentBase && |  | ) |

delete

## Member Function Documentation

## operator=() [1/2]

ComponentBase & operator= | ( | const ComponentBase & |  | ) |

delete

## operator=() [2/2]

ComponentBase & operator= | ( | ComponentBase && |  | ) |

delete

## Parent()

ComponentBase * Parent | ( |  | ) | const

Return the parent ComponentBase, or nul if any.

See also
  Detach
  Parent

Definition at line 39 of file component.cpp.

## ChildAt()

Component & ChildAt | ( | size_t | i | ) |

Access the child at index i.

Definition at line 45 of file component.cpp.

## ChildCount()

size_t ChildCount | ( |  | ) | const

Returns the number of children.

Definition at line 52 of file component.cpp.

## Index()

int Index | ( |  | ) | const

Return index of the component in its parent. -1 if no parent.

Definition at line 58 of file component.cpp.

## Add()

void Add | ( | Component | children | ) |

Add a child. @param child The child to be attached.

Definition at line 75 of file component.cpp.

## Detach()

void Detach | ( |  | ) |

Detach this child from its parent.

See also
  Detach
  Parent

Definition at line 85 of file component.cpp.

## DetachAllChildren()

void DetachAllChildren | ( |  | ) |

Remove all children.

Definition at line 101 of file component.cpp.

## Render()

Element Render | ( |  | ) |

Draw the component. Build a ftxui::Element to be drawn on the ftxui::Screen representing this ftxui::ComponentBase. Please override OnRender() to modify the rendering.

Definition at line 111 of file component.cpp.

## OnRender()

Element OnRender | ( |  | ) |

virtual

Draw the component. Build a ftxui::Element to be drawn on the ftxi::Screen representing this ftxui::ComponentBase. This function is means to be overridden.

Definition at line 147 of file component.cpp.

## OnEvent()

bool OnEvent | ( | Event | event | ) |

virtual

Called in response to an event.

Parameters

  event | The event.

Returns
  True when the event has been handled. The default implementation called OnEvent on every child until one return true. If none returns true, return false.

Definition at line 161 of file component.cpp.

## OnAnimation()

void OnAnimation | ( | animation::Params & | params | ) |

virtual

Called in response to an animation event.

Parameters

  params | the parameters of the animation The default implementation dispatch the event to every child.

Definition at line 174 of file component.cpp.

## ActiveChild()

Component ActiveChild | ( |  | ) |

virtual

Return the currently Active child.

Returns
  the currently Active child.

Definition at line 183 of file component.cpp.

## Focusable()

bool Focusable | ( |  | ) | const

virtual

Return true when the component contains focusable elements. The non focusable Components will be skipped when navigating using the keyboard.

Definition at line 196 of file component.cpp.

## Active()

bool Active | ( |  | ) | const

Returns if the element if the currently active child of its parent.

Definition at line 207 of file component.cpp.

## Focused()

bool Focused | ( |  | ) | const

Returns if the elements if focused by the user. True when the ComponentBase is focused by the user. An element is Focused when it is with all its ancestors the ActiveChild() of their parents, and it Focusable().

Definition at line 216 of file component.cpp.

## SetActiveChild() [1/2]

void SetActiveChild | ( | ComponentBase * | child | ) |

virtual

Make the |child| to be the "active" one.

Parameters

  child | the child to become active.

Definition at line 227 of file component.cpp.

## SetActiveChild() [2/2]

void SetActiveChild | ( | Component | child | ) |

Make the |child| to be the "active" one.

Parameters

  child | the child to become active.

Definition at line 232 of file component.cpp.

## TakeFocus()

void TakeFocus | ( |  | ) |

Configure all the ancestors to give focus to this component.

Definition at line 238 of file component.cpp.

## CaptureMouse()

CapturedMouse CaptureMouse | ( | const Event & | event | ) |

protected

Take the CapturedMouse if available. There is only one component of them. It represents a component taking priority over others.

Parameters

  event | The event

Definition at line 250 of file component.cpp.

## Field Documentation

## children_

Components children_

protected

Definition at line 96 of file component_base.hpp.

The documentation for this class was generated from the following files:

- include/ftxui/component/component_base.hpp
- src/ftxui/component/component.cpp