Добавлять объекты в родителя
This commit is contained in:
@@ -30,6 +30,17 @@ pub fn addObject(self: *Document, template: Object) !void {
|
||||
try self.objects.append(self.allocator, obj);
|
||||
}
|
||||
|
||||
/// Добавляет объект в документ: как ребёнка родителя (если id найден), иначе в корень.
|
||||
pub fn addObjectUnderParentId(self: *Document, parent_id: ?u64, template: Object) !void {
|
||||
if (parent_id) |id| {
|
||||
if (self.findObjectById(id)) |parent| {
|
||||
try parent.addChild(self.allocator, template, &self.next_object_id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
try self.addObject(template);
|
||||
}
|
||||
|
||||
pub fn addShape(self: *Document, parent: ?*Object, shape_kind: Object.ShapeKind) !void {
|
||||
const obj = try shape.createObject(self.allocator, shape_kind);
|
||||
if (parent) |p| {
|
||||
|
||||
Reference in New Issue
Block a user