2021-07-07 22:13:33 +02:00
|
|
|
#ifndef FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP
|
|
|
|
|
#define FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP
|
|
|
|
|
|
2021-07-07 22:37:50 +02:00
|
|
|
#include <ftxui/dom/elements.hpp>
|
2021-07-10 12:29:39 +02:00
|
|
|
#include <ftxui/util/ref.hpp>
|
2021-07-07 22:37:50 +02:00
|
|
|
|
2021-07-07 22:13:33 +02:00
|
|
|
namespace ftxui {
|
|
|
|
|
|
2021-07-10 11:50:17 +02:00
|
|
|
/// @brief Option for the Menu component.
|
2021-07-10 14:23:46 +02:00
|
|
|
/// @ingroup component
|
2021-07-07 22:13:33 +02:00
|
|
|
struct MenuOption {
|
2021-07-10 11:50:17 +02: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-07 22:13:33 +02:00
|
|
|
|
2021-07-10 11:50:17 +02: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 12:59:36 +02:00
|
|
|
|
|
|
|
|
Ref<int> focused_entry = 0;
|
2021-07-07 22:13:33 +02:00
|
|
|
};
|
|
|
|
|
|
2021-07-10 11:50:17 +02:00
|
|
|
/// @brief Option for the Button component.
|
2021-07-10 14:23:46 +02:00
|
|
|
/// @ingroup component
|
2021-07-07 22:23:07 +02:00
|
|
|
struct ButtonOption {
|
2021-07-10 11:50:17 +02:00
|
|
|
/// Whether to show a border around the button.
|
2021-07-07 22:23:07 +02:00
|
|
|
bool border = true;
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-10 11:50:17 +02:00
|
|
|
/// @brief Option for the Checkbox component.
|
2021-07-10 14:23:46 +02:00
|
|
|
/// @ingroup component
|
2021-07-07 22:37:50 +02:00
|
|
|
struct CheckboxOption {
|
2021-07-10 11:50:17 +02: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-07 22:37:50 +02:00
|
|
|
|
|
|
|
|
/// Called when the user change the state.
|
|
|
|
|
std::function<void()> on_change = []() {};
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-10 11:50:17 +02:00
|
|
|
/// @brief Option for the Input component.
|
2021-07-10 14:23:46 +02:00
|
|
|
/// @ingroup component
|
2021-07-08 00:01:42 +02:00
|
|
|
struct InputOption {
|
2021-07-10 11:50:17 +02:00
|
|
|
/// Called when the content changes.
|
2021-07-08 00:01:42 +02:00
|
|
|
std::function<void()> on_change = [] {};
|
2021-07-10 11:50:17 +02:00
|
|
|
/// Called when the user presses enter.
|
2021-07-08 00:01:42 +02:00
|
|
|
std::function<void()> on_enter = [] {};
|
2021-07-10 12:29:39 +02:00
|
|
|
|
|
|
|
|
Ref<int> cursor_position = 0;
|
2021-07-08 00:01:42 +02:00
|
|
|
};
|
|
|
|
|
|
2021-07-10 11:50:17 +02:00
|
|
|
/// @brief Option for the Radiobox component.
|
2021-07-10 14:23:46 +02:00
|
|
|
/// @ingroup component
|
2021-07-10 10:50:25 +02:00
|
|
|
struct RadioboxOption {
|
2021-07-10 11:50:17 +02: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 10:50:25 +02:00
|
|
|
|
2021-07-10 11:50:17 +02:00
|
|
|
/// Called when the selected entry changes.
|
2021-07-10 10:50:25 +02:00
|
|
|
std::function<void()> on_change = []() {};
|
2021-07-10 13:07:01 +02:00
|
|
|
|
|
|
|
|
Ref<int> focused_entry = 0;
|
2021-07-10 10:50:25 +02:00
|
|
|
};
|
|
|
|
|
|
2021-07-10 11:50:17 +02:00
|
|
|
/// @brief Option for the Toggle component.
|
2021-07-10 14:23:46 +02:00
|
|
|
/// @ingroup component
|
2021-07-10 11:03:01 +02:00
|
|
|
struct ToggleOption {
|
2021-07-10 11:50:17 +02: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 11:03:01 +02:00
|
|
|
|
2021-07-10 11:50:17 +02: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 13:15:28 +02:00
|
|
|
|
|
|
|
|
Ref<int> focused_entry = 0;
|
2021-07-10 11:03:01 +02:00
|
|
|
};
|
|
|
|
|
|
2021-07-10 14:23:46 +02:00
|
|
|
} // namespace ftxui
|
2021-07-07 22:13:33 +02:00
|
|
|
|
|
|
|
|
#endif /* end of include guard: FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP */
|
2021-07-10 13:20:43 +02:00
|
|
|
|
|
|
|
|
// Copyright 2021 Arthur Sonzogni. All rights reserved.
|
|
|
|
|
// Use of this source code is governed by the MIT license that can be found in
|
|
|
|
|
// the LICENSE file.
|