mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-15 23:48:15 +08:00
Add option for radiobox
This commit is contained in:

committed by
Arthur Sonzogni

parent
33b3d1c7ab
commit
ae6473363d
@@ -36,7 +36,9 @@ Component Input(StringRef content,
|
||||
Component Menu(const std::vector<std::wstring>* entries,
|
||||
int* selected_,
|
||||
ConstRef<MenuOption> = {});
|
||||
Component Radiobox(const std::vector<std::wstring>* entries, int* selected_);
|
||||
Component Radiobox(const std::vector<std::wstring>* entries,
|
||||
int* selected_,
|
||||
ConstRef<RadioboxOption> option = {});
|
||||
Component Toggle(const std::vector<std::wstring>* entries, int* selected);
|
||||
template <class T> // T = {int, float, long}
|
||||
Component Slider(StringRef label, T* value, T min, T max, T increment);
|
||||
|
@@ -36,6 +36,16 @@ struct InputOption {
|
||||
std::function<void()> on_enter = [] {};
|
||||
};
|
||||
|
||||
struct RadioboxOption {
|
||||
std::wstring checked = L"◉ ";
|
||||
std::wstring unchecked = L"○ ";
|
||||
|
||||
Decorator focused_style = inverted;
|
||||
Decorator unfocused_style = nothing;
|
||||
|
||||
std::function<void()> on_change = []() {};
|
||||
};
|
||||
|
||||
}; // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP */
|
||||
|
@@ -22,20 +22,13 @@ class RadioboxBase : public ComponentBase {
|
||||
static RadioboxBase* From(Component component);
|
||||
|
||||
// Constructor.
|
||||
RadioboxBase(const std::vector<std::wstring>* entries, int* selected);
|
||||
RadioboxBase(const std::vector<std::wstring>* entries,
|
||||
int* selected,
|
||||
ConstRef<RadioboxOption> option);
|
||||
~RadioboxBase() override = default;
|
||||
|
||||
int focused = 0;
|
||||
|
||||
std::wstring checked = L"◉ ";
|
||||
std::wstring unchecked = L"○ ";
|
||||
|
||||
Decorator focused_style = inverted;
|
||||
Decorator unfocused_style = nothing;
|
||||
|
||||
// State update callback.
|
||||
std::function<void()> on_change = []() {};
|
||||
|
||||
// Component implementation.
|
||||
Element Render() override;
|
||||
bool OnEvent(Event) override;
|
||||
@@ -47,6 +40,7 @@ class RadioboxBase : public ComponentBase {
|
||||
bool OnMouseEvent(Event event);
|
||||
int cursor_position = 0;
|
||||
std::vector<Box> boxes_;
|
||||
ConstRef<RadioboxOption> option_;
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
Reference in New Issue
Block a user