FTXUI/include/ftxui/component/component_options.hpp

75 lines
2.6 KiB
C++
Raw Normal View History

#ifndef FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP
#define FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP
2021-07-08 04:37:50 +08:00
#include <ftxui/dom/elements.hpp>
namespace ftxui {
2021-07-10 17:50:17 +08:00
/// @brief Option for the Menu component.
struct MenuOption {
2021-07-10 17:50:17 +08:00
Decorator style_normal = nothing; /// style.
Decorator style_focused = inverted; /// Style when focused.
Decorator style_selected = bold; /// Style when selected.
Decorator style_selected_focused =
Decorator(inverted) | bold; /// Style when selected and focused.
2021-07-10 17:50:17 +08:00
/// Called when the selected entry changes.
std::function<void()> on_change = [] {};
/// Called when the user presses enter.
std::function<void()> on_enter = [] {};
};
2021-07-10 17:50:17 +08:00
/// @brief Option for the Button component.
2021-07-08 04:23:07 +08:00
struct ButtonOption {
2021-07-10 17:50:17 +08:00
/// Whether to show a border around the button.
2021-07-08 04:23:07 +08:00
bool border = true;
};
2021-07-10 17:50:17 +08:00
/// @brief Option for the Checkbox component.
2021-07-08 04:37:50 +08:00
struct CheckboxOption {
2021-07-10 17:50:17 +08:00
std::wstring style_checked = L""; /// Prefix for a "checked" state.
std::wstring style_unchecked = L""; /// Prefix for a "unchecked" state.
Decorator style_focused = inverted; /// Decorator used when focused.
Decorator style_unfocused = nothing; /// Decorator used when unfocused.
2021-07-08 04:37:50 +08:00
/// Called when the user change the state.
std::function<void()> on_change = []() {};
};
2021-07-10 17:50:17 +08:00
/// @brief Option for the Input component.
2021-07-08 06:01:42 +08:00
struct InputOption {
2021-07-10 17:50:17 +08:00
/// Called when the content changes.
2021-07-08 06:01:42 +08:00
std::function<void()> on_change = [] {};
2021-07-10 17:50:17 +08:00
/// Called when the user presses enter.
2021-07-08 06:01:42 +08:00
std::function<void()> on_enter = [] {};
};
2021-07-10 17:50:17 +08:00
/// @brief Option for the Radiobox component.
2021-07-10 16:50:25 +08:00
struct RadioboxOption {
2021-07-10 17:50:17 +08:00
std::wstring style_checked = L""; /// Prefix for a "checked" state.
std::wstring style_unchecked = L""; /// Prefix for a "unchecked" state.
Decorator style_focused = inverted; /// Decorator used when focused.
Decorator style_unfocused = nothing; /// Decorator used when unfocused.
2021-07-10 16:50:25 +08:00
2021-07-10 17:50:17 +08:00
/// Called when the selected entry changes.
2021-07-10 16:50:25 +08:00
std::function<void()> on_change = []() {};
};
2021-07-10 17:50:17 +08:00
/// @brief Option for the Toggle component.
2021-07-10 17:03:01 +08:00
struct ToggleOption {
2021-07-10 17:50:17 +08:00
Decorator style_normal = nothing; /// style.
Decorator style_focused = inverted; /// Style when focused.
Decorator style_selected = bold; /// Style when selected.
Decorator style_selected_focused =
Decorator(inverted) | bold; /// Style when selected and focused.
2021-07-10 17:03:01 +08:00
2021-07-10 17:50:17 +08:00
/// Called when the selected entry changes.
std::function<void()> on_change = [] {};
/// Called when the user presses enter.
std::function<void()> on_enter = [] {};
2021-07-10 17:03:01 +08:00
};
2021-07-08 04:23:07 +08:00
}; // namespace ftxui
#endif /* end of include guard: FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP */