add deletion of views
This commit is contained in:
parent
7de55bde54
commit
1428d3d9bf
40
src/app.zig
40
src/app.zig
@ -1085,6 +1085,46 @@ pub const Project = struct {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn removeFile(self: *Project, allocator: std.mem.Allocator, file_id: Id) void {
|
||||
const file = self.files.get(file_id) orelse return;
|
||||
|
||||
self.removeSampleList(file.samples_id);
|
||||
file.deinit(allocator);
|
||||
|
||||
self.files.remove(file_id);
|
||||
file.* = undefined;
|
||||
}
|
||||
|
||||
pub fn removeChannel(self: *Project, allocator: std.mem.Allocator, channel_id: Id) void {
|
||||
const channel = self.channels.get(channel_id) orelse return;
|
||||
|
||||
self.removeSampleList(channel.collected_samples_id);
|
||||
|
||||
channel.deinit(allocator);
|
||||
self.channels.remove(channel_id);
|
||||
channel.* = undefined;
|
||||
}
|
||||
|
||||
pub fn removeView(self: *Project, allocator: std.mem.Allocator, view_id: Id) void {
|
||||
const view = self.views.get(view_id) orelse return;
|
||||
|
||||
if (view.transformed_samples) |sample_list_id| {
|
||||
self.removeSampleList(sample_list_id);
|
||||
}
|
||||
|
||||
switch (view.reference) {
|
||||
.file => |file_id| {
|
||||
self.removeFile(allocator, file_id);
|
||||
},
|
||||
.channel => |channel_id| {
|
||||
self.removeChannel(allocator, channel_id);
|
||||
}
|
||||
}
|
||||
|
||||
self.views.remove(view_id);
|
||||
view.* = undefined;
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Project, allocator: Allocator) void {
|
||||
var file_iter = self.files.iterator();
|
||||
while (file_iter.next()) |file| {
|
||||
|
@ -723,6 +723,16 @@ fn showViewSettings(self: *MainScreen, view_id: Id) !void {
|
||||
view.transforms.appendAssumeCapacity(.{ .addition = 0 });
|
||||
}
|
||||
}
|
||||
|
||||
_ = ui.createBox(.{ .size_y = UI.Sizing.initGrowFull() });
|
||||
|
||||
{
|
||||
const btn = ui.textButton("Delete");
|
||||
btn.borders = UI.Borders.all(.{ .color = srcery.red, .size = 4 });
|
||||
if (ui.signal(btn).clicked()) {
|
||||
project.removeView(self.app.allocator, view_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn showMarkedRange(self: *MainScreen, view_id: Id, index: usize) void {
|
||||
|
Loading…
Reference in New Issue
Block a user