david-vanderson / dvui

Other
346 stars 26 forks source link

Better structEntry field options and example #114

Closed VisenDev closed 1 week ago

VisenDev commented 2 weeks ago

Demonstrated advanced structEntry configuration with FieldOptions

            const color_field_options = .{ .fields = .{
                .r = .{ .min = 0, .max = 255, .widget_type = .slider },
                .g = .{ .min = 0, .max = 255, .widget_type = .slider },
                .b = .{ .min = 0, .max = 255, .widget_type = .slider },
                .a = .{ .disabled = true },
            } };

            try dvui.structEntryExAlloc(@src(), "dvui.Theme", dvui.Theme, dvui.themeGet(), .{ .fields = .{
                .dark = .{ .widget_type = .toggle },
                .style_err = .{ .disabled = true },
                .style_accent = .{ .disabled = true },
                .font_body = .{ .disabled = true },
                .font_heading = .{ .disabled = true },
                .font_caption = .{ .disabled = true },
                .font_caption_heading = .{ .disabled = true },
                .font_title = .{ .disabled = true },
                .font_title_1 = .{ .disabled = true },
                .font_title_2 = .{ .disabled = true },
                .font_title_3 = .{ .disabled = true },
                .font_title_4 = .{ .disabled = true },
                .color_accent = color_field_options,
                .color_err = color_field_options,
                .color_text = color_field_options,
                .color_text_press = color_field_options,
                .color_fill = color_field_options,
                .color_fill_window = color_field_options,
                .color_fill_control = color_field_options,
                .color_fill_hover = color_field_options,
                .color_fill_press = color_field_options,
                .color_border = color_field_options,
            } });
Screenshot 2024-09-03 at 10 45 23 AM
VisenDev commented 1 week ago

TODO

VisenDev commented 1 week ago

@david-vanderson I'm ready for this to be merged if you approve.

david-vanderson commented 1 week ago

Looks great - thanks!

Instead of the sliders, you could use sliderEntry() - you probably already tried it, but just in case.

VisenDev commented 1 week ago

Instead of the sliders, you could use sliderEntry() - you probably already tried it, but just in case.

Oh I didn't think of that. I can work on that in a future pr.