Разделил главный фрейм UI на отдельные модули: tab_bar, left_panel, right_panel и canvas_view. Это улучшает читаемость и поддерживает принцип единственной ответственности. Также изменил функцию `updateVisibleImageRect`, чтобы она возвращала `bool`, указывающий на необходимость перерисовки.
44 lines
1.4 KiB
Zig
44 lines
1.4 KiB
Zig
// Корневой кадр UI: разметка и сборка панелей.
|
|
const dvui = @import("dvui");
|
|
const WindowContext = @import("../WindowContext.zig");
|
|
const tab_bar = @import("tab_bar.zig");
|
|
const left_panel = @import("left_panel.zig");
|
|
const right_panel = @import("right_panel.zig");
|
|
|
|
/// Отрисовать один кадр GUI. Возвращает false при закрытии окна/выходе.
|
|
pub fn guiFrame(ctx: *WindowContext) bool {
|
|
for (dvui.events()) |*e| {
|
|
if (e.evt == .window and e.evt.window.action == .close) return false;
|
|
if (e.evt == .app and e.evt.app.action == .quit) return false;
|
|
}
|
|
|
|
var root = dvui.box(
|
|
@src(),
|
|
.{ .dir = .vertical },
|
|
.{ .expand = .both, .background = true, .style = .window },
|
|
);
|
|
{
|
|
tab_bar.tabBar(ctx);
|
|
|
|
var content_row = dvui.box(@src(), .{ .dir = .horizontal }, .{ .expand = .both });
|
|
{
|
|
left_panel.leftPanel(ctx);
|
|
|
|
var back = dvui.box(
|
|
@src(),
|
|
.{ .dir = .horizontal },
|
|
.{ .expand = .both, .padding = dvui.Rect.all(12), .background = true },
|
|
);
|
|
{
|
|
right_panel.rightPanel(ctx);
|
|
}
|
|
back.deinit();
|
|
}
|
|
content_row.deinit();
|
|
}
|
|
root.deinit();
|
|
|
|
ctx.frame_index += 1;
|
|
return true;
|
|
}
|