Окно хранит документы
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const std = @import("std");
|
||||
const Canvas = @import("Canvas.zig");
|
||||
const CpuRenderEngine = @import("render/CpuRenderEngine.zig");
|
||||
const Document = @import("models/Document.zig");
|
||||
|
||||
const WindowContext = @This();
|
||||
|
||||
@@ -8,6 +9,8 @@ allocator: std.mem.Allocator,
|
||||
canvas: Canvas,
|
||||
cpu_render: *CpuRenderEngine,
|
||||
frame_index: u64,
|
||||
/// Открытые документы в текущем окне
|
||||
documents: std.array_list.Managed(Document),
|
||||
|
||||
pub fn init(allocator: std.mem.Allocator) !WindowContext {
|
||||
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.frame_index = 0;
|
||||
self.documents = std.array_list.Managed(Document).init(allocator);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn deinit(self: *WindowContext) void {
|
||||
self.documents.deinit();
|
||||
self.canvas.deinit();
|
||||
self.allocator.destroy(self.cpu_render);
|
||||
}
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
// Файл векторного документа
|
||||
const basic_models = @import("basic_models.zig");
|
||||
const Size = basic_models.Size;
|
||||
|
||||
const Document = @This();
|
||||
|
||||
size: Size,
|
||||
|
||||
@@ -9,3 +9,8 @@ pub const ImageSize = struct {
|
||||
w: u32,
|
||||
h: u32,
|
||||
};
|
||||
|
||||
pub const Size = struct {
|
||||
width: f32,
|
||||
height: f32,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user