DVUI

add

Add a dialog to be displayed on the GUI thread during Window.end.

Returns an locked mutex that must be unlocked by the caller. Caller does any Window.dataSet calls before unlocking the mutex to ensure that data is available before the dialog is displayed.

Can be called from any thread.

Parameters

#
self:*Dialogs
*Dialogs
gpa:std.mem.Allocator
std.mem.Allocator
dialog:Dialog
Dialog

Source

Implementation

#
pub fn add(self: *Dialogs, gpa: std.mem.Allocator, dialog: Dialog) !*Io.Mutex {
    const io = dvui.io;
    self.mutex.lockUncancelable(io);
    errdefer self.mutex.unlock(io);
    for (self.stack.items) |*d| {
        if (d.id == dialog.id) {
            d.* = dialog;
            break;
        }
    } else {
        try self.stack.append(gpa, dialog);
    }
    return &self.mutex;
}