increase x axis mouse tooltip accuracy
This commit is contained in:
parent
aa63dab79a
commit
be0d0f6bb1
@ -176,7 +176,7 @@ fn formatAxisLabel(allocator: std.mem.Allocator, project: *App.Project, axis: UI
|
||||
const sample_rate = project.sample_rate;
|
||||
if (axis == .X and sample_rate != null) {
|
||||
const seconds = position / sample_rate.?;
|
||||
return try utils.formatDuration(allocator, seconds);
|
||||
return try utils.formatDuration(allocator, seconds, false);
|
||||
} else {
|
||||
return try std.fmt.allocPrint(allocator, "{d:.3}", .{ position });
|
||||
}
|
||||
@ -240,7 +240,7 @@ fn showMouseTooltip(ctx: Context, axis: UI.Axis, view_id: Id, position: f64) voi
|
||||
} else if (axis == .X and sample_rate != null) {
|
||||
const seconds = position / sample_rate.?;
|
||||
const frame_allocator = ui.frameAllocator();
|
||||
_ = ui.label("{s}", .{ utils.formatDuration(frame_allocator, seconds) catch "-" });
|
||||
_ = ui.label("{s}", .{ utils.formatDuration(frame_allocator, seconds, true) catch "-" });
|
||||
|
||||
} else {
|
||||
_ = ui.label("{d:.3}", .{position});
|
||||
|
@ -754,7 +754,7 @@ fn showViewSettings(self: *MainScreen, view_id: Id) !void {
|
||||
var duration_str: ?[]const u8 = null;
|
||||
if (sample_rate != null) {
|
||||
const duration = @as(f64, @floatFromInt(sample_count)) / sample_rate.?;
|
||||
if (utils.formatDuration(ui.frameAllocator(), duration)) |str| {
|
||||
if (utils.formatDuration(ui.frameAllocator(), duration, false)) |str| {
|
||||
duration_str = str;
|
||||
} else |_| {}
|
||||
}
|
||||
@ -1186,7 +1186,7 @@ fn showSolutions(self: *MainScreen) !void {
|
||||
|
||||
if (sample_rate != null) {
|
||||
const seconds = @as(f64, @floatFromInt(solution.sample)) / sample_rate.?;
|
||||
_ = ui.label("{s}", .{ try utils.formatDuration(ui.frameAllocator(), seconds) });
|
||||
_ = ui.label("{s}", .{ try utils.formatDuration(ui.frameAllocator(), seconds, false) });
|
||||
} else {
|
||||
_ = ui.label("{d}", .{ solution.sample });
|
||||
}
|
||||
@ -1235,7 +1235,7 @@ fn showStatisticsPoints(self: *MainScreen) !void {
|
||||
|
||||
if (sample_rate != null) {
|
||||
const seconds = @as(f64, @floatFromInt(sample_timestamp)) / sample_rate.?;
|
||||
_ = ui.label("{s}", .{ try utils.formatDuration(ui.frameAllocator(), seconds) });
|
||||
_ = ui.label("{s}", .{ try utils.formatDuration(ui.frameAllocator(), seconds, false) });
|
||||
} else {
|
||||
_ = ui.label("{d}", .{ sample_timestamp });
|
||||
}
|
||||
@ -1284,7 +1284,7 @@ fn showGainChanges(self: *MainScreen) !void {
|
||||
|
||||
if (sample_rate != null) {
|
||||
const seconds = gain_change.sample / sample_rate.?;
|
||||
_ = ui.label("{s}", .{ try utils.formatDuration(ui.frameAllocator(), seconds) });
|
||||
_ = ui.label("{s}", .{ try utils.formatDuration(ui.frameAllocator(), seconds, false) });
|
||||
} else {
|
||||
_ = ui.label("{d}", .{ gain_change.sample });
|
||||
}
|
||||
|
@ -86,8 +86,12 @@ pub inline fn dumpErrorTrace() void {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn formatDuration(allocator: std.mem.Allocator, total_seconds: f64) ![]u8 {
|
||||
pub fn formatDuration(allocator: std.mem.Allocator, total_seconds: f64, high_accuracy: bool) ![]u8 {
|
||||
const seconds = @mod(total_seconds, @as(f64, @floatFromInt(std.time.s_per_min)));
|
||||
const minutes = @divFloor(total_seconds, std.time.s_per_min);
|
||||
return try std.fmt.allocPrint(allocator, "{d:.0}m {d:.3}s", .{ minutes, seconds });
|
||||
if (high_accuracy) {
|
||||
return try std.fmt.allocPrint(allocator, "{d:.0}m {d:.5}s", .{ minutes, seconds });
|
||||
} else {
|
||||
return try std.fmt.allocPrint(allocator, "{d:.0}m {d:.3}s", .{ minutes, seconds });
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user