refactor: add panel border to inspector_view

This commit is contained in:
CJ van den Berg 2025-12-11 19:00:07 +01:00
parent 950c5af01d
commit 82257ee4e3
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -12,6 +12,7 @@ const EventHandler = @import("EventHandler");
const tui = @import("tui.zig"); const tui = @import("tui.zig");
const Widget = @import("Widget.zig"); const Widget = @import("Widget.zig");
const WidgetList = @import("WidgetList.zig");
const ed = @import("editor.zig"); const ed = @import("editor.zig");
pub const name = @typeName(Self); pub const name = @typeName(Self);
@ -22,17 +23,21 @@ theme: ?*const Widget.Theme = null,
last_node: usize = 0, last_node: usize = 0,
const Self = @This(); const Self = @This();
const widget_type: Widget.Type = .panel;
pub fn create(allocator: Allocator, parent: Plane) !Widget { pub fn create(allocator: Allocator, parent: Plane) !Widget {
const editor = tui.get_active_editor() orelse return error.NotFound; const editor = tui.get_active_editor() orelse return error.NotFound;
const self = try allocator.create(Self); const self = try allocator.create(Self);
errdefer allocator.destroy(self); errdefer allocator.destroy(self);
const container = try WidgetList.createHStyled(allocator, parent, "panel_frame", .dynamic, widget_type);
self.* = .{ self.* = .{
.plane = try Plane.init(&(Widget.Box{}).opts_vscroll(name), parent), .plane = try Plane.init(&(Widget.Box{}).opts_vscroll(name), parent),
.editor = editor, .editor = editor,
}; };
try editor.handlers.add(EventHandler.bind(self, ed_receive)); try editor.handlers.add(EventHandler.bind(self, ed_receive));
return Widget.to(self); container.ctx = self;
try container.add(Widget.to(self));
return container.widget();
} }
pub fn deinit(self: *Self, allocator: Allocator) void { pub fn deinit(self: *Self, allocator: Allocator) void {