Первая версия тулбара

This commit is contained in:
2026-02-25 21:13:38 +03:00
parent 0d546782bb
commit 9202b527e4
9 changed files with 143 additions and 4 deletions

View File

@@ -9,11 +9,13 @@ const Size_i = basic_models.Size_i;
const Point2_f = @import("models/basic_models.zig").Point2_f;
const Color = dvui.Color;
const Toolbar = @import("Toolbar.zig");
const Canvas = @This();
allocator: std.mem.Allocator,
document: *Document,
render_engine: RenderEngine,
toolbar: Toolbar,
texture: ?dvui.Texture = null,
pos: dvui.Point = dvui.Point{ .x = 400, .y = 400 },
scroll: dvui.ScrollInfo = .{
@@ -30,15 +32,17 @@ cursor_document_point: ?Point2_f = null,
/// true — рисовать документ (render), false — пример (gradient/squares).
draw_document: bool = true,
pub fn init(allocator: std.mem.Allocator, document: *Document, engine: RenderEngine) Canvas {
pub fn init(allocator: std.mem.Allocator, document: *Document, engine: RenderEngine, toolbar: Toolbar) Canvas {
return .{
.allocator = allocator,
.document = document,
.render_engine = engine,
.toolbar = toolbar,
};
}
pub fn deinit(self: *Canvas) void {
self.toolbar.deinit();
if (self.texture) |texture| {
dvui.Texture.destroyLater(texture);
self.texture = null;