show statistics points

This commit is contained in:
Rokas Puzonas 2025-05-27 10:13:29 +03:00
parent d49dc387fb
commit aa63dab79a

View File

@ -449,6 +449,42 @@ pub fn show(ctx: Context, box: *UI.Box, graph_box: *UI.Box, view_id: Id, axis: U
project.updateGainChange(i, mouse_range.remapTo(view_range.*, mouse_position)); project.updateGainChange(i, mouse_range.remapTo(view_range.*, mouse_position));
} }
} }
for (0.., project.statistic_points.items) |i, statistic_point| {
const color = srcery.bright_blue;
const sample: f64 = @floatFromInt(statistic_point);
showMarkerLine(ui, ruler, sample, color);
showMarkerLine(ui, ruler, sample, color);
var hasher = UI.Key.CombineHasher.init();
hasher.update(std.mem.asBytes("Statistic point"));
hasher.update(std.mem.asBytes(&view_id));
hasher.update(std.mem.asBytes(&axis));
hasher.update(std.mem.asBytes(&i));
const view_size = view.graph_opts.x_range.size();
const clickable_width = view_size * 0.01;
const clickable = ui.createBox(.{
.key = UI.Key.init(hasher.final()),
.float_rect = ruler.getGraphDrawContext().getRect(sample - clickable_width/2, clickable_width, 0, 1),
.float_relative_to = ruler.graph_box,
.parent = ruler.graph_box,
.flags = &.{ .draw_hot, .draw_active, .clickable },
.hot_cursor = .mouse_cursor_pointing_hand,
});
const signal = ui.signal(clickable);
if (signal.hot) {
const mouse_tooltip = ui.mouseTooltip();
mouse_tooltip.beginChildren();
defer mouse_tooltip.endChildren();
_ = ui.label("Statistic point", .{ });
}
}
} }
} }