Jazz2::UI::Windows::FileDialog class

Picks a file to open or to save to.

Only files with the extension are listed, several can be separated by ;, e.g. ".it;.xm". The first one is added to a name typed without it. If it's empty, all files are listed. When opening, a file of the initial name is selected.

On a desktop, the whole computer can be browsed too, as the last place — the drives on Windows, / elsewhere — unless the file has to be in one of the places, see anywhere. A path can be typed into the row above the list.

Base classes

class Dialog
Window shown over the interface with a title, content and buttons.

Public static variables

static bool ShowHiddenFiles
Whether files and folders hidden by the system, or named with a dot first, are listed, until the application is closed.

Public static functions

static auto Show(Surface& surface, StringView title, FileDialogMode mode, SmallVectorImpl<FileRoot>&& roots, StringView extension, StringView initialDirectory, StringView initialName, Function<void(StringView)>&& onChosen, bool anywhere = true) -> FileDialog*
Shows a file dialog.

Constructors, destructors, conversion operators

FileDialog(StringView title, FileDialogMode mode, SmallVectorImpl<FileRoot>&& roots, StringView extension, StringView initialDirectory, StringView initialName, Function<void(StringView)>&& onChosen, bool anywhere = true)
Creates a new instance.
~FileDialog() override

Public functions

void SetSpecialEntries(SmallVectorImpl<FileSpecialEntry>&& entries, StringView selectedValue, Function<void(StringView)>&& onChosen)
Lists values that aren't files at the top of the list in every folder, only when opening.
auto Measure(const Context& context, Vector2f available) -> Vector2f override
Returns the size the element wants, in pixels.
void Update(float timeMult) override
Advances animations of the element and its children.

Public variables

Function<bool(StringView path, FileInfo& info)> InfoFunc
Reads what is shown about a file next to the list, its picture and details, returns false if there's nothing.
Function<bool(StringView path, FileKind& kind)> KindFunc
Tells how a file is shown in the list, returns false to show it as any other file.
bool Asynchronous
Whether KindFunc and InfoFunc may run on a thread of their own.
Function<void(StringView path, Function<void()>&& proceed)> ConfirmFunc
Asked before a file is chosen, while the dialog stays open, the file is chosen once it calls proceed.

Function documentation

Jazz2::UI::Windows::FileDialog::FileDialog(StringView title, FileDialogMode mode, SmallVectorImpl<FileRoot>&& roots, StringView extension, StringView initialDirectory, StringView initialName, Function<void(StringView)>&& onChosen, bool anywhere = true)

Creates a new instance.

If anywhere is false, files only of the places can be chosen, for a file that is referred to by its path in one of them.

void Jazz2::UI::Windows::FileDialog::SetSpecialEntries(SmallVectorImpl<FileSpecialEntry>&& entries, StringView selectedValue, Function<void(StringView)>&& onChosen)

Lists values that aren't files at the top of the list in every folder, only when opening.

The entry of selectedValue is selected, onChosen gets the value of the one chosen instead of a file.

Vector2f Jazz2::UI::Windows::FileDialog::Measure(const Context& context, Vector2f available) override

Returns the size the element wants, in pixels.

The available size is what the parent can give, a size without limit is a very large number.

Variable documentation

Function<bool(StringView path, FileInfo& info)> Jazz2::UI::Windows::FileDialog::InfoFunc

Reads what is shown about a file next to the list, its picture and details, returns false if there's nothing.

Asked once a file stays selected for a moment.

Function<bool(StringView path, FileKind& kind)> Jazz2::UI::Windows::FileDialog::KindFunc

Tells how a file is shown in the list, returns false to show it as any other file.

Asked once for each file as its row is first seen, only for a few of them in a frame, so it may read the start of the file.

bool Jazz2::UI::Windows::FileDialog::Asynchronous

Whether KindFunc and InfoFunc may run on a thread of their own.

They must touch nothing the user interface uses then. The rows show a dim icon until it's known, and the details of the selected file appear once they're read. Without threads they're asked as without it.

Function<void(StringView path, Function<void()>&& proceed)> Jazz2::UI::Windows::FileDialog::ConfirmFunc

Asked before a file is chosen, while the dialog stays open, the file is chosen once it calls proceed.

The dialog stays open if it doesn't, e.g. to ask whether to overwrite a file, so another name can be entered.