правильный скролл для свойств
This commit is contained in:
@@ -13,21 +13,28 @@ pub fn canvasView(canvas: *Canvas, selected_object: ?*Document.Object, content_r
|
||||
{
|
||||
var overlay = dvui.overlay(@src(), .{ .expand = .both });
|
||||
{
|
||||
const overlay_parent = dvui.parentGet();
|
||||
var scroll = dvui.scrollArea(
|
||||
@src(),
|
||||
.{
|
||||
.scroll_info = &canvas.scroll,
|
||||
.vertical_bar = .auto,
|
||||
.horizontal_bar = .auto,
|
||||
.process_events_after = false,
|
||||
},
|
||||
.{
|
||||
.expand = .both,
|
||||
.background = false,
|
||||
},
|
||||
.{ .expand = .both, .background = false },
|
||||
);
|
||||
{
|
||||
drawCanvasContent(canvas, scroll);
|
||||
handleCanvasZoom(canvas, scroll);
|
||||
handleCanvasMouse(canvas, scroll);
|
||||
}
|
||||
scroll.deinit();
|
||||
|
||||
const scroll_parent = dvui.parentGet();
|
||||
dvui.parentSet(overlay_parent);
|
||||
|
||||
// Тулбар поверх scroll
|
||||
var toolbar_box = dvui.box(
|
||||
@@ -38,7 +45,7 @@ pub fn canvasView(canvas: *Canvas, selected_object: ?*Document.Object, content_r
|
||||
.background = false,
|
||||
.gravity_x = 0.0,
|
||||
.gravity_y = 0.0,
|
||||
.margin = dvui.Rect{ .x = 8, .y = 8 },
|
||||
.margin = dvui.Rect{ .x = 16, .y = 16 },
|
||||
},
|
||||
);
|
||||
{
|
||||
@@ -58,7 +65,7 @@ pub fn canvasView(canvas: *Canvas, selected_object: ?*Document.Object, content_r
|
||||
.background = false,
|
||||
.gravity_x = 1.0,
|
||||
.gravity_y = 0.0,
|
||||
.margin = dvui.Rect{ .w = 8, .y = 8 },
|
||||
.margin = dvui.Rect{ .w = 32, .y = 16, .h = 100 },
|
||||
},
|
||||
);
|
||||
{
|
||||
@@ -70,6 +77,30 @@ pub fn canvasView(canvas: *Canvas, selected_object: ?*Document.Object, content_r
|
||||
}
|
||||
|
||||
dvui.label(@src(), "Canvas", .{}, .{ .gravity_x = 0.5, .gravity_y = 0.0 });
|
||||
|
||||
if (canvas.properties_rect_scale) |prs| {
|
||||
for (dvui.events()) |*e| {
|
||||
if (e.handled) continue;
|
||||
if (e.evt != .mouse) continue;
|
||||
const mouse = &e.evt.mouse;
|
||||
if (mouse.action != .wheel_x and mouse.action != .wheel_y) continue;
|
||||
const pt = prs.pointFromPhysical(mouse.p);
|
||||
const r = prs.r;
|
||||
if (pt.x >= 0 and pt.x * prs.s < r.w and pt.y >= 0 and pt.y * prs.s < r.h) {
|
||||
e.handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!scroll.init_opts.process_events_after) {
|
||||
if (scroll.scroll) |*sc| {
|
||||
dvui.clipSet(sc.prevClip);
|
||||
sc.processEventsAfter();
|
||||
}
|
||||
}
|
||||
|
||||
dvui.parentSet(scroll_parent);
|
||||
scroll.deinit();
|
||||
}
|
||||
overlay.deinit();
|
||||
}
|
||||
@@ -246,7 +277,6 @@ fn drawToolbar(canvas: *Canvas) void {
|
||||
.{
|
||||
.gravity_x = 0.0,
|
||||
.gravity_y = 0.0,
|
||||
.margin = dvui.Rect{ .x = 8, .y = 8 },
|
||||
.padding = dvui.Rect.all(6),
|
||||
.corner_radius = dvui.Rect.all(8),
|
||||
.background = true,
|
||||
@@ -280,7 +310,6 @@ fn drawPropertiesPanel(canvas: *Canvas, selected_object: *Document.Object) void
|
||||
.{
|
||||
.gravity_x = 1.0,
|
||||
.gravity_y = 0.0,
|
||||
.margin = dvui.Rect{ .x = 8, .y = 8 },
|
||||
.padding = dvui.Rect.all(8),
|
||||
.corner_radius = dvui.Rect.all(8),
|
||||
.background = true,
|
||||
@@ -290,10 +319,19 @@ fn drawPropertiesPanel(canvas: *Canvas, selected_object: *Document.Object) void
|
||||
);
|
||||
{
|
||||
dvui.label(@src(), "Properties", .{}, .{});
|
||||
var scroll = dvui.scrollArea(@src(), .{
|
||||
.horizontal = .none,
|
||||
.vertical = .auto,
|
||||
}, .{
|
||||
.expand = .both,
|
||||
});
|
||||
{
|
||||
for (selected_object.properties.items, 0..) |*prop, i| {
|
||||
drawPropertyEditor(canvas, selected_object, prop, i);
|
||||
}
|
||||
}
|
||||
scroll.deinit();
|
||||
}
|
||||
panel.deinit();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user