Окно хранит документы

This commit is contained in:
2026-02-22 00:55:08 +03:00
parent fd0ba8b583
commit 7dc7069186
3 changed files with 16 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
const std = @import("std"); const std = @import("std");
const Canvas = @import("Canvas.zig"); const Canvas = @import("Canvas.zig");
const CpuRenderEngine = @import("render/CpuRenderEngine.zig"); const CpuRenderEngine = @import("render/CpuRenderEngine.zig");
const Document = @import("models/Document.zig");
const WindowContext = @This(); const WindowContext = @This();
@@ -8,6 +9,8 @@ allocator: std.mem.Allocator,
canvas: Canvas, canvas: Canvas,
cpu_render: *CpuRenderEngine, cpu_render: *CpuRenderEngine,
frame_index: u64, frame_index: u64,
/// Открытые документы в текущем окне
documents: std.array_list.Managed(Document),
pub fn init(allocator: std.mem.Allocator) !WindowContext { pub fn init(allocator: std.mem.Allocator) !WindowContext {
var self: WindowContext = undefined; var self: WindowContext = undefined;
@@ -20,11 +23,13 @@ pub fn init(allocator: std.mem.Allocator) !WindowContext {
self.canvas = Canvas.init(allocator, self.cpu_render.renderEngine()); self.canvas = Canvas.init(allocator, self.cpu_render.renderEngine());
self.frame_index = 0; self.frame_index = 0;
self.documents = std.array_list.Managed(Document).init(allocator);
return self; return self;
} }
pub fn deinit(self: *WindowContext) void { pub fn deinit(self: *WindowContext) void {
self.documents.deinit();
self.canvas.deinit(); self.canvas.deinit();
self.allocator.destroy(self.cpu_render); self.allocator.destroy(self.cpu_render);
} }

View File

@@ -1 +1,6 @@
// Файл векторного документа const basic_models = @import("basic_models.zig");
const Size = basic_models.Size;
const Document = @This();
size: Size,

View File

@@ -9,3 +9,8 @@ pub const ImageSize = struct {
w: u32, w: u32,
h: u32, h: u32,
}; };
pub const Size = struct {
width: f32,
height: f32,
};