Canvas в отдельном файле
This commit is contained in:
12
src/main.zig
12
src/main.zig
@@ -90,7 +90,7 @@ fn gui_frame(ctx: *WindowContext) bool {
|
||||
ctx.fillRandomColor() catch |err| {
|
||||
std.debug.print("Error filling canvas: {}\n", .{err});
|
||||
};
|
||||
ctx.canvas_pos = .{ .x = 400, .y = 400 };
|
||||
ctx.canvas.pos = .{ .x = 400, .y = 400 };
|
||||
}
|
||||
}
|
||||
left_panel.deinit();
|
||||
@@ -128,7 +128,7 @@ fn gui_frame(ctx: *WindowContext) bool {
|
||||
var scroll = dvui.scrollArea(
|
||||
@src(),
|
||||
.{
|
||||
.scroll_info = &ctx.canvas_scroll,
|
||||
.scroll_info = &ctx.canvas.scroll,
|
||||
.vertical_bar = .auto,
|
||||
.horizontal_bar = .auto,
|
||||
},
|
||||
@@ -137,14 +137,14 @@ fn gui_frame(ctx: *WindowContext) bool {
|
||||
{
|
||||
// Отобразить canvas внутри scroll area.
|
||||
// ScrollArea сам двигает дочерние виджеты, поэтому margin не нужен.
|
||||
if (ctx.canvas_texture) |texture| {
|
||||
if (ctx.canvas.texture) |texture| {
|
||||
_ = dvui.image(@src(), .{
|
||||
.source = .{ .texture = texture },
|
||||
}, .{
|
||||
.margin = .{ .x = ctx.canvas_pos.x, .y = ctx.canvas_pos.y },
|
||||
.margin = .{ .x = ctx.canvas.pos.x, .y = ctx.canvas.pos.y },
|
||||
.min_size_content = .{
|
||||
.w = @floatFromInt(ctx.canvas_width),
|
||||
.h = @floatFromInt(ctx.canvas_height),
|
||||
.w = @floatFromInt(ctx.canvas.width),
|
||||
.h = @floatFromInt(ctx.canvas.height),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user