DVUI

extendId

Make a unique id from src and id_extra, possibly starting with start (usually a parent widget id). This is how the initial parent widget id is created, and also toasts and dialogs from other threads.

See Widget.extendId which calls this with the widget id as start.

dvui.parentGet().extendId(@src(), id_extra)

is how new widgets get their id, and can be used to make a unique id without making a widget.

Parameters

#
start:?Id
?Id
src:std.builtin.SourceLocation
std.builtin.SourceLocation
id_extra:usize
usize

Source

Implementation

#
pub fn extendId(start: ?Id, src: std.builtin.SourceLocation, id_extra: usize) Id {
        var hash = fnv.init();
        if (start) |s| {
            hash.value = s.asU64();
        }
        hash.update(std.mem.asBytes(&src.module.ptr));
        hash.update(std.mem.asBytes(&src.file.ptr));
        hash.update(std.mem.asBytes(&src.line));
        hash.update(std.mem.asBytes(&src.column));
        hash.update(std.mem.asBytes(&id_extra));
        return @enumFromInt(hash.final());
    }