GGUI::GGFiles class

GGFiles: the platform file dialog, requested now and answered later. Thread-safe.

The platform layer provides the backend (SetBackend) and reports results (Answer). Results are delivered where it is safe: to a document at its next update, or to non-document callers when the host calls RunAnswers.

Public types

using BackendFn = void(*)(void*context, const FileRequest&request)
Opens the native dialog. Must eventually call Answer with the request's ID.

Public functions

void SetBackend(BackendFn open, void* context)
The platform's dialog. Without one, Open does nothing.
auto HasBackend() const -> bool
Whether a backend is set.
void Open(const FileDialogProps& props, FileChoiceFn chosen)
Open a dialog, for non-document callers: chosen runs from RunAnswers. Nothing without a backend.
void Open(const FileDialogProps& props, FileChoiceFn chosen, const UIContext* asker)
Open a dialog for a document: chosen runs in that document's next update after the answer arrives. Nothing without a backend.
void Answer(uint32_t id, std::vector<std::string> paths)
Report a result. Empty paths means cancelled.
void RunAnswers()
Deliver results to non-document callers. Called by the host.
void RunAnswersFor(const UIContext* asker)
Deliver results to asker. Called from its update.
void Forget(const UIContext* asker)
Drop asker's pending requests. Called when a document is destroyed.