Improve the documentation.

This commit is contained in:
ArthurSonzogni
2021-07-10 14:23:46 +02:00
committed by Arthur Sonzogni
parent 5c4cd1add1
commit 9820832fea
23 changed files with 79 additions and 133 deletions

View File

@@ -16,8 +16,6 @@
namespace ftxui {
namespace {
/// @brief A button. An action is associated to the click event.
/// @ingroup dom
class ButtonBase : public ComponentBase {
public:
ButtonBase(ConstStringRef label,
@@ -69,6 +67,7 @@ class ButtonBase : public ComponentBase {
/// @brief Draw a button. Execute a function when clicked.
/// @param label The label of the button.
/// @param on_click The action to execute when clicked.
/// @param option Additional optional parameters.
/// @ingroup component
/// @see ButtonBase
///

View File

@@ -8,8 +8,6 @@
namespace ftxui {
/// @brief A component executing a provided function for catching events.
/// @ingroup component.
class CatchEventBase : public ComponentBase {
public:
// Constructor.
@@ -31,6 +29,7 @@ class CatchEventBase : public ComponentBase {
/// @brief Return a component, using |on_event| to catch events. This function
/// must returns true when the event has been handled, false otherwise.
/// @param child The wrapped component.
/// @param on_event The function drawing the interface.
/// @ingroup component
///

View File

@@ -15,9 +15,6 @@
namespace ftxui {
namespace {
/// @brief A Checkbox. It can be checked or unchecked.Display an element on a
/// ftxui::Screen.
/// @ingroup dom
class CheckboxBase : public ComponentBase {
public:
CheckboxBase(ConstStringRef label, bool* state, Ref<CheckboxOption> option)
@@ -25,10 +22,10 @@ class CheckboxBase : public ComponentBase {
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
// Microsoft terminal do not use fonts able to render properly the default
// radiobox glyph.
if (option->checked == L"")
option->checked = L"[X]";
if (option->unchecked == L"")
option->unchecked = L"[ ]";
if (option_->style_checked == L"")
option_->style_checked = L"[X]";
if (option_->style_unchecked == L"")
option_->style_unchecked = L"[ ]";
#endif
}
@@ -86,6 +83,7 @@ class CheckboxBase : public ComponentBase {
/// @brief Draw checkable element.
/// @param label The label of the checkbox.
/// @param checked Whether the checkbox is checked or not.
/// @param option Additional optional parameters.
/// @ingroup component
/// @see CheckboxBase
///

View File

@@ -96,12 +96,12 @@ bool ComponentBase::Focused() {
}
/// @brief Make the |child| to be the "active" one.
/// @argument child the child to become active.
/// @param child the child to become active.
/// @ingroup component
void ComponentBase::SetActiveChild(ComponentBase*) {}
/// @brief Make the |child| to be the "active" one.
/// @argument child the child to become active.
/// @param child the child to become active.
/// @ingroup component
void ComponentBase::SetActiveChild(Component child) {
SetActiveChild(child.get());
@@ -121,7 +121,7 @@ void ComponentBase::TakeFocus() {
/// @brief Take the CapturedMouse if available. There is only one component of
/// them. It represents a component taking priority over others.
/// @argument event
/// @param event
/// @ingroup component
CapturedMouse ComponentBase::CaptureMouse(const Event& event) {
if (!event.screen_)

View File

@@ -11,7 +11,6 @@
namespace ftxui {
/// @brief A component where focus and events are automatically handled for you.
class ContainerBase : public ComponentBase {
public:
static Component Vertical() { return Vertical({}); }
@@ -195,7 +194,7 @@ Component Vertical(Components children) {
/// vertically using up/down arrow key or 'j'/'k' keys.
/// This is useful for implementing a Menu for instance.
/// @param children the list of components.
/// @param selector An integer storing the selected children.
/// @param selector A reference to the index of the selected children.
/// @ingroup component
/// @see ContainerBase
///
@@ -237,6 +236,7 @@ Component Horizontal(Components children) {
/// @brief A list of components, drawn one by one horizontally and navigated
/// horizontally using left/right arrow key or 'h'/'l' keys.
/// @param children the list of components.
/// @param selector A reference to the index of the selected children.
/// @ingroup component
/// @see ContainerBase
///
@@ -259,7 +259,7 @@ Component Horizontal(Components children, int* selector) {
/// a time. The |selector| gives the index of the selected component. This is
/// useful to implement tabs.
/// @param selector The index of the drawn children.
/// @param children the list of components.
/// @param children The list of components.
/// @ingroup component
/// @see ContainerBase
///

View File

@@ -17,8 +17,7 @@
namespace ftxui {
/// @brief An input box. The user can type text into it.
/// @ingroup component.
// An input box. The user can type text into it.
class InputBase : public ComponentBase {
public:
InputBase(StringRef content,
@@ -171,6 +170,7 @@ class InputBase : public ComponentBase {
/// @brief An input box for editing text.
/// @param content The editable content.
/// @param placeholder The text displayed when content is still empty.
/// @param option Additional optional parameters.
/// @ingroup component
/// @see InputBase
///

View File

@@ -119,6 +119,7 @@ class MenuBase : public ComponentBase {
/// @brief A list of text. The focused element is selected.
/// @param entries The list of entries in the menu.
/// @param selected The index of the currently selected element.
/// @param option Additional optional parameters.
/// @ingroup component
/// @see MenuBase
///

View File

@@ -32,10 +32,10 @@ class RadioboxBase : public ComponentBase {
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
// Microsoft terminal do not use fonts able to render properly the default
// radiobox glyph.
if (option_->checked == L"")
option_->checked = L"(*)";
if (option_->unchecked == L"")
option_->unchecked = L"( )";
if (option_->style_checked == L"")
option_->style_checked = L"(*)";
if (option_->style_unchecked == L"")
option_->style_unchecked = L"( )";
#endif
}
~RadioboxBase() override = default;
@@ -135,6 +135,7 @@ class RadioboxBase : public ComponentBase {
/// @brief A list of element, where only one can be selected.
/// @param entries The list of entries in the list.
/// @param selected The index of the currently selected element.
/// @param option Additional optional parameters.
/// @ingroup component
/// @see RadioboxBase
///

View File

@@ -8,8 +8,7 @@
namespace ftxui {
/// @brief A component rendering Element from a function.
/// @ingroup component.
// @brief A component rendering Element from a function.
class RendererBase : public ComponentBase {
public:
// Access this interface from a Component

View File

@@ -121,6 +121,9 @@ class ToggleBase : public ComponentBase {
} // namespace
/// @brief An horizontal list of elements. The user can navigate through them.
/// @param entries The list of selectable entries to display.
/// @param selected Reference the selected entry.
/// @param option Additional optional parameters.
/// @ingroup component
Component Toggle(const std::vector<std::wstring>* entries,
int* selected,

View File

@@ -6,7 +6,7 @@
namespace ftxui {
/// @brief Center an element horizontally.
/// @param The input element.
/// @param child The decorated element.
/// @return The centered element.
/// @ingroup dom
Element hcenter(Element child) {
@@ -14,7 +14,7 @@ Element hcenter(Element child) {
}
/// @brief Center an element vertically.
/// @param The input element.
/// @param child The decorated element.
/// @return The centered element.
/// @ingroup dom
Element vcenter(Element child) {
@@ -22,7 +22,7 @@ Element vcenter(Element child) {
}
/// @brief Center an element horizontally and vertically.
/// @param The input element.
/// @param child The decorated element.
/// @return The centered element.
/// @ingroup dom
Element center(Element child) {
@@ -30,7 +30,7 @@ Element center(Element child) {
}
/// @brief Align an element on the right side.
/// @param The input element.
/// @param child The decorated element.
/// @return The right aligned element.
/// @ingroup dom
Element align_right(Element child) {

View File

@@ -82,8 +82,8 @@ class Size : public Node {
/// @brief Apply a constraint on the size of an element.
/// @param direction Whether the WIDTH of the HEIGHT of the element must be
/// constrained.
/// @param constrain The type of constaint.
/// @param value the value.
/// @param constraint The type of constaint.
/// @param value The value.
/// @ingroup dom
Decorator size(Direction direction, Constraint constraint, int value) {
return [=](Element e) {

View File

@@ -6,11 +6,13 @@
namespace ftxui {
namespace {
Decorator compose(Decorator a, Decorator b) {
return [a = std::move(a), b = std::move(b)](Element element) {
return b(a(std::move(element)));
};
}
} // namespace
/// @brief A decoration doing absolutely nothing.
/// @ingroup dom

View File

@@ -117,9 +117,9 @@ Color Color::RGB(uint8_t red, uint8_t green, uint8_t blue) {
/// @brief Build a Color from its HSV representation.
/// https://en.wikipedia.org/wiki/HSL_and_HSV
///
/// @param hue The hue of the color [0,255]
/// @param saturation The "colorfulness" [0,255].
/// @param value The "Lightness" [0,255]
/// @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) {