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,
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) = .{},
channels: GenerationalArray(Channel) = .{},
files: GenerationalArray(File) = .{},
@ -1132,9 +1129,6 @@ pub const Project = struct {
self.sample_rate = null;
}
const show_rulers_u8 = try readInt(reader, u8);
self.show_rulers = show_rulers_u8 == 1;
{ // Channels
const channel_count = try readInt(reader, u32);
for (0..channel_count) |_| {
@ -1246,7 +1240,6 @@ pub const Project = struct {
try writeInt(writer, u8, file_format_version);
try writeFloat(writer, f64, self.sample_rate orelse 0);
try writeInt(writer, u8, @intFromBool(self.show_rulers));
{ // Channels
try writeInt(writer, u32, @intCast(self.channels.count()));

View File

@ -169,7 +169,6 @@ cursor: ?ViewAxisPosition = null,
view_settings: ?Id = null, // View id
view_fullscreen: ?Id = null, // View id
view_protocol_modal: ?Id = null, // View id
show_ruler: bool = false,
selected_tool: enum { move, select, marker } = .move,
show_marked_range: ?struct {
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);
if (!ctx.app.project.show_rulers) {
const graph_box = createGraphBox(ctx);
showGraph(ctx, graph_box, view_id);
const ruler_ctx = UIViewRuler.Context{
.ui = ctx.ui,
.project = &ctx.app.project,
.view_controls = ctx.view_controls
};
} else {
const ruler_ctx = UIViewRuler.Context{
.ui = ctx.ui,
.project = &ctx.app.project,
.view_controls = ctx.view_controls
};
var graph_box: *UI.Box = undefined;
var x_ruler: *UI.Box = undefined;
var y_ruler: *UI.Box = undefined;
var graph_box: *UI.Box = undefined;
var x_ruler: *UI.Box = undefined;
var y_ruler: *UI.Box = undefined;
{
const container = ui.createBox(.{
.layout_direction = .left_to_right,
.size_x = UI.Sizing.initGrowFull(),
.size_y = UI.Sizing.initGrowFull(),
});
container.beginChildren();
defer container.endChildren();
{
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);
y_ruler = UIViewRuler.createBox(ruler_ctx, ui.keyFromString("Y ruler"), .Y);
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);
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);
return result;
}

View File

@ -102,7 +102,7 @@ pub fn main() !void {
try Application.init(&app, allocator);
defer app.deinit();
if (builtin.mode == .Debug) {
if (builtin.mode == .Debug and false) {
var cwd_realpath_buff: [std.fs.MAX_PATH_BYTES]u8 = undefined;
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()) {
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 {
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) {
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);
defer if (do_scissor) self.endScissor();
// defer if (do_scissor) rl.drawRectangleLinesEx(box_rect, 1, rl.Color.magenta);
var value_shift: f32 = 0;
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);
// rl.drawRectangleLinesEx(intersected_rect, 1, rl.Color.magenta);
rl.beginScissorMode(
@intFromFloat(intersected_rect.x),
@ -1962,11 +1966,13 @@ fn beginScissor(self: *UI, rect: Rect) void {
fn endScissor(self: *UI) void {
rl.endScissorMode();
_ = self.scissor_stack.pop();
if (self.scissor_stack.len > 0) {
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.beginScissorMode(
@intFromFloat(top_scissor_rect.x),
@ -1974,6 +1980,7 @@ fn endScissor(self: *UI) void {
@intFromFloat(top_scissor_rect.width),
@intFromFloat(top_scissor_rect.height)
);
}
}