Refactor: Разделил UI на модули
Разделил главный фрейм UI на отдельные модули: tab_bar, left_panel, right_panel и canvas_view. Это улучшает читаемость и поддерживает принцип единственной ответственности. Также изменил функцию `updateVisibleImageRect`, чтобы она возвращала `bool`, указывающий на необходимость перерисовки.
This commit is contained in:
31
src/ui/left_panel.zig
Normal file
31
src/ui/left_panel.zig
Normal file
@@ -0,0 +1,31 @@
|
||||
// Левая панель: инструменты для активного документа (scaling, тип рендера).
|
||||
const dvui = @import("dvui");
|
||||
const WindowContext = @import("../WindowContext.zig");
|
||||
|
||||
pub fn leftPanel(ctx: *WindowContext) void {
|
||||
var panel = dvui.box(
|
||||
@src(),
|
||||
.{ .dir = .vertical },
|
||||
.{ .expand = .vertical, .min_size_content = .{ .w = 200 }, .background = true },
|
||||
);
|
||||
{
|
||||
dvui.label(@src(), "Tools", .{}, .{});
|
||||
|
||||
const active_doc = ctx.activeDocument();
|
||||
if (active_doc) |doc| {
|
||||
const canvas = &doc.canvas;
|
||||
if (dvui.checkbox(@src(), &canvas.native_scaling, "Scaling", .{})) {}
|
||||
if (dvui.button(@src(), if (doc.cpu_render.type == .Gradient) "Gradient" else "Squares", .{}, .{})) {
|
||||
if (doc.cpu_render.type == .Gradient) {
|
||||
doc.cpu_render.type = .Squares;
|
||||
} else {
|
||||
doc.cpu_render.type = .Gradient;
|
||||
}
|
||||
canvas.redrawExample() catch {};
|
||||
}
|
||||
} else {
|
||||
dvui.label(@src(), "No document", .{}, .{});
|
||||
}
|
||||
}
|
||||
panel.deinit();
|
||||
}
|
||||
Reference in New Issue
Block a user