DVUI

initNoFmtAllocator

The allocator argument will be used to deallocator label_str on when deinit is called.

Assumes the label_str is valid utf8

It's expected to call this when self is undefined

Parameters

#
self:*LabelWidget
*LabelWidget
src:std.builtin.SourceLocation
std.builtin.SourceLocation
label_str:[]const u8
[]const u8
allocator:?std.mem.Allocator
?std.mem.Allocator
init_opts:InitOptions
InitOptions
opts:Options
Options

Source

Implementation

#
pub fn initNoFmtAllocator(self: *LabelWidget, src: std.builtin.SourceLocation, label_str: []const u8, allocator: ?std.mem.Allocator, init_opts: InitOptions, opts: Options) void {
    const options = defaults.override(opts);
    const lsize = options.fontGet().textSize(label_str);
    var size = lsize;
    if (opts.rotationGet() != 0.0) {
        var t: dvui.Triangles = .{ .vertexes = &.{}, .indices = &.{}, .bounds = .{ .w = size.w, .h = size.h } };

        t.rotate(.{}, opts.rotationGet());
        size.w = t.bounds.w;
        size.h = t.bounds.h;
    }
    size = Size.max(size, options.min_size_contentGet());
    self.* = .{
        .wd = .init(src, .{}, options.override(.{ .min_size_content = size })),
        .init_options = init_opts,
        .label_str = label_str,
        .label_size = lsize,
        .allocator = allocator,
        .ellipsized = false,
    };

    self.data().register();
    self.data().borderAndBackground(.{});

    if (self.data().accesskit_node()) |ak_node| {
        dvui.AccessKit.nodeSetValueWithLength(ak_node, self.label_str.ptr, self.label_str.len);
        if (self.data().options.label == null) {
            dvui.AccessKit.nodeSetLabelWithLength(ak_node, self.label_str.ptr, self.label_str.len);
        }
    }
}