Тулзы перенесены в свой каталог

This commit is contained in:
2026-02-26 19:02:36 +03:00
parent bf63729124
commit a1f31d76c7
9 changed files with 11 additions and 11 deletions

43
src/toolbar/Toolbar.zig Normal file
View File

@@ -0,0 +1,43 @@
const Tool = @import("Tool.zig");
const Toolbar = @This();
pub const ToolDescriptor = struct {
name: []const u8,
icon_tvg: []const u8,
implementation: *const Tool.Tool,
};
tools: []const ToolDescriptor,
selected_index: ?usize,
pub fn init(tools_list: []const ToolDescriptor) Toolbar {
return .{
.tools = tools_list,
.selected_index = null,
};
}
pub fn deinit(_: *Toolbar) void {}
pub fn currentDescriptor(self: *const Toolbar) ?*const ToolDescriptor {
if (self.tools.len == 0) return null;
if (self.selected_index) |index| {
return &self.tools[index];
}
return null;
}
pub fn select(self: *Toolbar, index: ?usize) void {
if (index == self.selected_index) {
self.selected_index = null;
return;
}
if (index) |i| {
if (i < self.tools.len) {
self.selected_index = i;
}
} else {
self.selected_index = null;
}
}