Text input.

This commit is contained in:
Dario
2025-01-19 00:29:40 -03:00
committed by Mr-Wiseguy
parent de88b5de46
commit 0a33cf03ef
12 changed files with 189 additions and 69 deletions
+22 -1
View File
@@ -10,7 +10,7 @@ namespace recompui {
void ConfigOptionElement::process_event(const Event &e) {
switch (e.type) {
case EventType::Hover:
hover_callback(this, e.hover.active);
hover_callback(this, std::get<EventHover>(e.variant).active);
break;
default:
assert(false && "Unknown event type.");
@@ -73,6 +73,22 @@ void ConfigOptionSlider::set_max_value(double v) {
slider->set_max_value(v);
}
// ConfigOptionTextInput
void ConfigOptionTextInput::text_changed(const std::string &text) {
// TODO: Hook up to whatever API Recomp exposes to set the value of the persisent configuration in mods.
printf("%s changed to %s.\n", name.c_str(), text.c_str());
}
ConfigOptionTextInput::ConfigOptionTextInput(Element *parent) : ConfigOptionElement(parent) {
text_input = get_current_context().create_element<TextInput>(this);
text_input->add_text_changed_callback(std::bind(&ConfigOptionTextInput::text_changed, this, std::placeholders::_1));
}
ConfigOptionTextInput::~ConfigOptionTextInput() {
}
// ConfigSubMenu
void ConfigSubMenu::back_button_pressed() {
@@ -159,6 +175,11 @@ void ConfigSubMenu::add_slider_option(std::string_view name, std::string_view de
add_option(option_slider, name, description);
}
void ConfigSubMenu::add_text_option(std::string_view name, std::string_view description) {
ConfigOptionTextInput *option_text_input = get_current_context().create_element<ConfigOptionTextInput>(config_scroll_container);
add_option(option_text_input, name, description);
}
void ConfigSubMenu::set_enter_sub_menu_callback(std::function<void()> callback) {
enter_sub_menu_callback = callback;
}