Дерево объектов хорошее
This commit is contained in:
@@ -8,7 +8,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
|
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "Zivro",
|
.name = "Zivro",
|
||||||
.use_llvm = true,
|
.use_llvm = optimize == .Debug,
|
||||||
.root_module = b.createModule(.{
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("src/main.zig"),
|
.root_source_file = b.path("src/main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
|
|||||||
@@ -31,25 +31,32 @@ fn objectTreeRow(open_doc: *WindowContext.OpenDocument, obj: *Object, depth: u32
|
|||||||
|
|
||||||
const focus_color = dvui.themeGet().focus;
|
const focus_color = dvui.themeGet().focus;
|
||||||
|
|
||||||
// Визуально строка — это box с подсветкой по hover/selected, а не кнопка.
|
|
||||||
var row = dvui.box(
|
var row = dvui.box(
|
||||||
@src(),
|
@src(),
|
||||||
.{ .dir = .horizontal },
|
.{ .dir = .horizontal },
|
||||||
.{
|
.{
|
||||||
.id_extra = row_id,
|
.id_extra = row_id,
|
||||||
.expand = .horizontal,
|
.expand = .horizontal,
|
||||||
// Постоянной рамки нет; лёгкая заливка по hover и более яркая по selected.
|
|
||||||
// .color_fill = if (is_selected) focus_color.opacity(0.35) else null,
|
|
||||||
.color_fill_hover = focus_color.opacity(0.18),
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
var hovered: bool = false;
|
var hovered: bool = false;
|
||||||
const row_data = row.data();
|
const row_data = row.data();
|
||||||
if (dvui.clicked(row_data, .{
|
var select_row: bool = false;
|
||||||
.hovered = &hovered,
|
|
||||||
})) {
|
// Ручная обработка hover/click по строке без пометки события как handled,
|
||||||
object_callback.* = .{ .select = obj };
|
// чтобы кнопка удаления могла нормально получать свои события.
|
||||||
|
for (dvui.events()) |*e| {
|
||||||
|
switch (e.evt) {
|
||||||
|
.mouse => |*mouse| {
|
||||||
|
if (!dvui.eventMatchSimple(e, row_data)) continue;
|
||||||
|
hovered = true;
|
||||||
|
if (mouse.action == .press and mouse.button == .left) {
|
||||||
|
select_row = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
else => {},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const background = is_selected or hovered;
|
const background = is_selected or hovered;
|
||||||
@@ -81,6 +88,10 @@ fn objectTreeRow(open_doc: *WindowContext.OpenDocument, obj: *Object, depth: u32
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
content.deinit();
|
content.deinit();
|
||||||
|
|
||||||
|
if (select_row) {
|
||||||
|
object_callback.* = .{ .select = obj };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
row.deinit();
|
row.deinit();
|
||||||
for (obj.children.items) |*child| {
|
for (obj.children.items) |*child| {
|
||||||
|
|||||||
Reference in New Issue
Block a user