4#ifndef FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP
5#define FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP
25struct FTXUI_EXPORT(COMPONENT) EntryState {
35struct FTXUI_EXPORT(COMPONENT) UnderlineOption {
38 Color color_active = Color::White;
39 Color color_inactive = Color::GrayDark;
41 animation::easing::Function leader_function =
42 animation::easing::QuadraticInOut;
43 animation::easing::Function follower_function =
44 animation::easing::QuadraticInOut;
46 animation::Duration leader_duration = std::chrono::milliseconds(250);
47 animation::Duration leader_delay = std::chrono::milliseconds(0);
48 animation::Duration follower_duration = std::chrono::milliseconds(250);
49 animation::Duration follower_delay = std::chrono::milliseconds(0);
51 void SetAnimation(animation::Duration d, animation::easing::Function f);
52 void SetAnimationDuration(animation::Duration d);
53 void SetAnimationFunction(animation::easing::Function f);
54 void SetAnimationFunction(animation::easing::Function f_leader,
55 animation::easing::Function f_follower);
60struct FTXUI_EXPORT(COMPONENT) AnimatedColorOption {
64 animation::Duration duration = std::chrono::milliseconds(250),
65 animation::easing::Function function = animation::easing::QuadraticInOut);
70 animation::Duration duration = std::chrono::milliseconds(250);
71 animation::easing::Function function = animation::easing::QuadraticInOut;
74struct FTXUI_EXPORT(COMPONENT) AnimatedColorsOption {
75 AnimatedColorOption background;
76 AnimatedColorOption foreground;
81struct FTXUI_EXPORT(COMPONENT) MenuEntryOption {
82 ConstStringRef label =
"MenuEntry";
83 std::function<
Element(
const EntryState& state)> transform;
84 AnimatedColorsOption animated_colors;
89struct FTXUI_EXPORT(COMPONENT) MenuOption {
91 static MenuOption Horizontal();
92 static MenuOption HorizontalAnimated();
93 static MenuOption Vertical();
94 static MenuOption VerticalAnimated();
95 static MenuOption Toggle();
97 ConstStringListRef entries;
98 Ref<int> selected = 0;
101 UnderlineOption underline;
102 MenuEntryOption entries_option;
104 std::function<
Element()> elements_prefix;
105 std::function<
Element()> elements_infix;
106 std::function<
Element()> elements_postfix;
109 std::function<void()> on_change;
110 std::function<void()> on_enter;
111 Ref<int> focused_entry = 0;
116struct FTXUI_EXPORT(COMPONENT) ButtonOption {
118 static ButtonOption Ascii();
119 static ButtonOption Simple();
120 static ButtonOption Border();
121 static ButtonOption Animated();
122 static ButtonOption Animated(Color color);
123 static ButtonOption Animated(Color background, Color foreground);
124 static ButtonOption Animated(Color background,
126 Color background_active,
127 Color foreground_active);
129 ConstStringRef label =
"Button";
130 std::function<void()> on_click = [] {};
133 std::function<
Element(
const EntryState&)> transform;
134 AnimatedColorsOption animated_colors;
139struct FTXUI_EXPORT(COMPONENT) CheckboxOption {
141 static CheckboxOption Simple();
143 ConstStringRef label =
"Checkbox";
145 Ref<bool> checked =
false;
148 std::function<
Element(
const EntryState&)> transform;
152 std::function<void()> on_change = [] {};
156struct FTXUI_EXPORT(COMPONENT) InputState {
166struct FTXUI_EXPORT(COMPONENT) InputOption {
170 static InputOption Default();
172 static InputOption Spacious();
175 StringRef content =
"";
178 StringRef placeholder =
"";
181 std::function<
Element(InputState)> transform;
182 Ref<bool> password =
false;
183 Ref<bool> multiline =
true;
184 Ref<bool> insert =
true;
187 std::function<void()> on_change = [] {};
189 std::function<void()> on_enter = [] {};
192 Ref<int> cursor_position = 0;
197struct FTXUI_EXPORT(COMPONENT) RadioboxOption {
199 static RadioboxOption Simple();
202 ConstStringListRef entries;
203 Ref<int> selected = 0;
206 std::function<
Element(
const EntryState&)> transform;
210 std::function<void()> on_change = [] {};
211 Ref<int> focused_entry = 0;
214struct FTXUI_EXPORT(COMPONENT) ResizableSplitOption {
217 Ref<Direction>
direction = Direction::Left;
221 std::function<
Element()> separator_func = [] { return ::ftxui::separator(); };
225 Ref<int> max = std::numeric_limits<int>::max();
237 Color color_active = Color::White;
238 Color color_inactive = Color::GrayDark;
244struct FTXUI_EXPORT(COMPONENT) WindowRenderState {
246 const std::string& title;
250 bool hover_left =
false;
251 bool hover_right =
false;
252 bool hover_top =
false;
253 bool hover_down =
false;
258struct FTXUI_EXPORT(COMPONENT) WindowOptions {
260 ConstStringRef title =
"";
265 Ref<int> height = 10;
267 Ref<bool> resize_left =
true;
268 Ref<bool> resize_right =
true;
269 Ref<bool> resize_top =
true;
270 Ref<bool> resize_down =
true;
273 std::function<Element(
const WindowRenderState&)> render;
279struct FTXUI_EXPORT(COMPONENT) DropdownOption {
281 Ref<bool> open =
false;
283 CheckboxOption checkbox;
285 RadioboxOption radiobox;
287 std::function<
Element(
bool open, Element checkbox, Element radiobox)>
An adapter. Own or reference an immutable object.
An adapter. Own or reference an mutable object.
Direction
Direction is an enumeration that represents the four cardinal directions.
The FTXUI ftxui:: namespace.
std::shared_ptr< Node > Element
std::shared_ptr< ComponentBase > Component
std::function< void()> on_change