ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
dialog.h
Go to the documentation of this file.
1
8
9#ifndef ASW_DIALOG_H
10#define ASW_DIALOG_H
11
12#include <optional>
13#include <string>
14#include <vector>
15
16namespace asw::dialog {
17
23void info(const std::string& title, const std::string& message);
24
30void warn(const std::string& title, const std::string& message);
31
37void error(const std::string& title, const std::string& message);
38
46bool confirm(const std::string& title, const std::string& message);
47
49enum class FileMode {
50 Open,
51 Save,
52};
53
55struct FileFilter {
57 std::string name;
58
61 std::string pattern;
62};
63
74bool request_file(FileMode mode, const std::string& default_location = "",
75 const std::vector<FileFilter>& filters = { });
76
81bool is_file_pending();
82
89std::optional<std::string> take_file();
90
91} // namespace asw::dialog
92
93#endif // ASW_DIALOG_H
FileMode
Kind of file chooser.
Definition dialog.h:49
void warn(const std::string &title, const std::string &message)
Show a warning message box. Blocks until it is closed.
Definition dialog.cpp:45
void error(const std::string &title, const std::string &message)
Show an error message box. Blocks until it is closed.
Definition dialog.cpp:50
bool confirm(const std::string &title, const std::string &message)
Ask a yes or no question. Blocks until it is answered.
Definition dialog.cpp:55
std::optional< std::string > take_file()
Take the file the user chose. Returns it once, then empty until the next chooser.
Definition dialog.cpp:117
void info(const std::string &title, const std::string &message)
Show an information message box. Blocks until it is closed.
Definition dialog.cpp:40
bool is_file_pending()
Check if a file chooser is open.
Definition dialog.cpp:112
bool request_file(FileMode mode, const std::string &default_location="", const std::vector< FileFilter > &filters={ })
Open a native file chooser. It does not block, the chosen file arrives later through take_file()....
Definition dialog.cpp:76
Filter shown in a file chooser.
Definition dialog.h:55
std::string name
Name shown to the user, for example "Levels".
Definition dialog.h:57
std::string pattern
Semicolon separated extensions without dots, for example "xml;json", or "*" for all files.
Definition dialog.h:61