Refactor: Разделил UI на модули

Разделил главный фрейм UI на отдельные модули: tab_bar, left_panel, right_panel и canvas_view. Это улучшает читаемость и поддерживает принцип единственной ответственности.
Также изменил функцию `updateVisibleImageRect`, чтобы она возвращала `bool`, указывающий на необходимость перерисовки.
This commit is contained in:
2026-02-23 19:58:49 +03:00
parent 6ae927c4b7
commit b30865d105
7 changed files with 275 additions and 243 deletions

27
src/ui/tab_bar.zig Normal file
View File

@@ -0,0 +1,27 @@
// Верхняя строка: вкладки документов + кнопка «Новый».
const std = @import("std");
const dvui = @import("dvui");
const WindowContext = @import("../WindowContext.zig");
pub fn tabBar(ctx: *WindowContext) void {
var bar = dvui.box(
@src(),
.{ .dir = .horizontal },
.{ .expand = .horizontal, .min_size_content = .{ .h = 32 }, .background = true, .padding = dvui.Rect.all(4) },
);
{
for (ctx.documents.items, 0..) |_, i| {
var buf: [32]u8 = undefined;
const label = std.fmt.bufPrint(&buf, "Doc {d}", .{i + 1}) catch "Doc";
if (dvui.button(@src(), label, .{}, .{ .id_extra = i })) {
ctx.setActiveDocument(i);
}
}
if (dvui.button(@src(), "+", .{}, .{})) {
ctx.addNewDocument() catch |err| {
std.debug.print("addNewDocument error: {}\n", .{err});
};
}
}
bar.deinit();
}