Improve documentation (#1058)

* Remove @ingroup from class member definitions
* Add the documentation for every public classes.
This commit is contained in:
Arthur Sonzogni 2025-06-05 11:35:14 +02:00 committed by GitHub
parent a86d8f32d7
commit 14da21b0ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 177 additions and 143 deletions

View File

@ -8,11 +8,21 @@
#include <functional> // for function
namespace ftxui::animation {
// Components who haven't completed their animation can call this function to
// request a new frame to be drawn later.
//
// When there is no new events and no animations to complete, no new frame is
// drawn.
/// @brief RequestAnimationFrame is a function that requests a new frame to be
/// drawn in the next animation cycle.
///
/// @note This function is typically called by components that need to
/// update their state or appearance over time, such as animations or
/// transitions. This is useful when the change doesn't depend depend on the
/// events seen by the terminal, but rather on the passage of time.
///
/// Components who haven't completed their animation can call this function to
/// request a new frame to be drawn later.
///
/// When there is no new events and no animations to complete, no new frame is
/// drawn.
///
/// @ingroup component
void RequestAnimationFrame();
using Clock = std::chrono::steady_clock;

View File

@ -7,6 +7,7 @@
#include <memory>
namespace ftxui {
class CapturedMouseInterface {
public:
CapturedMouseInterface() = default;

View File

@ -27,6 +27,8 @@ struct EntryState {
int index; ///< Index of the entry when applicable or -1.
};
/// @brief Option for the underline effect.
/// @ingroup component
struct UnderlineOption {
bool enabled = false;
@ -230,7 +232,8 @@ struct SliderOption {
std::function<void()> on_change; ///> Called when `value` is updated.
};
// Parameter pack used by `WindowOptions::render`.
/// @brief State passed to the `Window` component's render function.
/// @ingroup component
struct WindowRenderState {
Element inner; ///< The element wrapped inside this window.
const std::string& title; ///< The title of the window.

View File

@ -24,6 +24,8 @@ class ComponentBase;
///
/// Useful documentation about xterm specification:
/// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
///
/// @ingroup component
struct Event {
// --- Constructor section ---------------------------------------------------
static Event Character(std::string);

View File

@ -14,6 +14,45 @@ class ComponentBase;
using Component = std::shared_ptr<ComponentBase>;
class ScreenInteractive;
/// @brief Loop is a class that manages the event loop for a component.
///
/// It is responsible for running the component, handling events, and
/// updating the screen.
///
/// The Loop class is designed to be used with a ScreenInteractive object,
/// which represents the terminal screen.
///
/// **Example**
/// ```cpp
/// #include <ftxui/component/component.hpp>
/// #include <ftxui/component/screen_interactive.hpp>
/// #include <ftxui/component/loop.hpp>
///
/// int main() {
/// auto screen = ftxui::ScreenInteractive::TerminalOutput();
/// auto component = ftxui::Button("Click me", [] { ... });
///
/// ftxui::Loop loop(screen.get(), component);
///
/// // Either
/// loop.Run(); // Blocking until the component quits.
///
/// // Or
/// loop.RunOnce(); // Non-blocking, returns immediately.
///
/// // Or
/// loop.RunOnceBlocking(); // Blocking until handling one event.
///
/// // Or in a loop:
/// while (!loop.HasQuitted()) {
/// loop.RunOnce();
///
/// // Do something else like running a different library loop function.
/// }
/// }
/// ```
///
/// @ingroup component
class Loop {
public:
Loop(ScreenInteractive* screen, Component component);

View File

@ -27,6 +27,10 @@ struct Event;
using Component = std::shared_ptr<ComponentBase>;
class ScreenInteractivePrivate;
/// @brief ScreenInteractive is a `Screen` that can handle events, run a main
/// loop, and manage components.
///
/// @ingroup component
class ScreenInteractive : public Screen {
public:
// Constructors:

View File

@ -20,6 +20,21 @@
namespace ftxui {
/// @brief Canvas is a drawable buffer associated with drawing operations.
///
/// Canvas is a drawable area that can be used to create complex graphics. It
/// supports drawing points, lines, circles, ellipses, text, and images using
/// braille, block, or normal characters.
///
/// Note: A terminal contains cells. A cells is a unit of:
/// - 2x4 braille characters (1x1 pixel)
/// - 2x2 block characters (2x2 pixels)
/// - 2x4 normal characters (2x4 pixels)
///
/// You need to multiply the x coordinate by 2 and the y coordinate by 4 to
/// get the correct position in the terminal.
///
/// @ingroup dom
struct Canvas {
public:
Canvas() = default;

View File

@ -5,6 +5,11 @@
#define FTXUI_DOM_DIRECTION_HPP
namespace ftxui {
/// @brief Direction is an enumeration that represents the four cardinal
/// directions.
///
/// @ingroup dom
enum class Direction {
Up = 0,
Down = 1,

View File

@ -24,6 +24,14 @@ using Elements = std::vector<Element>;
using Decorator = std::function<Element(Element)>;
using GraphFunction = std::function<std::vector<int>(int, int)>;
/// @brief BorderStyle is an enumeration that represents the different styles
/// of borders that can be applied to elements in the terminal UI.
///
/// BorderStyle is an enumeration that represents the different styles of
/// borders that can be applied to elements in the terminal UI.
/// It is used to define the visual appearance of borders around elements,
/// such as windows, frames, or separators.
/// @ingroup dom
enum BorderStyle {
LIGHT,
DASHED,

View File

@ -12,6 +12,19 @@
namespace ftxui {
/// @brief FlexboxConfig is a configuration structure that defines the layout
/// properties for a flexbox container.
//
/// It allows you to specify the direction of the flex items, whether they
/// should wrap, how they should be justified along the main axis, and how
/// they should be aligned along the cross axis.
/// It also includes properties for gaps between flex items in both the
/// main and cross axes.
/// This structure is used to configure the layout behavior of flexbox
/// containers in a terminal user interface.
///
/// @ingroup dom
struct FlexboxConfig {
/// This establishes the main-axis, thus defining the direction flex items are
/// placed in the flex container. Flexbox is (aside wrapping) single-direction

View File

@ -27,8 +27,15 @@ namespace ftxui {
/// LinearGradient(Color::Red, Color::Blue);
/// LinearGradient(45, Color::Red, Color::Blue);
/// ```
///
/// @ingroup dom
struct LinearGradient {
float angle = 0.f;
/// A stop is a color at a specific position in the gradient.
/// The position is a value between 0.0 and 1.0,
/// where 0.0 is the start of the gradient
/// and 1.0 is the end of the gradient.
struct Stop {
Color color = Color::Default;
std::optional<float> position;

View File

@ -20,6 +20,20 @@ class Screen;
using Element = std::shared_ptr<Node>;
using Elements = std::vector<Element>;
/// @brief Node is the base class for all elements in the DOM tree.
///
/// It represents a single node in the document object model (DOM) and provides
/// the basic structure for layout and rendering.
/// It contains methods for computing layout requirements, setting the box
/// dimensions, selecting content, rendering to the screen, and checking the
/// layout status.
/// It typically contains child elements, which are also instances of Node.
///
/// Users are expected to derive from this class to create custom elements.
///
/// A list of builtin elements can be found in the `elements.hpp` file.
///
/// @ingroup dom
class Node {
public:
Node();

View File

@ -10,6 +10,11 @@
namespace ftxui {
class Node;
/// @brief Requirement is a structure that defines the layout requirements for a
/// Node in the terminal user interface.
///
/// It specifies the minimum size required to fully draw the element,
/// @ingroup dom
struct Requirement {
// The required size to fully draw the element.
int min_x = 0;

View File

@ -13,7 +13,12 @@
namespace ftxui {
/// @brief Represent a selection in the terminal.
/// @brief Represents a selection in a terminal user interface.
///
/// Selection is a class that represents the two endpoints of a selection in a
/// terminal user interface.
///
/// @ingroup dom
class Selection {
public:
Selection(); // Empty selection.

View File

@ -11,28 +11,28 @@
namespace ftxui {
// Usage:
//
// Initialization:
// ---------------
//
// auto table = Table({
// {"X", "Y"},
// {"-1", "1"},
// {"+0", "0"},
// {"+1", "1"},
// });
//
// table.SelectAll().Border(LIGHT);
//
// table.SelectRow(1).Border(DOUBLE);
// table.SelectRow(1).SeparatorInternal(Light);
//
// std::move(table).Element();
class Table;
class TableSelection;
/// @brief Table is a utility to draw tables.
///
/// **example**
/// ```cpp
/// auto table = Table({
/// {"X", "Y"},
/// {"-1", "1"},
/// {"+0", "0"},
/// {"+1", "1"},
/// });
///
/// table.SelectAll().Border(LIGHT);
/// table.SelectRow(1).Border(DOUBLE);
/// table.SelectRow(1).SeparatorInternal(LIGHT);
///
/// std::move(table).Render();
/// ```
///
/// @ingroup dom
class Table {
public:
Table();

View File

@ -6,6 +6,13 @@
namespace ftxui {
/// @brief Box is a structure that represents a rectangular area in a 2D space.
///
/// It is defined by its minimum and maximum coordinates along the x and y axes.
/// Note that the coordinates are inclusive, meaning that the box includes both
/// the minimum and maximum values.
///
/// @ingroup screen
struct Box {
int x_min = 0;
int x_max = 0;

View File

@ -15,7 +15,9 @@
namespace ftxui {
/// @brief A class representing terminal colors.
/// @brief Color is a class that represents a color in the terminal user
/// interface.
///
/// @ingroup screen
class Color {
public:

View File

@ -9,6 +9,10 @@
namespace ftxui {
/// @brief ColorInfo is a structure that contains information about the terminal
/// color palette.
///
/// @ingroup screen
struct ColorInfo {
const char* name;
uint8_t index_256;

View File

@ -5,6 +5,9 @@
#define FTXUI_SCREEN_TERMINAL_HPP
namespace ftxui {
/// @brief Dimensions is a structure that represents the size of the terminal
/// @ingroup screen
struct Dimensions {
int dimx;
int dimy;
@ -14,6 +17,9 @@ namespace Terminal {
Dimensions Size();
void SetFallbackSize(const Dimensions& fallbackSize);
/// @brief Color is an enumeration that represents the color support of the
/// terminal.
/// @ingroup screen
enum Color {
Palette1,
Palette16,

View File

@ -35,26 +35,22 @@ ComponentBase::~ComponentBase() {
/// @brief Return the parent ComponentBase, or nul if any.
/// @see Detach
/// @see Parent
/// @ingroup component
ComponentBase* ComponentBase::Parent() const {
return parent_;
}
/// @brief Access the child at index `i`.
/// @ingroup component
Component& ComponentBase::ChildAt(size_t i) {
assert(i < ChildCount()); // NOLINT
return children_[i];
}
/// @brief Returns the number of children.
/// @ingroup component
size_t ComponentBase::ChildCount() const {
return children_.size();
}
/// @brief Return index of the component in its parent. -1 if no parent.
/// @ingroup component
int ComponentBase::Index() const {
if (parent_ == nullptr) {
return -1;
@ -71,7 +67,6 @@ int ComponentBase::Index() const {
/// @brief Add a child.
/// @@param child The child to be attached.
/// @ingroup component
void ComponentBase::Add(Component child) {
child->Detach();
child->parent_ = this;
@ -81,7 +76,6 @@ void ComponentBase::Add(Component child) {
/// @brief Detach this child from its parent.
/// @see Detach
/// @see Parent
/// @ingroup component
void ComponentBase::Detach() {
if (parent_ == nullptr) {
return;
@ -97,7 +91,6 @@ void ComponentBase::Detach() {
}
/// @brief Remove all children.
/// @ingroup component
void ComponentBase::DetachAllChildren() {
while (!children_.empty()) {
children_[0]->Detach();
@ -107,7 +100,6 @@ void ComponentBase::DetachAllChildren() {
/// @brief 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.
/// @ingroup component
Element ComponentBase::Render() {
// Some users might call `ComponentBase::Render()` from
// `T::OnRender()`. To avoid infinite recursion, we use a flag.
@ -143,7 +135,6 @@ Element ComponentBase::Render() {
/// @brief 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.
/// @ingroup component
Element ComponentBase::OnRender() {
if (children_.size() == 1) {
return children_.front()->Render();
@ -157,7 +148,6 @@ Element ComponentBase::OnRender() {
/// @return 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.
/// @ingroup component
bool ComponentBase::OnEvent(Event event) { // NOLINT
for (Component& child : children_) { // NOLINT
if (child->OnEvent(event)) {
@ -170,7 +160,6 @@ bool ComponentBase::OnEvent(Event event) { // NOLINT
/// @brief Called in response to an animation event.
/// @param params the parameters of the animation
/// The default implementation dispatch the event to every child.
/// @ingroup component
void ComponentBase::OnAnimation(animation::Params& params) {
for (const Component& child : children_) {
child->OnAnimation(params);
@ -179,7 +168,6 @@ void ComponentBase::OnAnimation(animation::Params& params) {
/// @brief Return the currently Active child.
/// @return the currently Active child.
/// @ingroup component
Component ComponentBase::ActiveChild() {
for (auto& child : children_) {
if (child->Focusable()) {
@ -192,7 +180,6 @@ Component ComponentBase::ActiveChild() {
/// @brief Return true when the component contains focusable elements.
/// The non focusable Components will be skipped when navigating using the
/// keyboard.
/// @ingroup component
bool ComponentBase::Focusable() const {
for (const Component& child : children_) { // NOLINT
if (child->Focusable()) {
@ -203,7 +190,6 @@ bool ComponentBase::Focusable() const {
}
/// @brief Returns if the element if the currently active child of its parent.
/// @ingroup component
bool ComponentBase::Active() const {
return parent_ == nullptr || parent_->ActiveChild().get() == this;
}
@ -212,7 +198,6 @@ bool ComponentBase::Active() const {
/// 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().
/// @ingroup component
bool ComponentBase::Focused() const {
const auto* current = this;
while (current && current->Active()) {
@ -223,18 +208,15 @@ bool ComponentBase::Focused() const {
/// @brief Make the |child| to be the "active" one.
/// @param child the child to become active.
/// @ingroup component
void ComponentBase::SetActiveChild([[maybe_unused]] ComponentBase* child) {}
/// @brief Make the |child| to be the "active" one.
/// @param child the child to become active.
/// @ingroup component
void ComponentBase::SetActiveChild(Component child) { // NOLINT
SetActiveChild(child.get());
}
/// @brief Configure all the ancestors to give focus to this component.
/// @ingroup component
void ComponentBase::TakeFocus() {
ComponentBase* child = this;
while (ComponentBase* parent = child->parent_) {
@ -246,7 +228,6 @@ void ComponentBase::TakeFocus() {
/// @brief Take the CapturedMouse if available. There is only one component of
/// them. It represents a component taking priority over others.
/// @param event The event
/// @ingroup component
CapturedMouse ComponentBase::CaptureMouse(const Event& event) { // NOLINT
if (event.screen_) {
return event.screen_->CaptureMouse();

View File

@ -17,7 +17,6 @@ namespace ftxui {
/// @params _active The color when the component is active.
/// @params _duration The duration of the animation.
/// @params _function The easing function of the animation.
/// @ingroup component
void AnimatedColorOption::Set(Color _inactive,
Color _active,
animation::Duration _duration,
@ -32,7 +31,6 @@ void AnimatedColorOption::Set(Color _inactive,
/// @brief Set how the underline should animate.
/// @param d The duration of the animation.
/// @param f The easing function of the animation.
/// @ingroup component
void UnderlineOption::SetAnimation(animation::Duration d,
animation::easing::Function f) {
SetAnimationDuration(d);
@ -41,7 +39,6 @@ void UnderlineOption::SetAnimation(animation::Duration d,
/// @brief Set how the underline should animate.
/// @param d The duration of the animation.
/// @ingroup component
void UnderlineOption::SetAnimationDuration(animation::Duration d) {
leader_duration = d;
follower_duration = d;
@ -49,7 +46,6 @@ void UnderlineOption::SetAnimationDuration(animation::Duration d) {
/// @brief Set how the underline should animate.
/// @param f The easing function of the animation.
/// @ingroup component
void UnderlineOption::SetAnimationFunction(animation::easing::Function f) {
leader_function = f;
follower_function = std::move(f);
@ -60,7 +56,6 @@ void UnderlineOption::SetAnimationFunction(animation::easing::Function f) {
/// follower.
/// @param f_leader The duration of the animation for the leader.
/// @param f_follower The duration of the animation for the follower.
/// @ingroup component
void UnderlineOption::SetAnimationFunction(
animation::easing::Function f_leader,
animation::easing::Function f_follower) {
@ -70,7 +65,6 @@ void UnderlineOption::SetAnimationFunction(
/// @brief Standard options for a horizontal menu.
/// This can be useful to implement a tab bar.
/// @ingroup component
// static
MenuOption MenuOption::Horizontal() {
MenuOption option;
@ -95,7 +89,6 @@ MenuOption MenuOption::Horizontal() {
/// @brief Standard options for an animated horizontal menu.
/// This can be useful to implement a tab bar.
/// @ingroup component
// static
MenuOption MenuOption::HorizontalAnimated() {
auto option = Horizontal();
@ -105,7 +98,6 @@ MenuOption MenuOption::HorizontalAnimated() {
/// @brief Standard options for a vertical menu.
/// This can be useful to implement a list of selectable items.
/// @ingroup component
// static
MenuOption MenuOption::Vertical() {
MenuOption option;
@ -127,7 +119,6 @@ MenuOption MenuOption::Vertical() {
/// @brief Standard options for an animated vertical menu.
/// This can be useful to implement a list of selectable items.
/// @ingroup component
// static
MenuOption MenuOption::VerticalAnimated() {
auto option = MenuOption::Vertical();
@ -150,7 +141,6 @@ MenuOption MenuOption::VerticalAnimated() {
/// @brief Standard options for a horizontal menu with some separator.
/// This can be useful to implement a tab bar.
/// @ingroup component
// static
MenuOption MenuOption::Toggle() {
auto option = MenuOption::Horizontal();
@ -159,7 +149,6 @@ MenuOption MenuOption::Toggle() {
}
/// @brief Create a ButtonOption, highlighted using [] characters.
/// @ingroup component
// static
ButtonOption ButtonOption::Ascii() {
ButtonOption option;
@ -172,7 +161,6 @@ ButtonOption ButtonOption::Ascii() {
}
/// @brief Create a ButtonOption, inverted when focused.
/// @ingroup component
// static
ButtonOption ButtonOption::Simple() {
ButtonOption option;
@ -188,7 +176,6 @@ ButtonOption ButtonOption::Simple() {
/// @brief Create a ButtonOption. The button is shown using a border, inverted
/// when focused. This is the current default.
/// @ingroup component
ButtonOption ButtonOption::Border() {
ButtonOption option;
option.transform = [](const EntryState& s) {
@ -205,7 +192,6 @@ ButtonOption ButtonOption::Border() {
}
/// @brief Create a ButtonOption, using animated colors.
/// @ingroup component
// static
ButtonOption ButtonOption::Animated() {
return Animated(Color::Black, Color::GrayLight, //
@ -213,7 +199,6 @@ ButtonOption ButtonOption::Animated() {
}
/// @brief Create a ButtonOption, using animated colors.
/// @ingroup component
// static
ButtonOption ButtonOption::Animated(Color color) {
return ButtonOption::Animated(
@ -224,7 +209,6 @@ ButtonOption ButtonOption::Animated(Color color) {
}
/// @brief Create a ButtonOption, using animated colors.
/// @ingroup component
// static
ButtonOption ButtonOption::Animated(Color background, Color foreground) {
// NOLINTBEGIN
@ -237,7 +221,6 @@ ButtonOption ButtonOption::Animated(Color background, Color foreground) {
}
/// @brief Create a ButtonOption, using animated colors.
/// @ingroup component
// static
ButtonOption ButtonOption::Animated(Color background,
Color foreground,
@ -257,7 +240,6 @@ ButtonOption ButtonOption::Animated(Color background,
}
/// @brief Option for standard Checkbox.
/// @ingroup component
// static
CheckboxOption CheckboxOption::Simple() {
auto option = CheckboxOption();
@ -282,7 +264,6 @@ CheckboxOption CheckboxOption::Simple() {
}
/// @brief Option for standard Radiobox
/// @ingroup component
// static
RadioboxOption RadioboxOption::Simple() {
auto option = RadioboxOption();
@ -307,7 +288,6 @@ RadioboxOption RadioboxOption::Simple() {
}
/// @brief Standard options for the input component.
/// @ingroup component
// static
InputOption InputOption::Default() {
InputOption option;
@ -330,7 +310,6 @@ InputOption InputOption::Default() {
}
/// @brief Standard options for a more beautiful input component.
/// @ingroup component
// static
InputOption InputOption::Spacious() {
InputOption option;

View File

@ -24,7 +24,6 @@ namespace ftxui {
/// @brief An event corresponding to a given typed character.
/// @param input The character typed by the user.
/// @ingroup component
// static
Event Event::Character(std::string input) {
Event event;
@ -35,7 +34,6 @@ Event Event::Character(std::string input) {
/// @brief An event corresponding to a given typed character.
/// @param c The character typed by the user.
/// @ingroup component
// static
Event Event::Character(char c) {
return Event::Character(std::string{c});
@ -43,7 +41,6 @@ Event Event::Character(char c) {
/// @brief An event corresponding to a given typed character.
/// @param c The character typed by the user.
/// @ingroup component
// static
Event Event::Character(wchar_t c) {
return Event::Character(to_string(std::wstring{c}));
@ -52,7 +49,6 @@ Event Event::Character(wchar_t c) {
/// @brief An event corresponding to a given typed character.
/// @param input The sequence of character send by the terminal.
/// @param mouse The mouse state.
/// @ingroup component
// static
Event Event::Mouse(std::string input, struct Mouse mouse) {
Event event;
@ -74,7 +70,6 @@ Event Event::CursorShape(std::string input, int shape) {
/// @brief An custom event whose meaning is defined by the user of the library.
/// @param input An arbitrary sequence of character defined by the developer.
/// @ingroup component
// static
Event Event::Special(std::string input) {
Event event;

View File

@ -11,7 +11,6 @@ namespace ftxui {
/// @brief A Loop is a wrapper around a Component and a ScreenInteractive.
/// It is used to run a Component in a terminal.
/// @ingroup component
/// @see Component, ScreenInteractive.
/// @see ScreenInteractive::Loop().
/// @see ScreenInteractive::ExitLoop().
@ -28,7 +27,6 @@ Loop::~Loop() {
}
/// @brief Whether the loop has quitted.
/// @ingroup component
bool Loop::HasQuitted() {
return screen_->HasQuitted();
}

View File

@ -366,7 +366,6 @@ ScreenInteractive ScreenInteractive::FixedSize(int dimx, int dimy) {
};
}
/// @ingroup component
/// Create a ScreenInteractive taking the full terminal size. This is using the
/// alternate screen buffer to avoid messing with the terminal content.
/// @note This is the same as `ScreenInteractive::FullscreenAlternateScreen()`
@ -375,7 +374,6 @@ ScreenInteractive ScreenInteractive::Fullscreen() {
return FullscreenAlternateScreen();
}
/// @ingroup component
/// Create a ScreenInteractive taking the full terminal size. The primary screen
/// buffer is being used. It means if the terminal is resized, the previous
/// content might mess up with the terminal content.
@ -389,7 +387,6 @@ ScreenInteractive ScreenInteractive::FullscreenPrimaryScreen() {
};
}
/// @ingroup component
/// Create a ScreenInteractive taking the full terminal size. This is using the
/// alternate screen buffer to avoid messing with the terminal content.
// static
@ -422,7 +419,6 @@ ScreenInteractive ScreenInteractive::FitComponent() {
};
}
/// @ingroup component
/// @brief Set whether mouse is tracked and events reported.
/// called outside of the main loop. E.g `ScreenInteractive::Loop(...)`.
/// @param enable Whether to enable mouse event tracking.
@ -444,7 +440,6 @@ void ScreenInteractive::TrackMouse(bool enable) {
/// @brief Add a task to the main loop.
/// It will be executed later, after every other scheduled tasks.
/// @ingroup component
void ScreenInteractive::Post(Task task) {
// Task/Events sent toward inactive screen or screen waiting to become
// inactive are dropped.
@ -457,7 +452,6 @@ void ScreenInteractive::Post(Task task) {
/// @brief Add an event to the main loop.
/// It will be executed later, after every other scheduled events.
/// @ingroup component
void ScreenInteractive::PostEvent(Event event) {
Post(event);
}
@ -479,7 +473,6 @@ void ScreenInteractive::RequestAnimationFrame() {
/// @brief Try to get the unique lock about behing able to capture the mouse.
/// @return A unique lock if the mouse is not already captured, otherwise a
/// null.
/// @ingroup component
CapturedMouse ScreenInteractive::CaptureMouse() {
if (mouse_captured) {
return nullptr;
@ -491,14 +484,12 @@ CapturedMouse ScreenInteractive::CaptureMouse() {
/// @brief Execute the main loop.
/// @param component The component to draw.
/// @ingroup component
void ScreenInteractive::Loop(Component component) { // NOLINT
class Loop loop(this, std::move(component));
loop.Run();
}
/// @brief Return whether the main loop has been quit.
/// @ingroup component
bool ScreenInteractive::HasQuitted() {
return task_receiver_->HasQuitted();
}
@ -1022,13 +1013,11 @@ void ScreenInteractive::ResetCursorPosition() {
}
/// @brief Return a function to exit the main loop.
/// @ingroup component
Closure ScreenInteractive::ExitLoopClosure() {
return [this] { Exit(); };
}
/// @brief Exit the main loop.
/// @ingroup component
void ScreenInteractive::Exit() {
Post([this] { ExitNow(); });
}

View File

@ -6,42 +6,36 @@
namespace ftxui {
/// @brief Set the flexbox direction.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::Direction d) {
this->direction = d;
return *this;
}
/// @brief Set the flexbox wrap.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::Wrap w) {
this->wrap = w;
return *this;
}
/// @brief Set the flexbox justify content.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::JustifyContent j) {
this->justify_content = j;
return *this;
}
/// @brief Set the flexbox align items.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::AlignItems a) {
this->align_items = a;
return *this;
}
/// @brief Set the flexbox align content.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::Set(FlexboxConfig::AlignContent a) {
this->align_content = a;
return *this;
}
/// @brief Set the flexbox flex direction.
/// @ingroup dom
FlexboxConfig& FlexboxConfig::SetGap(int x, int y) {
this->gap_x = x;
this->gap_y = y;

View File

@ -189,13 +189,11 @@ class LinearGradientColor : public NodeDecorator {
/// .Stop(Color::Green, 0.5)
/// .Stop(Color::Blue, 1.0);;
/// ```
/// @ingroup dom
LinearGradient::LinearGradient() = default;
/// @brief Build a gradient with two colors.
/// @param begin The color at the beginning of the gradient.
/// @param end The color at the end of the gradient.
/// @ingroup dom
LinearGradient::LinearGradient(Color begin, Color end)
: LinearGradient(0, begin, end) {}
@ -203,7 +201,6 @@ LinearGradient::LinearGradient(Color begin, Color end)
/// @param a The angle of the gradient.
/// @param begin The color at the beginning of the gradient.
/// @param end The color at the end of the gradient.
/// @ingroup dom
LinearGradient::LinearGradient(float a, Color begin, Color end) : angle(a) {
stops.push_back({begin, {}});
stops.push_back({end, {}});
@ -212,7 +209,6 @@ LinearGradient::LinearGradient(float a, Color begin, Color end) : angle(a) {
/// @brief Set the angle of the gradient.
/// @param a The angle of the gradient.
/// @return The gradient.
/// @ingroup dom
LinearGradient& LinearGradient::Angle(float a) {
angle = a;
return *this;
@ -221,7 +217,6 @@ LinearGradient& LinearGradient::Angle(float a) {
/// @brief Add a color stop to the gradient.
/// @param c The color of the stop.
/// @param p The position of the stop.
/// @return The gradient.
LinearGradient& LinearGradient::Stop(Color c, float p) {
stops.push_back({c, p});
return *this;
@ -230,7 +225,6 @@ LinearGradient& LinearGradient::Stop(Color c, float p) {
/// @brief Add a color stop to the gradient.
/// @param c The color of the stop.
/// @return The gradient.
/// @ingroup dom
/// @note The position of the stop is interpolated from nearby stops.
LinearGradient& LinearGradient::Stop(Color c) {
stops.push_back({c, {}});

View File

@ -17,7 +17,6 @@ Node::Node(Elements children) : children_(std::move(children)) {}
Node::~Node() = default;
/// @brief Compute how much space an element needs.
/// @ingroup dom
void Node::ComputeRequirement() {
if (children_.empty()) {
return;
@ -39,13 +38,11 @@ void Node::ComputeRequirement() {
}
/// @brief Assign a position and a dimension to an element for drawing.
/// @ingroup dom
void Node::SetBox(Box box) {
box_ = box;
}
/// @brief Compute the selection of an element.
/// @ingroup dom
void Node::Select(Selection& selection) {
// If this Node box_ doesn't intersect with the selection, then no selection.
if (Box::Intersection(selection.GetBox(), box_).IsEmpty()) {
@ -59,7 +56,6 @@ void Node::Select(Selection& selection) {
}
/// @brief Display an element on a ftxui::Screen.
/// @ingroup dom
void Node::Render(Screen& screen) {
for (auto& child : children_) {
child->Render(screen);

View File

@ -44,14 +44,12 @@ void Order(int& a, int& b) {
} // namespace
/// @brief Create an empty table.
/// @ingroup dom
Table::Table() {
Initialize({});
}
/// @brief Create a table from a vector of vector of string.
/// @param input The input data.
/// @ingroup dom
Table::Table(std::vector<std::vector<std::string>> input) {
std::vector<std::vector<Element>> output;
output.reserve(input.size());
@ -68,14 +66,12 @@ Table::Table(std::vector<std::vector<std::string>> input) {
/// @brief Create a table from a vector of vector of Element
/// @param input The input elements.
/// @ingroup dom
Table::Table(std::vector<std::vector<Element>> input) {
Initialize(std::move(input));
}
// @brief Create a table from a list of list of string.
// @param init The input data.
// @ingroup dom
Table::Table(std::initializer_list<std::vector<std::string>> init) {
std::vector<std::vector<Element>> input;
for (const auto& row : init) {
@ -139,7 +135,6 @@ void Table::Initialize(std::vector<std::vector<Element>> input) {
/// @brief Select a row of the table.
/// @param index The index of the row to select.
/// @note You can use negative index to select from the end.
/// @ingroup dom
TableSelection Table::SelectRow(int index) {
return SelectRectangle(0, -1, index, index);
}
@ -148,7 +143,6 @@ TableSelection Table::SelectRow(int index) {
/// @param row_min The first row to select.
/// @param row_max The last row to select.
/// @note You can use negative index to select from the end.
/// @ingroup dom
TableSelection Table::SelectRows(int row_min, int row_max) {
return SelectRectangle(0, -1, row_min, row_max);
}
@ -156,7 +150,6 @@ TableSelection Table::SelectRows(int row_min, int row_max) {
/// @brief Select a column of the table.
/// @param index The index of the column to select.
/// @note You can use negative index to select from the end.
/// @ingroup dom
TableSelection Table::SelectColumn(int index) {
return SelectRectangle(index, index, 0, -1);
}
@ -165,7 +158,6 @@ TableSelection Table::SelectColumn(int index) {
/// @param column_min The first column to select.
/// @param column_max The last column to select.
/// @note You can use negative index to select from the end.
/// @ingroup dom
TableSelection Table::SelectColumns(int column_min, int column_max) {
return SelectRectangle(column_min, column_max, 0, -1);
}
@ -174,7 +166,6 @@ TableSelection Table::SelectColumns(int column_min, int column_max) {
/// @param column The column of the cell to select.
/// @param row The row of the cell to select.
/// @note You can use negative index to select from the end.
/// @ingroup dom
TableSelection Table::SelectCell(int column, int row) {
return SelectRectangle(column, column, row, row);
}
@ -185,7 +176,6 @@ TableSelection Table::SelectCell(int column, int row) {
/// @param row_min The first row to select.
/// @param row_max The last row to select.
/// @note You can use negative index to select from the end.
/// @ingroup dom
TableSelection Table::SelectRectangle(int column_min,
int column_max,
int row_min,
@ -207,7 +197,6 @@ TableSelection Table::SelectRectangle(int column_min,
}
/// @brief Select all the table.
/// @ingroup dom
TableSelection Table::SelectAll() {
TableSelection output; // NOLINT
output.table_ = this;
@ -220,7 +209,6 @@ TableSelection Table::SelectAll() {
/// @brief Render the table.
/// @return The rendered table. This is an element you can draw.
/// @ingroup dom
Element Table::Render() {
for (int y = 0; y < dim_y_; ++y) {
for (int x = 0; x < dim_x_; ++x) {
@ -250,7 +238,6 @@ Element Table::Render() {
/// @brief Apply the `decorator` to the selection.
/// This decorate both the cells, the lines and the corners.
/// @param decorator The decorator to apply.
/// @ingroup dom
// NOLINTNEXTLINE
void TableSelection::Decorate(Decorator decorator) {
for (int y = y_min_; y <= y_max_; ++y) {
@ -264,7 +251,6 @@ void TableSelection::Decorate(Decorator decorator) {
/// @brief Apply the `decorator` to the selection.
/// @param decorator The decorator to apply.
/// This decorate only the cells.
/// @ingroup dom
// NOLINTNEXTLINE
void TableSelection::DecorateCells(Decorator decorator) {
for (int y = y_min_; y <= y_max_; ++y) {
@ -282,7 +268,6 @@ void TableSelection::DecorateCells(Decorator decorator) {
/// @param decorator The decorator to apply.
/// @param modulo The modulo of the lines to decorate.
/// @param shift The shift of the lines to decorate.
/// @ingroup dom
// NOLINTNEXTLINE
void TableSelection::DecorateAlternateColumn(Decorator decorator,
int modulo,
@ -302,7 +287,6 @@ void TableSelection::DecorateAlternateColumn(Decorator decorator,
/// @param decorator The decorator to apply.
/// @param modulo The modulo of the lines to decorate.
/// @param shift The shift of the lines to decorate.
/// @ingroup dom
// NOLINTNEXTLINE
void TableSelection::DecorateAlternateRow(Decorator decorator,
int modulo,
@ -322,7 +306,6 @@ void TableSelection::DecorateAlternateRow(Decorator decorator,
/// @param decorator The decorator to apply.
/// @param modulo The modulo of the corners to decorate.
/// @param shift The shift of the corners to decorate.
/// @ingroup dom
// NOLINTNEXTLINE
void TableSelection::DecorateCellsAlternateColumn(Decorator decorator,
int modulo,
@ -342,7 +325,6 @@ void TableSelection::DecorateCellsAlternateColumn(Decorator decorator,
/// @param decorator The decorator to apply.
/// @param modulo The modulo of the corners to decorate.
/// @param shift The shift of the corners to decorate.
/// @ingroup dom
// NOLINTNEXTLINE
void TableSelection::DecorateCellsAlternateRow(Decorator decorator,
int modulo,
@ -359,7 +341,6 @@ void TableSelection::DecorateCellsAlternateRow(Decorator decorator,
/// @brief Apply a `border` around the selection.
/// @param border The border style to apply.
/// @ingroup dom
void TableSelection::Border(BorderStyle border) {
BorderLeft(border);
BorderRight(border);
@ -378,7 +359,6 @@ void TableSelection::Border(BorderStyle border) {
/// @brief Draw some separator lines in the selection.
/// @param border The border style to apply.
/// @ingroup dom
void TableSelection::Separator(BorderStyle border) {
for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) {
for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) {
@ -394,7 +374,6 @@ void TableSelection::Separator(BorderStyle border) {
/// @brief Draw some vertical separator lines in the selection.
/// @param border The border style to apply.
/// @ingroup dom
void TableSelection::SeparatorVertical(BorderStyle border) {
for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) {
for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) {
@ -408,7 +387,6 @@ void TableSelection::SeparatorVertical(BorderStyle border) {
/// @brief Draw some horizontal separator lines in the selection.
/// @param border The border style to apply.
/// @ingroup dom
void TableSelection::SeparatorHorizontal(BorderStyle border) {
for (int y = y_min_ + 1; y <= y_max_ - 1; ++y) {
for (int x = x_min_ + 1; x <= x_max_ - 1; ++x) {
@ -422,7 +400,6 @@ void TableSelection::SeparatorHorizontal(BorderStyle border) {
/// @brief Draw some separator lines to the left side of the selection.
/// @param border The border style to apply.
/// @ingroup dom
void TableSelection::BorderLeft(BorderStyle border) {
for (int y = y_min_; y <= y_max_; y++) {
table_->elements_[y][x_min_] =
@ -432,7 +409,6 @@ void TableSelection::BorderLeft(BorderStyle border) {
/// @brief Draw some separator lines to the right side of the selection.
/// @param border The border style to apply.
/// @ingroup dom
void TableSelection::BorderRight(BorderStyle border) {
for (int y = y_min_; y <= y_max_; y++) {
table_->elements_[y][x_max_] =
@ -442,7 +418,6 @@ void TableSelection::BorderRight(BorderStyle border) {
/// @brief Draw some separator lines to the top side of the selection.
/// @param border The border style to apply.
/// @ingroup dom
void TableSelection::BorderTop(BorderStyle border) {
for (int x = x_min_; x <= x_max_; x++) {
table_->elements_[y_min_][x] =
@ -452,7 +427,6 @@ void TableSelection::BorderTop(BorderStyle border) {
/// @brief Draw some separator lines to the bottom side of the selection.
/// @param border The border style to apply.
/// @ingroup dom
void TableSelection::BorderBottom(BorderStyle border) {
for (int x = x_min_; x <= x_max_; x++) {
table_->elements_[y_max_][x] =

View File

@ -7,7 +7,6 @@
namespace ftxui {
/// @return the biggest Box contained in both |a| and |b|.
/// @ingroup screen
// static
Box Box::Intersection(Box a, Box b) {
return Box{
@ -19,7 +18,6 @@ Box Box::Intersection(Box a, Box b) {
}
/// @return the smallest Box containing both |a| and |b|.
/// @ingroup screen
// static
Box Box::Union(Box a, Box b) {
return Box{
@ -33,7 +31,6 @@ Box Box::Union(Box a, Box b) {
/// Shift the box by (x,y).
/// @param x horizontal shift.
/// @param y vertical shift.
/// @ingroup screen
void Box::Shift(int x, int y) {
x_min += x;
x_max += x;
@ -42,7 +39,6 @@ void Box::Shift(int x, int y) {
}
/// @return whether (x,y) is contained inside the box.
/// @ingroup screen
bool Box::Contain(int x, int y) const {
return x_min <= x && //
x_max >= x && //
@ -51,20 +47,17 @@ bool Box::Contain(int x, int y) const {
}
/// @return whether the box is empty.
/// @ingroup screen
bool Box::IsEmpty() const {
return x_min > x_max || y_min > y_max;
}
/// @return whether |other| is the same as |this|
/// @ingroup screen
bool Box::operator==(const Box& other) const {
return (x_min == other.x_min) && (x_max == other.x_max) &&
(y_min == other.y_min) && (y_max == other.y_max);
}
/// @return whether |other| and |this| are different.
/// @ingroup screen
bool Box::operator!=(const Box& other) const {
return !operator==(other);
}

View File

@ -74,20 +74,16 @@ std::string Color::Print(bool is_background_color) const {
}
/// @brief Build a transparent color.
/// @ingroup screen
Color::Color() = default;
/// @brief Build a transparent color.
/// @ingroup screen
Color::Color(Palette1 /*value*/) : Color() {}
/// @brief Build a color using the Palette16 colors.
/// @ingroup screen
Color::Color(Palette16 index)
: type_(ColorType::Palette16), red_(index), alpha_(255) {}
/// @brief Build a color using Palette256 colors.
/// @ingroup screen
Color::Color(Palette256 index)
: type_(ColorType::Palette256), red_(index), alpha_(255) {
if (Terminal::ColorSupport() >= Terminal::Color::Palette256) {
@ -104,7 +100,6 @@ Color::Color(Palette256 index)
/// @param green The quantity of green [0,255]
/// @param blue The quantity of blue [0,255]
/// @param alpha The quantity of alpha [0,255]
/// @ingroup screen
Color::Color(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
: type_(ColorType::TrueColor),
red_(red),
@ -148,7 +143,6 @@ Color::Color(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
/// @param red The quantity of red [0,255]
/// @param green The quantity of green [0,255]
/// @param blue The quantity of blue [0,255]
/// @ingroup screen
// static
Color Color::RGB(uint8_t red, uint8_t green, uint8_t blue) {
return RGBA(red, green, blue, 255);
@ -160,7 +154,6 @@ Color Color::RGB(uint8_t red, uint8_t green, uint8_t blue) {
/// @param green The quantity of green [0,255]
/// @param blue The quantity of blue [0,255]
/// @param alpha The quantity of alpha [0,255]
/// @ingroup screen
/// @see Color::RGB
// static
Color Color::RGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) {
@ -174,7 +167,6 @@ Color Color::RGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) {
/// @param s The "colorfulness" [0,255].
/// @param v The "Lightness" [0,255]
/// @param alpha The quantity of alpha [0,255]
/// @ingroup screen
// static
Color Color::HSVA(uint8_t h, uint8_t s, uint8_t v, uint8_t alpha) {
uint8_t region = h / 43; // NOLINT
@ -202,7 +194,6 @@ Color Color::HSVA(uint8_t h, uint8_t s, uint8_t v, uint8_t alpha) {
/// @param h The hue of the color [0,255]
/// @param s The "colorfulness" [0,255].
/// @param v The "Lightness" [0,255]
/// @ingroup screen
// static
Color Color::HSV(uint8_t h, uint8_t s, uint8_t v) {
return HSVA(h, s, v, 255);