feat: select widget styles based on widget type

This commit is contained in:
CJ van den Berg 2025-08-13 12:58:05 +02:00
parent fbc49c3dab
commit bcfd17a0e2
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
7 changed files with 81 additions and 37 deletions

View file

@ -14,6 +14,7 @@ pub const scroll_lines = 3;
pub fn Options(context: type) type {
return struct {
ctx: Context,
style: Widget.Style.Type,
on_click: *const fn (ctx: context, button: *Button.State(*State(Context))) void = do_nothing,
on_click4: *const fn (menu: **State(Context), button: *Button.State(*State(Context))) void = do_nothing_click,
@ -60,7 +61,7 @@ pub fn Options(context: type) type {
pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Plane, opts: Options(ctx_type)) !*State(ctx_type) {
const self = try allocator.create(State(ctx_type));
errdefer allocator.destroy(self);
const container = try WidgetList.createHStyled(allocator, parent, @typeName(@This()), .dynamic, Widget.Style.thick_boxed);
const container = try WidgetList.createHStyled(allocator, parent, @typeName(@This()), .dynamic, opts.style);
self.* = .{
.allocator = allocator,
.menu = try WidgetList.createV(allocator, container.plane, @typeName(@This()), .dynamic),