json сохранение
This commit is contained in:
@@ -27,6 +27,17 @@ pub const OpenDocument = struct {
|
||||
self.selected_object_id = null;
|
||||
}
|
||||
|
||||
pub fn initWithDocument(allocator: std.mem.Allocator, self: *OpenDocument, doc: Document) void {
|
||||
self.document = doc;
|
||||
self.cpu_render = CpuRenderEngine.init(allocator, .Squares);
|
||||
self.canvas = Canvas.init(
|
||||
allocator,
|
||||
&self.document,
|
||||
(&self.cpu_render).renderEngine(),
|
||||
);
|
||||
self.selected_object_id = null;
|
||||
}
|
||||
|
||||
pub fn deinit(self: *OpenDocument) void {
|
||||
self.document.deinit();
|
||||
self.canvas.deinit();
|
||||
@@ -73,6 +84,16 @@ pub fn addNewDocument(self: *WindowContext) !void {
|
||||
self.active_document_index = self.documents.items.len - 1;
|
||||
}
|
||||
|
||||
pub fn addDocument(self: *WindowContext, doc: Document) !void {
|
||||
const ptr = try self.allocator.create(OpenDocument);
|
||||
errdefer self.allocator.destroy(ptr);
|
||||
var doc_mut = doc;
|
||||
errdefer doc_mut.deinit();
|
||||
OpenDocument.initWithDocument(self.allocator, ptr, doc_mut);
|
||||
try self.documents.append(self.allocator, ptr);
|
||||
self.active_document_index = self.documents.items.len - 1;
|
||||
}
|
||||
|
||||
pub fn setActiveDocument(self: *WindowContext, index: usize) void {
|
||||
if (index < self.documents.items.len) {
|
||||
self.active_document_index = index;
|
||||
|
||||
Reference in New Issue
Block a user