2021-07-08 04:13:33 +08:00
|
|
|
#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>
|
2021-07-10 18:29:39 +08:00
|
|
|
#include <ftxui/util/ref.hpp>
|
2021-07-08 04:37:50 +08:00
|
|
|
|
2021-07-08 04:13:33 +08:00
|
|
|
namespace ftxui {
|
|
|
|
|
2021-07-10 17:50:17 +08:00
|
|
|
/// @brief Option for the Menu component.
|
2021-07-10 20:23:46 +08:00
|
|
|
/// @ingroup component
|
2021-07-08 04:13:33 +08:00
|
|
|
struct MenuOption {
|
2021-07-23 14:40:47 +08:00
|
|
|
Decorator style_normal = nothing; ///< style.
|
|
|
|
Decorator style_focused = inverted; ///< Style when focused.
|
|
|
|
Decorator style_selected = bold; ///< Style when selected.
|
2021-07-10 17:50:17 +08:00
|
|
|
Decorator style_selected_focused =
|
2021-07-23 14:40:47 +08:00
|
|
|
Decorator(inverted) | bold; ///< Style when selected and focused.
|
2021-07-08 04:13:33 +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 18:59:36 +08:00
|
|
|
|
|
|
|
Ref<int> focused_entry = 0;
|
2021-07-08 04:13:33 +08:00
|
|
|
};
|
|
|
|
|
2021-07-10 17:50:17 +08:00
|
|
|
/// @brief Option for the Button component.
|
2021-07-10 20:23:46 +08:00
|
|
|
/// @ingroup 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-10 20:23:46 +08:00
|
|
|
/// @ingroup component
|
2021-07-08 04:37:50 +08:00
|
|
|
struct CheckboxOption {
|
2021-08-09 05:25:20 +08:00
|
|
|
std::string style_checked = "▣ "; ///< Prefix for a "checked" state.
|
|
|
|
std::string style_unchecked = "☐ "; ///< 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-10 20:23:46 +08:00
|
|
|
/// @ingroup 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 18:29:39 +08:00
|
|
|
|
2021-07-17 16:36:50 +08:00
|
|
|
/// Obscure the input content using '*'.
|
|
|
|
bool password = false;
|
|
|
|
|
2021-07-10 18:29:39 +08:00
|
|
|
Ref<int> cursor_position = 0;
|
2021-07-08 06:01:42 +08:00
|
|
|
};
|
|
|
|
|
2021-07-10 17:50:17 +08:00
|
|
|
/// @brief Option for the Radiobox component.
|
2021-07-10 20:23:46 +08:00
|
|
|
/// @ingroup component
|
2021-07-10 16:50:25 +08:00
|
|
|
struct RadioboxOption {
|
2021-08-09 05:25:20 +08:00
|
|
|
std::string style_checked = "◉ "; ///< Prefix for a "checked" state.
|
|
|
|
std::string style_unchecked = "○ "; ///< 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 19:07:01 +08:00
|
|
|
|
|
|
|
Ref<int> focused_entry = 0;
|
2021-07-10 16:50:25 +08:00
|
|
|
};
|
|
|
|
|
2021-07-10 17:50:17 +08:00
|
|
|
/// @brief Option for the Toggle component.
|
2021-07-10 20:23:46 +08:00
|
|
|
/// @ingroup component
|
2021-07-10 17:03:01 +08:00
|
|
|
struct ToggleOption {
|
2021-07-23 14:40:47 +08:00
|
|
|
Decorator style_normal = nothing; ///< style.
|
|
|
|
Decorator style_focused = inverted; ///< Style when focused.
|
|
|
|
Decorator style_selected = bold; ///< Style when selected.
|
2021-07-10 17:50:17 +08:00
|
|
|
Decorator style_selected_focused =
|
2021-07-23 14:40:47 +08:00
|
|
|
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 19:15:28 +08:00
|
|
|
|
|
|
|
Ref<int> focused_entry = 0;
|
2021-07-10 17:03:01 +08:00
|
|
|
};
|
|
|
|
|
2021-07-10 20:23:46 +08:00
|
|
|
} // namespace ftxui
|
2021-07-08 04:13:33 +08:00
|
|
|
|
|
|
|
#endif /* end of include guard: FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP */
|
2021-07-10 19:20:43 +08: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.
|