Рефакторинг ещё...

This commit is contained in:
2026-02-24 23:52:13 +03:00
parent e5dd455d14
commit 1d995995e7
7 changed files with 156 additions and 74 deletions

View File

@@ -10,6 +10,24 @@ pub const ShapeKind = enum {
broken,
};
const default_common_data = [_]PropertyData{
.{ .position = .{ .x = 0, .y = 0 } },
.{ .angle = 0 },
.{ .scale = .{ .scale_x = 1, .scale_y = 1 } },
.{ .visible = true },
.{ .opacity = 1.0 },
.{ .locked = false },
.{ .stroke_rgba = 0x000000FF },
};
pub const defaultCommonProperties: [default_common_data.len]Property = blk: {
var result: [default_common_data.len]Property = undefined;
for (default_common_data, &result) |d, *p| {
p.* = .{ .data = d };
}
break :blk result;
};
shape: ShapeKind,
properties: std.ArrayList(Property),
children: std.ArrayList(Object),
@@ -29,7 +47,8 @@ pub fn setProperty(self: *Object, allocator: std.mem.Allocator, prop: Property)
return;
}
}
try self.properties.append(allocator, prop);
std.debug.print("Property not found: {s}\n", .{@tagName(prop.data)});
return error.PropertyNotFound;
}
pub fn addChild(self: *Object, allocator: std.mem.Allocator, template: Object) !void {