какое то скроллирование

This commit is contained in:
2025-12-18 21:49:01 +03:00
parent b852384322
commit bb825d0225
2 changed files with 44 additions and 15 deletions

View File

@@ -9,6 +9,11 @@ canvas_texture: ?dvui.Texture = null,
canvas_width: u32 = 400,
canvas_height: u32 = 300,
canvas_pos: dvui.Point = dvui.Point{ .x = 0, .y = 0 },
canvas_scroll: dvui.ScrollInfo = .{
.vertical = .given,
.horizontal = .given,
.virtual_size = .{ .w = 2000, .h = 2000 },
},
pub fn init(allocator: std.mem.Allocator) WindowContext {
return .{
@@ -61,6 +66,12 @@ pub fn fillRandomColor(self: *WindowContext) !void {
// Создать новую текстуру из пиксельных данных
self.canvas_texture = try dvui.textureCreate(pixels, self.canvas_width, self.canvas_height, .linear);
// Дать скроллам ощутимый диапазон сразу (минимум 2000x2000)
self.canvas_scroll.virtual_size = .{
.w = @max(2000, @as(f32, @floatFromInt(self.canvas_width))),
.h = @max(2000, @as(f32, @floatFromInt(self.canvas_height))),
};
}
/// Отобразить canvas в UI