Refactor: Разделил UI на модули
Разделил главный фрейм UI на отдельные модули: tab_bar, left_panel, right_panel и canvas_view. Это улучшает читаемость и поддерживает принцип единственной ответственности. Также изменил функцию `updateVisibleImageRect`, чтобы она возвращала `bool`, указывающий на необходимость перерисовки.
This commit is contained in:
27
src/ui/tab_bar.zig
Normal file
27
src/ui/tab_bar.zig
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user