class mrpt::imgui::SimpleFileDialog

Overview

Minimal file browser drawn with ImGui itself (a modal popup), with no dependency on any system dialog helper.

Used by CImGuiFileDialog when no native dialog is available (e.g. remote or minimal sessions).

dlg.open(SimpleFileDialog::Mode::Open, {{"Rawlogs", {"rawlog"}}});
// Every frame:
if (auto path = dlg.render(); path) { ... }
#include <mrpt/imgui/SimpleFileDialog.h>

class SimpleFileDialog
{
public:
    // enums

    enum Mode;

    // methods

    void open(
        Mode mode,
        const std::vector<FileDialogFilter>& filters,
        const std::string& title = "",
        const std::string& initialPath = ""
        );

    std::optional<std::string> render();
    bool isOpen() const;
    void close();
    const std::string& currentDirectory() const;
};

Methods

void open(
    Mode mode,
    const std::vector<FileDialogFilter>& filters,
    const std::string& title = "",
    const std::string& initialPath = ""
    )

Opens the dialog, starting at initialPath (a directory, or a file whose directory and name are used), or else the last directory used, or else the current directory.

std::optional<std::string> render()

Must be called every frame while isOpen().

Returns the selected path once the user confirms, nullopt otherwise (still open, or cancelled: check isOpen() to tell them apart).

void close()

Closes the dialog without a result.