refactor: improve WidgetList.addP style

This commit is contained in:
CJ van den Berg 2024-10-09 20:46:11 +02:00
parent 07fdf30e9f
commit c5e7b1f896
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -16,7 +16,7 @@ pub const Layout = Widget.Layout;
const WidgetState = struct {
widget: Widget,
layout: Layout = .{},
layout: Layout = .dynamic,
};
plane: Plane,
@ -85,8 +85,10 @@ pub fn add(self: *Self, w_: Widget) !void {
pub fn addP(self: *Self, w_: Widget) !*Widget {
var w: *WidgetState = try self.widgets.addOne();
w.widget = w_;
w.layout = w_.layout();
w.* = .{
.widget = w_,
.layout = w_.layout(),
};
return &w.widget;
}