mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-10-01 17:29:07 +08:00
Improve documentation (#1058)
* Remove @ingroup from class member definitions * Add the documentation for every public classes.
This commit is contained in:
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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(); });
|
||||
}
|
||||
|
Reference in New Issue
Block a user