Update logic for dealing with file dialogs.

This in preparation for an upcoming change that uses native file dialogs instead
of our very basic ImGui file dialog.

PiperOrigin-RevId: 861671041
Change-Id: I9b00c05efdda5e37ffe15048a2ccf66f6eca89d9
This commit is contained in:
Haroon Qureshi
2026-01-27 05:30:09 -08:00
committed by Copybara-Service
parent ad482a57bb
commit 75715ab966
9 changed files with 234 additions and 161 deletions
@@ -66,27 +66,6 @@ bool ImGui_Slider(const char* name, mjtNum* value, mjtNum min, mjtNum max) {
return res;
}
bool ImGui_FileDialog(char* buf, int len) {
bool ok = false;
ImGui::Text("Filename");
ImGui::SameLine();
ImGui::SetNextItemWidth(600);
if (ImGui::InputText("##Filename", buf, len, ImGuiInputTextFlags_EnterReturnsTrue)) {
ok = true;
ImGui::CloseCurrentPopup();
};
if (ImGui::Button("OK", ImVec2(120, 0)) || ImGui_IsChordJustPressed(ImGuiKey_Enter)) {
ok = true;
ImGui::CloseCurrentPopup();
}
ImGui::SetItemDefaultFocus();
ImGui::SameLine();
if (ImGui::Button("Cancel", ImVec2(120, 0)) || ImGui_IsChordJustPressed(ImGuiKey_Escape)) {
ImGui::CloseCurrentPopup();
}
return ok;
}
void MaybeSaveToClipboard(const std::string& contents) {
if (ImGui::GetIO().SetClipboardTextFn) {
ImGui::GetIO().SetClipboardTextFn(nullptr, contents.c_str());