remove ruler configuring

This commit is contained in:
Rokas Puzonas 2025-05-10 18:29:45 +03:00
parent a2da649d96
commit a6e0fd9e67
6 changed files with 58 additions and 70 deletions

View File

@ -929,9 +929,6 @@ pub const Project = struct {
sample_rate: ?f64 = null, sample_rate: ?f64 = null,
notes: std.ArrayListUnmanaged(u8) = .{}, notes: std.ArrayListUnmanaged(u8) = .{},
// TODO: How this to computer local settings, like appdata. Because this option shouldn't be project specific.
show_rulers: bool = true,
sample_lists: GenerationalArray(SampleList) = .{}, sample_lists: GenerationalArray(SampleList) = .{},
channels: GenerationalArray(Channel) = .{}, channels: GenerationalArray(Channel) = .{},
files: GenerationalArray(File) = .{}, files: GenerationalArray(File) = .{},
@ -1132,9 +1129,6 @@ pub const Project = struct {
self.sample_rate = null; self.sample_rate = null;
} }
const show_rulers_u8 = try readInt(reader, u8);
self.show_rulers = show_rulers_u8 == 1;
{ // Channels { // Channels
const channel_count = try readInt(reader, u32); const channel_count = try readInt(reader, u32);
for (0..channel_count) |_| { for (0..channel_count) |_| {
@ -1246,7 +1240,6 @@ pub const Project = struct {
try writeInt(writer, u8, file_format_version); try writeInt(writer, u8, file_format_version);
try writeFloat(writer, f64, self.sample_rate orelse 0); try writeFloat(writer, f64, self.sample_rate orelse 0);
try writeInt(writer, u8, @intFromBool(self.show_rulers));
{ // Channels { // Channels
try writeInt(writer, u32, @intCast(self.channels.count())); try writeInt(writer, u32, @intCast(self.channels.count()));

View File

@ -169,7 +169,6 @@ cursor: ?ViewAxisPosition = null,
view_settings: ?Id = null, // View id view_settings: ?Id = null, // View id
view_fullscreen: ?Id = null, // View id view_fullscreen: ?Id = null, // View id
view_protocol_modal: ?Id = null, // View id view_protocol_modal: ?Id = null, // View id
show_ruler: bool = false,
selected_tool: enum { move, select, marker } = .move, selected_tool: enum { move, select, marker } = .move,
show_marked_range: ?struct { show_marked_range: ?struct {
view_id: Id, view_id: Id,

View File

@ -286,65 +286,59 @@ pub fn show(ctx: Context, view_id: Id, height: UI.Sizing) !Result {
showToolbar(ctx, view_id); showToolbar(ctx, view_id);
if (!ctx.app.project.show_rulers) { const ruler_ctx = UIViewRuler.Context{
const graph_box = createGraphBox(ctx); .ui = ctx.ui,
showGraph(ctx, graph_box, view_id); .project = &ctx.app.project,
.view_controls = ctx.view_controls
};
} else { var graph_box: *UI.Box = undefined;
const ruler_ctx = UIViewRuler.Context{ var x_ruler: *UI.Box = undefined;
.ui = ctx.ui, var y_ruler: *UI.Box = undefined;
.project = &ctx.app.project,
.view_controls = ctx.view_controls
};
var graph_box: *UI.Box = undefined; {
var x_ruler: *UI.Box = undefined; const container = ui.createBox(.{
var y_ruler: *UI.Box = undefined; .layout_direction = .left_to_right,
.size_x = UI.Sizing.initGrowFull(),
.size_y = UI.Sizing.initGrowFull(),
});
container.beginChildren();
defer container.endChildren();
{ y_ruler = UIViewRuler.createBox(ruler_ctx, ui.keyFromString("Y ruler"), .Y);
const container = ui.createBox(.{
.layout_direction = .left_to_right,
.size_x = UI.Sizing.initGrowFull(),
.size_y = UI.Sizing.initGrowFull(),
});
container.beginChildren();
defer container.endChildren();
y_ruler = UIViewRuler.createBox(ruler_ctx, ui.keyFromString("Y ruler"), .Y); graph_box = createGraphBox(ctx);
graph_box = createGraphBox(ctx);
}
{
const container = ui.createBox(.{
.layout_direction = .left_to_right,
.size_x = UI.Sizing.initGrowFull(),
.size_y = ruler_size,
});
container.beginChildren();
defer container.endChildren();
const fullscreen = ui.createBox(.{
.key = ui.keyFromString("Fullscreen toggle"),
.size_x = ruler_size,
.size_y = ruler_size,
.background = srcery.hard_black,
.hot_cursor = .mouse_cursor_pointing_hand,
.flags = &.{ .draw_hot, .draw_active, .clickable },
.texture = Assets.fullscreen,
.texture_size = .{ .x = 28, .y = 28 }
});
if (ui.signal(fullscreen).clicked()) {
ctx.view_controls.toggleFullscreenView(view_id);
}
x_ruler = UIViewRuler.createBox(ruler_ctx, ui.keyFromString("X ruler"), .X);
}
try UIViewRuler.show(ruler_ctx, x_ruler, graph_box, view_id, .X);
try UIViewRuler.show(ruler_ctx, y_ruler, graph_box, view_id, .Y);
showGraph(ctx, graph_box, view_id);
} }
{
const container = ui.createBox(.{
.layout_direction = .left_to_right,
.size_x = UI.Sizing.initGrowFull(),
.size_y = ruler_size,
});
container.beginChildren();
defer container.endChildren();
const fullscreen = ui.createBox(.{
.key = ui.keyFromString("Fullscreen toggle"),
.size_x = ruler_size,
.size_y = ruler_size,
.background = srcery.hard_black,
.hot_cursor = .mouse_cursor_pointing_hand,
.flags = &.{ .draw_hot, .draw_active, .clickable },
.texture = Assets.fullscreen,
.texture_size = .{ .x = 28, .y = 28 }
});
if (ui.signal(fullscreen).clicked()) {
ctx.view_controls.toggleFullscreenView(view_id);
}
x_ruler = UIViewRuler.createBox(ruler_ctx, ui.keyFromString("X ruler"), .X);
}
try UIViewRuler.show(ruler_ctx, x_ruler, graph_box, view_id, .X);
try UIViewRuler.show(ruler_ctx, y_ruler, graph_box, view_id, .Y);
showGraph(ctx, graph_box, view_id);
return result; return result;
} }

View File

@ -102,7 +102,7 @@ pub fn main() !void {
try Application.init(&app, allocator); try Application.init(&app, allocator);
defer app.deinit(); defer app.deinit();
if (builtin.mode == .Debug) { if (builtin.mode == .Debug and false) {
var cwd_realpath_buff: [std.fs.MAX_PATH_BYTES]u8 = undefined; var cwd_realpath_buff: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const cwd_realpath = try std.fs.cwd().realpath(".", &cwd_realpath_buff); const cwd_realpath = try std.fs.cwd().realpath(".", &cwd_realpath_buff);

View File

@ -342,11 +342,6 @@ fn showProjectSettings(self: *MainScreen) !void {
} }
} }
_ = ui.checkbox(.{
.value = &project.show_rulers,
.label = "Ruler"
});
if (ui.signal(ui.textButton("Open notes")).clicked()) { if (ui.signal(ui.textButton("Open notes")).clicked()) {
self.modal = .notes; self.modal = .notes;
} }

View File

@ -1761,12 +1761,15 @@ pub fn draw(self: *UI) void {
fn drawBox(self: *UI, box: *Box, on_top_pass: ?bool) void { fn drawBox(self: *UI, box: *Box, on_top_pass: ?bool) void {
var child_on_top_pass = on_top_pass; var child_on_top_pass = on_top_pass;
var do_scissor = false;
defer if (do_scissor) self.endScissor();
if (on_top_pass == null or box.draw_on_top == on_top_pass) { if (on_top_pass == null or box.draw_on_top == on_top_pass) {
const box_rect = box.rect(); const box_rect = box.rect();
const do_scissor = box.flags.contains(.clip_view); do_scissor = box.flags.contains(.clip_view);
if (do_scissor) self.beginScissor(box_rect); if (do_scissor) self.beginScissor(box_rect);
defer if (do_scissor) self.endScissor(); // defer if (do_scissor) rl.drawRectangleLinesEx(box_rect, 1, rl.Color.magenta);
var value_shift: f32 = 0; var value_shift: f32 = 0;
if (box.flags.contains(.draw_active) and box.persistent.active > 0.01) { if (box.flags.contains(.draw_active) and box.persistent.active > 0.01) {
@ -1951,6 +1954,7 @@ fn beginScissor(self: *UI, rect: Rect) void {
} }
self.scissor_stack.appendAssumeCapacity(intersected_rect); self.scissor_stack.appendAssumeCapacity(intersected_rect);
// rl.drawRectangleLinesEx(intersected_rect, 1, rl.Color.magenta);
rl.beginScissorMode( rl.beginScissorMode(
@intFromFloat(intersected_rect.x), @intFromFloat(intersected_rect.x),
@ -1962,11 +1966,13 @@ fn beginScissor(self: *UI, rect: Rect) void {
fn endScissor(self: *UI) void { fn endScissor(self: *UI) void {
rl.endScissorMode(); rl.endScissorMode();
_ = self.scissor_stack.pop(); _ = self.scissor_stack.pop();
if (self.scissor_stack.len > 0) { if (self.scissor_stack.len > 0) {
const top_scissor_rect = self.scissor_stack.buffer[self.scissor_stack.len - 1]; const top_scissor_rect = self.scissor_stack.buffer[self.scissor_stack.len - 1];
// rl.drawRectangleLinesEx(top_scissor_rect, 1, rl.Color.magenta);
rl.endScissorMode(); rl.endScissorMode();
rl.beginScissorMode( rl.beginScissorMode(
@intFromFloat(top_scissor_rect.x), @intFromFloat(top_scissor_rect.x),
@ -1974,6 +1980,7 @@ fn endScissor(self: *UI) void {
@intFromFloat(top_scissor_rect.width), @intFromFloat(top_scissor_rect.width),
@intFromFloat(top_scissor_rect.height) @intFromFloat(top_scissor_rect.height)
); );
} }
} }