add functionality for saving and loading presets

This commit is contained in:
gymnast86
2026-06-19 03:08:12 -07:00
parent f20cf3c24e
commit 08e0645ef8
6 changed files with 199 additions and 6 deletions
+33
View File
@@ -1,5 +1,7 @@
#include "modal.hpp"
#include "string_button.hpp"
namespace dusk::ui {
Modal::Modal(Props props) : WindowSmall("modal", "modal-dialog"), mProps(std::move(props)) {
@@ -100,4 +102,35 @@ bool Modal::handle_nav_command(Rml::Event& event, NavCommand cmd) {
return false;
}
TextInputModal::TextInputModal(Props props) : Modal(props) {
auto modalBody = mDialog->QuerySelector(".modal-body");
mInput = std::make_unique<StringButton>(modalBody, StringButton::Props{
.getValue = [this]{return mInputText;},
.setValue = [this](Rml::String value) { mInputText = value; },
});
mInput->start_editing();
}
bool TextInputModal::handle_nav_command(Rml::Event& event, NavCommand cmd) {
auto retVal = Modal::handle_nav_command(event, cmd);
if (!retVal) {
if (mInput->root()->IsPseudoClassSet("focus") && cmd == NavCommand::Down) {
mButtons[0]->focus();
retVal = true;
} else if (!mInput->root()->IsPseudoClassSet("focus") && cmd == NavCommand::Up) {
mInput->focus();
retVal = true;
}
}
return retVal;
}
void TextInputModal::update() {
mInput->update();
Document::update();
}
} // namespace dusk::ui