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
asw::dialog Namespace Reference

Classes

struct  FileFilter
 Filter shown in a file chooser. More...
 

Enumerations

enum class  FileMode { Open , Save }
 Kind of file chooser. More...
 

Functions

void info (const std::string &title, const std::string &message)
 Show an information message box. Blocks until it is closed.
 
void warn (const std::string &title, const std::string &message)
 Show a warning message box. Blocks until it is closed.
 
void error (const std::string &title, const std::string &message)
 Show an error message box. Blocks until it is closed.
 
bool confirm (const std::string &title, const std::string &message)
 Ask a yes or no question. Blocks until it is answered.
 
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(). Only one chooser can be open at a time.
 
bool is_file_pending ()
 Check if a file chooser is open.
 
std::optional< std::string > take_file ()
 Take the file the user chose. Returns it once, then empty until the next chooser.
 

Enumeration Type Documentation

◆ FileMode

enum class asw::dialog::FileMode
strong

Kind of file chooser.

Enumerator
Open 
Save 

Definition at line 49 of file dialog.h.

Function Documentation

◆ confirm()

bool asw::dialog::confirm ( const std::string & title,
const std::string & message )

Ask a yes or no question. Blocks until it is answered.

Parameters
titleThe title of the message box.
messageThe question to ask.
Returns
true - If yes was chosen.
false - If no was chosen, or the box was closed.

Definition at line 55 of file dialog.cpp.

◆ error()

void asw::dialog::error ( const std::string & title,
const std::string & message )

Show an error message box. Blocks until it is closed.

Parameters
titleThe title of the message box.
messageThe message to show.

Definition at line 50 of file dialog.cpp.

◆ info()

void asw::dialog::info ( const std::string & title,
const std::string & message )

Show an information message box. Blocks until it is closed.

Parameters
titleThe title of the message box.
messageThe message to show.

Definition at line 40 of file dialog.cpp.

◆ is_file_pending()

bool asw::dialog::is_file_pending ( )

Check if a file chooser is open.

Returns
true - While waiting for the user to choose.

Definition at line 112 of file dialog.cpp.

◆ request_file()

bool asw::dialog::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(). Only one chooser can be open at a time.

Parameters
modeOpen an existing file, or choose where to save one.
default_locationFolder or file the chooser starts at, empty for the system default.
filtersFilters to offer, empty for all files.
Returns
true - If the chooser was opened.
false - If a chooser is already open.

Definition at line 76 of file dialog.cpp.

◆ take_file()

std::optional< std::string > asw::dialog::take_file ( )

Take the file the user chose. Returns it once, then empty until the next chooser.

Returns
The chosen path, or empty while waiting, after a cancel, or on failure.

Definition at line 117 of file dialog.cpp.

◆ warn()

void asw::dialog::warn ( const std::string & title,
const std::string & message )

Show a warning message box. Blocks until it is closed.

Parameters
titleThe title of the message box.
messageThe message to show.

Definition at line 45 of file dialog.cpp.