add display name to views
This commit is contained in:
parent
ecea2b513a
commit
7de55bde54
@ -857,6 +857,7 @@ pub const View = struct {
|
||||
marked_ranges: std.BoundedArray(MarkedRange, 32) = .{},
|
||||
markers: std.BoundedArray(f64, max_markers) = .{},
|
||||
transforms: BoundedTransformsArray = .{},
|
||||
name: std.BoundedArray(u8, 128) = .{},
|
||||
|
||||
// Runtime
|
||||
graph_cache: Graph.RenderCache = .{},
|
||||
|
@ -168,14 +168,6 @@ fn showToolbar(ctx: Context, view_id: Id) void {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const btn = ui.textButton("Reset view");
|
||||
btn.background = srcery.hard_black;
|
||||
if (ui.signal(btn).clicked()) {
|
||||
ctx.view_controls.pushViewMove(view_id, view.available_x_range, view.available_y_range);
|
||||
}
|
||||
}
|
||||
|
||||
if (view.reference == .channel) {
|
||||
const channel_id = view.reference.channel;
|
||||
const channel = ctx.app.getChannel(channel_id).?;
|
||||
@ -234,6 +226,10 @@ fn showToolbar(ctx: Context, view_id: Id) void {
|
||||
view_name = std.fs.path.stem(file.path);
|
||||
}
|
||||
|
||||
if (view.name.len > 0) {
|
||||
view_name = view.name.constSlice();
|
||||
}
|
||||
|
||||
if (view_name) |text| {
|
||||
_ = ui.createBox(.{
|
||||
.size_x = UI.Sizing.initGrowFull()
|
||||
|
@ -49,7 +49,9 @@ export_location_picker: ?Platform.FilePickerId = null,
|
||||
parsed_sample_rate: ?f64 = null,
|
||||
|
||||
// View settings
|
||||
prev_view_settings: ?Id = null, // View ID
|
||||
transform_inputs: [App.View.max_transforms]UI.TextInputStorage,
|
||||
view_name_input: UI.TextInputStorage,
|
||||
channel_save_file_picker: ?Platform.FilePickerId = null,
|
||||
file_save_file_picker: ?Platform.FilePickerId = null,
|
||||
|
||||
@ -70,6 +72,7 @@ pub fn init(app: *App) !MainScreen {
|
||||
.solution_input = UI.TextInputStorage.init(allocator),
|
||||
.experiment_name = UI.TextInputStorage.init(allocator),
|
||||
.pipete_solution = UI.TextInputStorage.init(allocator),
|
||||
.view_name_input = UI.TextInputStorage.init(allocator),
|
||||
.view_controls = ViewControlsSystem.init(&app.project),
|
||||
.transform_inputs = transform_inputs,
|
||||
.preview_sample_list_id = try app.project.addSampleList(allocator)
|
||||
@ -89,6 +92,7 @@ pub fn deinit(self: *MainScreen) void {
|
||||
self.solution_input.deinit();
|
||||
self.experiment_name.deinit();
|
||||
self.pipete_solution.deinit();
|
||||
self.view_name_input.deinit();
|
||||
for (self.transform_inputs) |input| {
|
||||
input.deinit();
|
||||
}
|
||||
@ -455,7 +459,8 @@ fn showProjectSettings(self: *MainScreen) !void {
|
||||
.placeholder = placeholder,
|
||||
.initial = project.sample_rate,
|
||||
.invalid = self.parsed_sample_rate != project.sample_rate,
|
||||
.editable = !self.app.isCollectionInProgress()
|
||||
.editable = !self.app.isCollectionInProgress(),
|
||||
.width = 400
|
||||
});
|
||||
project.sample_rate = self.parsed_sample_rate;
|
||||
|
||||
@ -488,7 +493,8 @@ fn showProjectSettings(self: *MainScreen) !void {
|
||||
.path = project.export_location,
|
||||
.file_picker = &self.export_location_picker,
|
||||
.open_dialog = true,
|
||||
.folder = true
|
||||
.folder = true,
|
||||
.size_x = UI.Sizing.initGrowFull()
|
||||
})) |path| {
|
||||
if (project.export_location) |str| {
|
||||
self.app.allocator.free(str);
|
||||
@ -515,6 +521,13 @@ fn showViewSettings(self: *MainScreen, view_id: Id) !void {
|
||||
const sample_rate = project.getSampleRate();
|
||||
const view = project.views.get(view_id) orelse return;
|
||||
|
||||
// TODO: Hack
|
||||
if (self.prev_view_settings == null or !self.prev_view_settings.?.eql(view_id)) {
|
||||
self.view_name_input.clear();
|
||||
try self.view_name_input.setText(view.name.constSlice());
|
||||
self.prev_view_settings = view_id;
|
||||
}
|
||||
|
||||
{
|
||||
const label = ui.label("Settings", .{});
|
||||
label.borders.bottom = .{
|
||||
@ -525,6 +538,25 @@ fn showViewSettings(self: *MainScreen, view_id: Id) !void {
|
||||
_ = ui.createBox(.{ .size_y = UI.Sizing.initFixedPixels(ui.rem(1)) });
|
||||
}
|
||||
|
||||
{
|
||||
_ = ui.label("Name", .{});
|
||||
try ui.textInput(.{
|
||||
.key = ui.keyFromString("Name input"),
|
||||
.storage = &self.view_name_input,
|
||||
.initial = view.name.constSlice()
|
||||
});
|
||||
|
||||
if (self.view_name_input.modified) {
|
||||
const name = self.view_name_input.textSlice();
|
||||
view.name.len = 0;
|
||||
if (name.len > view.name.buffer.len) {
|
||||
view.name.appendSliceAssumeCapacity(name[0..view.name.buffer.len]);
|
||||
} else {
|
||||
view.name.appendSliceAssumeCapacity(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (view.reference) {
|
||||
.channel => |channel_id| {
|
||||
const channel = project.channels.get(channel_id).?;
|
||||
@ -542,8 +574,9 @@ fn showViewSettings(self: *MainScreen, view_id: Id) !void {
|
||||
.file => |file_id| {
|
||||
const file = project.files.get(file_id).?;
|
||||
|
||||
_ = ui.label("File", .{});
|
||||
if (ui.fileInput(.{
|
||||
.key = ui.keyFromString("Filename"),
|
||||
.key = ui.keyFromString("Filename input"),
|
||||
.allocator = self.app.allocator,
|
||||
.file_picker = &self.file_save_file_picker,
|
||||
.path = file.path
|
||||
|
@ -2502,7 +2502,8 @@ pub const FileInputOptions = struct {
|
||||
file_picker: *?Platform.FilePickerId,
|
||||
open_dialog: bool = true,
|
||||
folder: bool = false,
|
||||
path: ?[]const u8 = null
|
||||
path: ?[]const u8 = null,
|
||||
size_x: ?Sizing = null
|
||||
};
|
||||
|
||||
pub fn mouseTooltip(self: *UI) *Box {
|
||||
@ -2649,7 +2650,7 @@ pub fn textInput(self: *UI, opts: TextInputOptions) !void {
|
||||
const storage_text = &storage.buffer;
|
||||
|
||||
if (opts.initial != null and container.created) {
|
||||
storage_text.clearAndFree();
|
||||
storage.clear();
|
||||
try storage_text.appendSlice(opts.initial.?);
|
||||
}
|
||||
|
||||
@ -3071,7 +3072,7 @@ pub fn fileInput(self: *UI, opts: FileInputOptions) ?[]u8 {
|
||||
|
||||
const container = self.createBox(.{
|
||||
.key = opts.key,
|
||||
.size_x = Sizing.initGrowUpTo(.{ .pixels = 200 }),
|
||||
.size_x = opts.size_x orelse Sizing.initGrowUpTo(.{ .pixels = 200 }),
|
||||
.size_y = Sizing.initFixed(Unit.initPixels(self.rem(1))),
|
||||
.flags = &.{ .clickable, .clip_view, .draw_hot, .draw_active },
|
||||
.background = srcery.bright_white,
|
||||
|
Loading…
Reference in New Issue
Block a user