Module ftxui/component
Classes & Structs
| Class | Description |
|---|---|
ftxui::AnimatedColorOption | Option about a potentially animated color. |
ftxui::AnimatedColorsOption | |
ftxui::App | App is a class that manages the application lifecycle. It is responsible for initializing the terminal, running the main loop, and cleaning up on exit. |
ftxui::ButtonOption | Option for the AnimatedButton component. |
ftxui::CheckboxOption | Option for the Checkbox component. |
ftxui::ComponentBase | It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ftxui::Event. |
ftxui::DropdownOption | Option for the Dropdown component. |
ftxui::EntryState | arguments for transform from ButtonOption, CheckboxOption, RadioboxOption, MenuEntryOption, MenuOption. |
ftxui::Event | Represent an event. It can be key press event, a terminal resize, or more ... |
ftxui::InputOption | Option for the Input component. |
ftxui::InputState | Used to define style for the Input component. |
ftxui::Loop | Loop is a class that manages the event loop for a component. |
ftxui::MenuEntryOption | Option for the MenuEntry component. |
ftxui::MenuOption | Option for the Menu component. |
ftxui::Mouse | A mouse event. It contains the coordinate of the mouse, the button pressed and the modifier (shift, ctrl, meta). |
ftxui::RadioboxOption | Option for the Radiobox component. |
ftxui::ResizableSplitOption | |
ftxui::SliderOption | |
ftxui::UnderlineOption | Option for the underline effect. |
ftxui::WindowOptions | |
ftxui::WindowRenderState | State passed to the Window component's render function. |
ftxui::animation::Animator | |
ftxui::animation::Params |
Type Aliases
Clock
using Clock = std::chrono::steady_clock;Duration
using Duration = std::chrono::duration< float >;Function
using Function = std::function< float(float)>;TimePoint
using TimePoint = std::chrono::time_point< Clock >;CapturedMouse
using CapturedMouse = std::unique_ptr< CapturedMouseInterface >;Closure
using Closure = std::function< void()>;Component
using Component = std::shared_ptr< ComponentBase >;Examples: component/collapsible, component/focus_cursor, component/gallery, component/homescreen, component/input, component/input_in_frame, component/menu2, component/menu_multiple, component/menu_style, component/menu_underline_animated_gallery, component/modal_dialog, component/scrollbar (+2 more)
ComponentDecorator
using ComponentDecorator = std::function< Component(Component)>;Components
using Components = std::vector< Component >;ElementDecorator
using ElementDecorator = std::function< Element(Element)>;ScreenInteractive
using ScreenInteractive = App;Task
using Task = std::variant< Event, Closure, AnimationTask >;Examples: dom/package_manager
Functions
| Symbol | Description |
|---|---|
Linear | Modeled after the line y = x. |
QuadraticIn | Modeled after the parabola y = x^2. |
RequestAnimationFrame | RequestAnimationFrame is a function that requests a new frame to be drawn in the next animation cycle. |
Button | Draw a button. Execute a function when clicked. |
CatchEvent | Decorate a component, using on_event to catch events. This function must returns true when the event has been handled, false otherwise. |
Checkbox | Draw checkable element. |
Collapsible | A collapsible component. It displays a checkbox with an arrow. Once activated, the child is displayed. |
Horizontal | A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow key or 'h'/'l' keys. |
Stacked | A list of components to be stacked on top of each other. Events are propagated to the first component, then the second if not handled, etc. The components are drawn in the reverse order they are given. When a component take focus, it is put at the front, without changing the relative order of the other elements. |
Tab | A list of components, where only one is drawn and interacted with at a time. The selector gives the index of the selected component. This is useful to implement tabs. |
Vertical | A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or 'j'/'k' keys. |
Dropdown | A dropdown menu. |
Hoverable | Wrap a component. Gives the ability to know if it is hovered by the mouse. |
Input | An input box for editing text. |
Maybe | Decorate a component child. It is shown only when show returns true. |
Menu | A list of text. The focused element is selected. |
MenuEntry | A specific menu entry. They can be put into a Container::Vertical to form a menu. |
Radiobox | A list of element, where only one can be selected. |
Renderer | Return a component, using render to render its interface. |
ResizableSplit | A split in between two components. |
ResizableSplitBottom | An vertical split in between two components, configurable using the mouse. |
ResizableSplitLeft | An horizontal split in between two components, configurable using the mouse. |
ResizableSplitRight | An horizontal split in between two components, configurable using the mouse. |
ResizableSplitTop | An vertical split in between two components, configurable using the mouse. |
Slider | An horizontal slider. |
Toggle | An horizontal list of elements. The user can navigate through them. |
Window | A draggeable / resizeable window. To use multiple of them, they must be stacked using Container::Stacked({...}) component;. |
Linear
float Linear(float p);Modeled after the line y = x.
Examples: component/menu_style
QuadraticIn
float QuadraticIn(float p);Modeled after the parabola y = x^2.
RequestAnimationFrame
void RequestAnimationFrame();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.
Examples: component/homescreen, component/terminal_info
Button
Component Button(ButtonOption options);Draw a button. Execute a function when clicked.
Parameters:
option: Additional optional parameters.
See also: ButtonBase
Example
auto screen = App::FitComponent();
Component button = Button({
.label = "Click to quit",
.on_click = screen.ExitLoopClosure(),
});
screen.Loop(button)Output
┌─────────────┐
│Click to quit│
└─────────────┘Examples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/composition, component/gallery, component/homescreen, component/modal_dialog, component/modal_dialog_custom, component/nested_screen, component/renderer, component/selection (+2 more)
Button
Component Button(ConstStringRef label, std::function< void()> on_click, ButtonOption options = ButtonOption::Simple());Draw a button. Execute a function when clicked.
Parameters:
label: The label of the button.on_click: The action to execute when clicked.option: Additional optional parameters.
See also: ButtonBase
Example
auto screen = App::FitComponent();
std::string label = "Click to quit";
Component button = Button(&label, screen.ExitLoopClosure());
screen.Loop(button)Output
┌─────────────┐
│Click to quit│
└─────────────┘Examples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/composition, component/gallery, component/homescreen, component/modal_dialog, component/modal_dialog_custom, component/nested_screen, component/renderer, component/selection (+2 more)
CatchEvent
ComponentDecorator CatchEvent(std::function< bool(Event)> on_event);Decorate a component, using on_event to catch events. This function must returns true when the event has been handled, false otherwise.
Parameters:
on_event: The function drawing the interface.
Example
auto screen = App::TerminalOutput();
auto renderer = Renderer([] { return text("Hello world"); });
renderer |= CatchEvent([&](Event event) {
if (event == Event::Character('q')) {
screen.ExitLoopClosure()();
return true;
}
return false;
});
screen.Loop(renderer);Examples: component/canvas_animated, component/custom_loop, component/input, component/print_key_press, component/terminal_info
Checkbox
Component Checkbox(CheckboxOption options);Draw checkable element.
Parameters:
option: Additional optional parameters.
See also: CheckboxBase
Example
auto screen = App::FitComponent();
CheckboxOption option;
option.label = "Make a sandwidth";
option.checked = false;
Component checkbox = Checkbox(option);
screen.Loop(checkbox)Output
☐ Make a sandwichExamples: component/checkbox, component/checkbox_in_frame, component/flexbox_gallery, component/gallery, component/homescreen, component/maybe, component/terminal_info, component/window
Checkbox
Component Checkbox(ConstStringRef label, bool * checked, CheckboxOption options = CheckboxOption::Simple());Draw checkable element.
Parameters:
label: The label of the checkbox.checked: Whether the checkbox is checked or not.option: Additional optional parameters.
See also: CheckboxBase
Example
auto screen = App::FitComponent();
std::string label = "Make a sandwidth";
bool checked = false;
Component checkbox = Checkbox(&label, &checked);
screen.Loop(checkbox)Output
☐ Make a sandwichExamples: component/checkbox, component/checkbox_in_frame, component/flexbox_gallery, component/gallery, component/homescreen, component/maybe, component/terminal_info, component/window
Collapsible
Component Collapsible(ConstStringRef label, Component child, Ref< bool > show = false);A collapsible component. It displays a checkbox with an arrow. Once activated, the child is displayed.
Parameters:
label: The label of the checkbox.child: The child to display.show: Hold the state about whether the child is displayed or not.
Example
auto component = Collapsible("Show details", details);Output
▼ Show details
<details component>Examples: component/collapsible
Horizontal
Component Horizontal(Components children);A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow key or 'h'/'l' keys.
Parameters:
children: the list of components.
See also: ContainerBase
Example
auto container = Container::Horizontal({
children_1,
children_2,
children_3,
children_4,
});Examples: component/button, component/button_animated, component/button_style, component/canvas_animated, component/composition, component/dropdown, component/dropdown_custom, component/flexbox_gallery, component/homescreen, component/input_style, component/menu2, component/menu_in_frame_horizontal (+7 more)
Horizontal
Component Horizontal(Components children, int * selector);A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow key or 'h'/'l' keys.
Parameters:
children: the list of components.selector: A reference to the index of the selected children.
See also: ContainerBase
Example
int selected_children = 2;
auto container = Container::Horizontal({
children_1,
children_2,
children_3,
children_4,
}, selected_children);Examples: component/button, component/button_animated, component/button_style, component/canvas_animated, component/composition, component/dropdown, component/dropdown_custom, component/flexbox_gallery, component/homescreen, component/input_style, component/menu2, component/menu_in_frame_horizontal (+7 more)
Stacked
Component Stacked(Components children);A list of components to be stacked on top of each other. Events are propagated to the first component, then the second if not handled, etc. The components are drawn in the reverse order they are given. When a component take focus, it is put at the front, without changing the relative order of the other elements.
This should be used with the Window component.
Parameters:
children: The list of components.
See also: Window
Example
auto container = Container::Stacked({
children_1,
children_2,
children_3,
children_4,
});Examples: component/scrollbar, component/window
Tab
Component Tab(Components children, int * selector);A list of components, where only one is drawn and interacted with at a time. The selector gives the index of the selected component. This is useful to implement tabs.
Parameters:
children: The list of components.selector: The index of the drawn children.
See also: ContainerBase
Example
int tab_drawn = 0;
auto container = Container::Tab({
children_1,
children_2,
children_3,
children_4,
}, &tab_drawn);Examples: component/canvas_animated, component/homescreen, component/modal_dialog_custom, component/tab_horizontal, component/tab_vertical
Vertical
Component Vertical(Components children);A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or 'j'/'k' keys.
Parameters:
children: the list of components.
See also: ContainerBase
Example
auto container = Container::Vertical({
children_1,
children_2,
children_3,
children_4,
});Examples: component/button, component/button_in_frame, component/button_style, component/checkbox, component/checkbox_in_frame, component/collapsible, component/dropdown, component/flexbox_gallery, component/focus, component/focus_cursor, component/gallery, component/homescreen (+19 more)
Vertical
Component Vertical(Components children, int * selector);A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or 'j'/'k' keys. This is useful for implementing a Menu for instance.
Parameters:
children: the list of components.selector: A reference to the index of the selected children.
See also: ContainerBase
Example
int selected_children = 2;
auto container = Container::Vertical({
children_1,
children_2,
children_3,
children_4,
}, &selected_children);Examples: component/button, component/button_in_frame, component/button_style, component/checkbox, component/checkbox_in_frame, component/collapsible, component/dropdown, component/flexbox_gallery, component/focus, component/focus_cursor, component/gallery, component/homescreen (+19 more)
Dropdown
Component Dropdown(ConstStringListRef entries, int * selected);A dropdown menu.
Parameters:
entries: The list of entries to display.selected: The index of the selected entry.
Examples: component/dropdown, component/dropdown_custom
Dropdown
Component Dropdown(DropdownOption options);A dropdown menu.
Parameters:
option: The options for the dropdown.
Examples: component/dropdown, component/dropdown_custom
Hoverable
Wrap a component. Gives the ability to know if it is hovered by the mouse.
Parameters:
component: The wrapped component.hover: The value to reflect whether the component is hovered or not.
Example
auto button = Button("exit", screen.ExitLoopClosure());
bool hover = false;
auto button_hover = Hoverable(button, &hover);Hoverable
Component Hoverable(Component component, std::function< void()> on_enter, std::function< void()> on_leave);Wrap a component. Uses callbacks.
Parameters:
component: The wrapped component.on_enter: Callback OnEnteron_leave: Callback OnLeave
Example
auto button = Button("exit", screen.ExitLoopClosure());
bool hover = false;
auto button_hover = Hoverable(button, &hover);Hoverable
ComponentDecorator Hoverable(bool * hover);Wrap a component. Gives the ability to know if it is hovered by the mouse.
Parameters:
hover: The value to reflect whether the component is hovered or not.
Example
bool hover = false;
auto button = Button("exit", screen.ExitLoopClosure());
button |= Hoverable(&hover);Hoverable
ComponentDecorator Hoverable(std::function< void()> on_enter, std::function< void()> on_leave);Wrap a component. Gives the ability to know if it is hovered by the mouse.
Parameters:
on_enter: is called when the mouse hover the component.on_leave: is called when the mouse leave the component.
Example
auto button = Button("exit", screen.ExitLoopClosure());
int on_enter_cnt = 0;
int on_leave_cnt = 0;
button |= Hoverable(
[&]{ on_enter_cnt++; },
[&]{ on_leave_cnt++; }
);Hoverable
Wrap a component. Gives the ability to know if it is hovered by the mouse.
Parameters:
component: the wrapped component.on_change: is called when the mouse enter or leave the component.
Example
auto button = Button("exit", screen.ExitLoopClosure());
bool hovered = false;
auto button_hoverable = Hoverable(button,
[&](bool hover) { hovered = hover;});Hoverable
ComponentDecorator Hoverable(std::function< void(bool)> on_change);Wrap a component. Gives the ability to know if it is hovered by the mouse.
Parameters:
on_change: is called when the mouse enter or leave the component.
Example
auto button = Button("exit", screen.ExitLoopClosure());
bool hovered = false;
button |= Hoverable([&](bool hover) { hovered = hover;});Input
Component Input(InputOption options = {});An input box for editing text.
Parameters:
option: Additional optional parameters.
See also: InputBase
Example
auto screen = App::FitComponent();
std::string content= "";
std::string placeholder = "placeholder";
Component input = Input({
.content = &content,
.placeholder = &placeholder,
})
screen.Loop(input);Output
placeholderExamples: component/gallery, component/homescreen, component/input, component/input_in_frame, component/input_style, component/textarea
Input
Component Input(StringRef content, InputOption options = {});An input box for editing text.
Parameters:
content: The editable content.option: Additional optional parameters.
See also: InputBase
Example
auto screen = App::FitComponent();
std::string content= "";
std::string placeholder = "placeholder";
Component input = Input(content, {
.placeholder = &placeholder,
.password = true,
})
screen.Loop(input);Output
placeholderExamples: component/gallery, component/homescreen, component/input, component/input_in_frame, component/input_style, component/textarea
Input
Component Input(StringRef content, StringRef placeholder, InputOption options = {});An input box for editing text.
Parameters:
content: The editable content.placeholder: The placeholder text.option: Additional optional parameters.
See also: InputBase
Example
auto screen = App::FitComponent();
std::string content= "";
std::string placeholder = "placeholder";
Component input = Input(content, placeholder);
screen.Loop(input);Output
placeholderExamples: component/gallery, component/homescreen, component/input, component/input_in_frame, component/input_style, component/textarea
Maybe
Decorate a component child. It is shown only when show returns true.
Parameters:
child: the component to decorate.show: a function returning whetherchildshould shown.
Examples: component/maybe
Maybe
ComponentDecorator Maybe(std::function< bool()>);Decorate a component. It is shown only when the show function returns true.
Parameters:
show: a function returning whether the decorated component should be shown.
Example
auto component = Renderer([]{ return text("Hello World!"); });
auto maybe_component = component | Maybe([&]{ return counter == 42; });Examples: component/maybe
Maybe
Decorate a component child. It is shown only when show is true.
Parameters:
child: the component to decorate.show: a boolean.childis shown whenshowis true.
Example
auto component = Renderer([]{ return text("Hello World!"); });
auto maybe_component = Maybe(component, &show);Examples: component/maybe
Maybe
ComponentDecorator Maybe(const bool * show);Decorate a component. It is shown only when show is true.
Parameters:
show: a boolean.childis shown whenshowis true.
Example
auto component = Renderer([]{ return text("Hello World!"); });
auto maybe_component = component | Maybe(&show);Examples: component/maybe
Menu
Component Menu(MenuOption options);A list of text. The focused element is selected.
Parameters:
option: a structure containing all the parameters.
Example
auto screen = App::TerminalOutput();
std::vector<std::string> entries = {
"entry 1",
"entry 2",
"entry 3",
};
int selected = 0;
auto menu = Menu({
.entries = &entries,
.selected = &selected,
});
screen.Loop(menu);Output
> entry 1
entry 2
entry 3Examples: component/canvas_animated, component/gallery, component/homescreen, component/menu, component/menu2, component/menu_in_frame, component/menu_in_frame_horizontal, component/menu_multiple, component/menu_style, component/menu_underline_animated_gallery, component/tab_vertical
Menu
Component Menu(ConstStringListRef entries, int * selected_, MenuOption options = MenuOption::Vertical());A list of text. The focused element is selected.
Parameters:
entries: The list of entries in the menu.selected: The index of the currently selected element.option: Additional optional parameters.
Example
auto screen = App::TerminalOutput();
std::vector<std::string> entries = {
"entry 1",
"entry 2",
"entry 3",
};
int selected = 0;
auto menu = Menu(&entries, &selected);
screen.Loop(menu);Output
> entry 1
entry 2
entry 3Examples: component/canvas_animated, component/gallery, component/homescreen, component/menu, component/menu2, component/menu_in_frame, component/menu_in_frame_horizontal, component/menu_multiple, component/menu_style, component/menu_underline_animated_gallery, component/tab_vertical
MenuEntry
Component MenuEntry(ConstStringRef label, MenuEntryOption options = {});A specific menu entry. They can be put into a Container::Vertical to form a menu.
Parameters:
label: The text drawn representing this element.option: Additional optional parameters.
Example
auto screen = App::TerminalOutput();
int selected = 0;
auto menu = Container::Vertical({
MenuEntry("entry 1"),
MenuEntry("entry 2"),
MenuEntry("entry 3"),
}, &selected);
screen.Loop(menu);Output
> entry 1
entry 2
entry 3Examples: component/menu_entries, component/menu_entries_animated
MenuEntry
Component MenuEntry(MenuEntryOption options);A specific menu entry. They can be put into a Container::Vertical to form a menu.
Parameters:
option: The parameters.
Example
auto screen = App::TerminalOutput();
int selected = 0;
auto menu = Container::Vertical({
MenuEntry({.label = "entry 1"}),
MenuEntry({.label = "entry 2"}),
MenuEntry({.label = "entry 3"}),
}, &selected);
screen.Loop(menu);Output
> entry 1
entry 2
entry 3Examples: component/menu_entries, component/menu_entries_animated
Radiobox
Component Radiobox(RadioboxOption options);A list of element, where only one can be selected.
Parameters:
option: The parameters
See also: RadioboxBase
Example
auto screen = App::TerminalOutput();
std::vector<std::string> entries = {
"entry 1",
"entry 2",
"entry 3",
};
int selected = 0;
auto menu = Radiobox({
.entries = entries,
.selected = &selected,
});
screen.Loop(menu);Output
◉ entry 1
○ entry 2
○ entry 3NOLINTNEXTLINE
Examples: component/flexbox_gallery, component/gallery, component/homescreen, component/maybe, component/radiobox, component/radiobox_in_frame, component/tab_horizontal, component/tab_vertical, component/terminal_info
Radiobox
Component Radiobox(ConstStringListRef entries, int * selected_, RadioboxOption options = {});A list of element, where only one can be selected.
Parameters:
entries: The list of entries in the list.selected: The index of the currently selected element.option: Additional optional parameters.
See also: RadioboxBase
Example
auto screen = App::TerminalOutput();
std::vector<std::string> entries = {
"entry 1",
"entry 2",
"entry 3",
};
int selected = 0;
auto menu = Radiobox(&entries, &selected);
screen.Loop(menu);Output
◉ entry 1
○ entry 2
○ entry 3Examples: component/flexbox_gallery, component/gallery, component/homescreen, component/maybe, component/radiobox, component/radiobox_in_frame, component/tab_horizontal, component/tab_vertical, component/terminal_info
Renderer
Return a component, using render to render its interface.
Parameters:
render: The function drawing the interface.
Example
auto screen = App::TerminalOutput();
auto renderer = Renderer([] {
return text("My interface");
});
screen.Loop(renderer);Examples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/canvas_animated, component/checkbox_in_frame, component/collapsible, component/composition, component/custom_loop, component/flexbox_gallery, component/focus, component/focus_cursor (+32 more)
Renderer
Return a new Component, similar to child, but using render as the Component::Render() event.
Parameters:
child: The component to forward events to.render: The function drawing the interface.
Example
auto screen = App::TerminalOutput();
std::string label = "Click to quit";
auto button = Button(&label, screen.ExitLoopClosure());
auto renderer = Renderer(button, [&] {
return hbox({
text("A button:"),
button->Render(),
});
});
screen.Loop(renderer);Examples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/canvas_animated, component/checkbox_in_frame, component/collapsible, component/composition, component/custom_loop, component/flexbox_gallery, component/focus, component/focus_cursor (+32 more)
Renderer
Return a focusable component, using render to render its interface.
Parameters:
render: The function drawing the interface, taking a boolean telling whether the component is focused or not.
Example
auto screen = App::TerminalOutput();
auto renderer = Renderer([] (bool focused) {
if (focused)
return text("My interface") | inverted;
else
return text("My interface");
});
screen.Loop(renderer);Examples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/canvas_animated, component/checkbox_in_frame, component/collapsible, component/composition, component/custom_loop, component/flexbox_gallery, component/focus, component/focus_cursor (+32 more)
Renderer
Decorate a component, by decorating what it renders.
Parameters:
decorator: the function modifying the element it renders.
Example
auto screen = App::TerminalOutput();
auto renderer =
Renderer([] { return text("Hello"); })
| Renderer(bold)
| Renderer(inverted);
screen.Loop(renderer);Examples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/canvas_animated, component/checkbox_in_frame, component/collapsible, component/composition, component/custom_loop, component/flexbox_gallery, component/focus, component/focus_cursor (+32 more)
ResizableSplit
Component ResizableSplit(ResizableSplitOption options);A split in between two components.
Parameters:
options: all the parameters.
Example
auto left = Renderer([] { return text("Left") | center;});
auto right = Renderer([] { return text("right") | center;});
int left_size = 10;
auto component = ResizableSplit({
.main = left,
.back = right,
.direction = Direction::Left,
.main_size = &left_size,
.separator_func = [] { return separatorDouble(); },
});Output
║
left ║ right
║Examples: component/resizable_split_clamp
ResizableSplitBottom
Component ResizableSplitBottom(Component main, Component back, int * main_size);An vertical split in between two components, configurable using the mouse.
Parameters:
main: The main component of sizemain_size, on the bottom.back: The back component taking the remaining size, on the top.main_size: The size of themaincomponent.
Example
auto screen = App::Fullscreen();
int bottom_size = 1;
auto top = Renderer([] { return text("Top") | center;});
auto bottom = Renderer([] { return text("Bottom") | center;});
auto split = ResizableSplit::Bottom(bottom, top, &bottom_size)
screen.Loop(split);Output
top
────────────
bottomExamples: component/flexbox_gallery, component/resizable_split
ResizableSplitLeft
Component ResizableSplitLeft(Component main, Component back, int * main_size);An horizontal split in between two components, configurable using the mouse.
Parameters:
main: The main component of sizemain_size, on the left.back: The back component taking the remaining size, on the right.main_size: The size of themaincomponent.
Example
auto screen = App::Fullscreen();
int left_size = 10;
auto left = Renderer([] { return text("Left") | center;});
auto right = Renderer([] { return text("right") | center;});
auto split = ResizableSplitLeft(left, right, &left_size);
screen.Loop(split);Output
│
left │ right
│Examples: component/homescreen, component/print_key_press, component/resizable_split, component/textarea
ResizableSplitRight
Component ResizableSplitRight(Component main, Component back, int * main_size);An horizontal split in between two components, configurable using the mouse.
Parameters:
main: The main component of sizemain_size, on the right.back: The back component taking the remaining size, on the left.main_size: The size of themaincomponent.
Example
auto screen = App::Fullscreen();
int right_size = 10;
auto left = Renderer([] { return text("Left") | center;});
auto right = Renderer([] { return text("right") | center;});
auto split = ResizableSplitRight(right, left, &right_size)
screen.Loop(split);Output
│
left │ right
│Examples: component/flexbox_gallery, component/resizable_split
ResizableSplitTop
Component ResizableSplitTop(Component main, Component back, int * main_size);An vertical split in between two components, configurable using the mouse.
Parameters:
main: The main component of sizemain_size, on the top.back: The back component taking the remaining size, on the bottom.main_size: The size of themaincomponent.
Example
auto screen = App::Fullscreen();
int top_size = 1;
auto top = Renderer([] { return text("Top") | center;});
auto bottom = Renderer([] { return text("Bottom") | center;});
auto split = ResizableSplitTop(top, bottom, &top_size)
screen.Loop(split);Output
top
────────────
bottomExamples: component/resizable_split
Slider
Component Slider(ConstStringRef label, Ref< int > value, ConstRef< int > min = 0, ConstRef< int > max = 100, ConstRef< int > increment = 5);An horizontal slider.
Parameters:
label: The name of the slider.value: The current value of the slider.min: The minimum value.max: The maximum value.increment: The increment when used by the cursor.
Example
auto screen = App::TerminalOutput();
int value = 50;
auto slider = Slider("Value:", &value, 0, 100, 1);
screen.Loop(slider);Output
Value:[██████████████████████████ ]Examples: component/focus, component/gallery, component/linear_gradient_gallery, component/scrollbar, component/slider, component/slider_direction, component/slider_rgb, component/window
Slider
Component Slider(SliderOption< T > options);A slider in any direction.
Parameters:
options: The options
Example
auto screen = App::TerminalOutput();
int value = 50;
auto slider = Slider({
.value = &value,
.min = 0,
.max = 100,
.increment= 20,
});
screen.Loop(slider);Examples: component/focus, component/gallery, component/linear_gradient_gallery, component/scrollbar, component/slider, component/slider_direction, component/slider_rgb, component/window
Toggle
Component Toggle(ConstStringListRef entries, int * selected);An horizontal list of elements. The user can navigate through them.
Parameters:
entries: The list of selectable entries to display.selected: Reference the selected entry. See alsoMenu.
Examples: component/gallery, component/menu_style, component/tab_horizontal, component/toggle
Window
Component Window(WindowOptions option);A draggeable / resizeable window. To use multiple of them, they must be stacked using Container::Stacked({...}) component;.
Parameters:
option: A struct holding every parameters.
See also: Window
Example
auto window_1= Window({
.inner = DummyWindowContent(),
.title = "First window",
});
auto window_2= Window({
.inner = DummyWindowContent(),
.title = "Second window",
});
auto container = Container::Stacked({
window_1,
window_2,
});Examples: component/menu_multiple, component/scrollbar, component/window