DVUI

init

Initialize and display only the fields provided. options: field options for all the fields to be displayed. default_value: An optional default value to be used whenever an instance of this type needs ot be created.

Example Usage - Do not display the .a field and display all other fields as sliders.

const color_options: dvui.struct_ui.StructOptions(dvui.Color) = .init(.{
.r = .{ .number = .{ .min = 0, .max = 255, .widget_type = .slider } },
.g = .{ .number = .{ .min = 0, .max = 255, .widget_type = .slider } },
.b = .{ .number = .{ .min = 0, .max = 255, .widget_type = .slider } },
}, .{ .r = 127, .g = 127, .b = 127, .a = 255 });

Parameters

#
options:std.enums.EnumFieldStruct( StructOptionsT.Key, ?StructOptionsT.Value, @as(?StructOptionsT.Value, null), )
std.enums.EnumFieldStruct( StructOptionsT.Key, ?StructOptionsT.Value, @as(?StructOptionsT.Value, null), )
default_value:?StructT
?StructT

Source

Implementation

#
pub fn init(
            options: std.enums.EnumFieldStruct(
                StructOptionsT.Key,
                ?StructOptionsT.Value,
                @as(?StructOptionsT.Value, null),
            ),
            comptime default_value: ?StructT,
        ) Self {
            return .{
                .field_options = .init(options),
                .default_value = default_value,
            };
        }