diff --git a/apps/desktop-gpui/locales/de.toml b/apps/desktop-gpui/locales/de.toml index c96d36f22a2..e6984d1a7d9 100644 --- a/apps/desktop-gpui/locales/de.toml +++ b/apps/desktop-gpui/locales/de.toml @@ -3124,6 +3124,11 @@ save_failed = "Der Aufnahmetitel für {path} konnte nicht gespeichert werden: {e clear_all = "Alle entfernen" delete = "Löschen" +[editor.window.track_rename] +title = "Spur umbenennen" +placeholder = "Spurname" +confirm = "Umbenennen" + [editor.window.transition] title = "Übergang" add = "Übergang hinzufügen" diff --git a/apps/desktop-gpui/locales/en.toml b/apps/desktop-gpui/locales/en.toml index 29f268aa5c6..078d44d7ed5 100644 --- a/apps/desktop-gpui/locales/en.toml +++ b/apps/desktop-gpui/locales/en.toml @@ -3126,6 +3126,11 @@ save_failed = "Could not save the recording title for {path}: {error}" clear_all = "Clear all" delete = "Delete" +[editor.window.track_rename] +title = { text = "Rename track", context = "Title of the dialog opened by double-clicking a timeline lane label." } +placeholder = "Track name" +confirm = "Rename" + [editor.window.transition] title = { text = "Transition", context = "Title of the popover that edits the transition between two clips." } add = { text = "Add transition", context = "Tooltip on the + button at a cut between two clips on the timeline." } diff --git a/apps/desktop-gpui/locales/es.toml b/apps/desktop-gpui/locales/es.toml index 27fbf306d17..6f159b6c8ab 100644 --- a/apps/desktop-gpui/locales/es.toml +++ b/apps/desktop-gpui/locales/es.toml @@ -3124,6 +3124,11 @@ save_failed = "No se pudo guardar el título de la grabación de {path}: {error} clear_all = "Borrar todo" delete = "Eliminar" +[editor.window.track_rename] +title = "Renombrar pista" +placeholder = "Nombre de la pista" +confirm = "Renombrar" + [editor.window.transition] title = "Transición" add = "Añadir transición" diff --git a/apps/desktop-gpui/locales/fr.toml b/apps/desktop-gpui/locales/fr.toml index 87b46c59460..5ef5aa579da 100644 --- a/apps/desktop-gpui/locales/fr.toml +++ b/apps/desktop-gpui/locales/fr.toml @@ -3124,6 +3124,11 @@ save_failed = "Impossible d'enregistrer le titre de l'enregistrement pour {path} clear_all = "Tout effacer" delete = "Supprimer" +[editor.window.track_rename] +title = "Renommer la piste" +placeholder = "Nom de la piste" +confirm = "Renommer" + [editor.window.transition] title = "Transition" add = "Ajouter une transition" diff --git a/apps/desktop-gpui/locales/hi.toml b/apps/desktop-gpui/locales/hi.toml index 319ed6675bb..32bf37d76ae 100644 --- a/apps/desktop-gpui/locales/hi.toml +++ b/apps/desktop-gpui/locales/hi.toml @@ -3124,6 +3124,11 @@ save_failed = "{path} का रिकॉर्डिंग टाइटल स clear_all = "सब साफ़ करें" delete = "हटाएँ" +[editor.window.track_rename] +title = "ट्रैक का नाम बदलें" +placeholder = "ट्रैक का नाम" +confirm = "नाम बदलें" + [editor.window.transition] title = "ट्रांज़िशन" add = "ट्रांज़िशन जोड़ें" diff --git a/apps/desktop-gpui/locales/ja.toml b/apps/desktop-gpui/locales/ja.toml index d007debfd05..a30f066620d 100644 --- a/apps/desktop-gpui/locales/ja.toml +++ b/apps/desktop-gpui/locales/ja.toml @@ -3124,6 +3124,11 @@ save_failed = "{path}の録画タイトルを保存できませんでした:{e clear_all = "すべて消去" delete = "削除" +[editor.window.track_rename] +title = "トラック名を変更" +placeholder = "トラック名" +confirm = "名前を変更" + [editor.window.transition] title = "トランジション" add = "トランジションを追加" diff --git a/apps/desktop-gpui/locales/zh-CN.toml b/apps/desktop-gpui/locales/zh-CN.toml index 922d4ee4a5d..5fa1b796b47 100644 --- a/apps/desktop-gpui/locales/zh-CN.toml +++ b/apps/desktop-gpui/locales/zh-CN.toml @@ -3124,6 +3124,11 @@ save_failed = "无法保存 {path} 的录制标题:{error}" clear_all = "全部清除" delete = "删除" +[editor.window.track_rename] +title = "重命名轨道" +placeholder = "轨道名称" +confirm = "重命名" + [editor.window.transition] title = "转场" add = "添加转场" diff --git a/apps/desktop-gpui/src/editor_edits.rs b/apps/desktop-gpui/src/editor_edits.rs index 079eab3403a..29d5e2887c9 100644 --- a/apps/desktop-gpui/src/editor_edits.rs +++ b/apps/desktop-gpui/src/editor_edits.rs @@ -1184,7 +1184,38 @@ pub fn delete_track_lane_and_order( true } }); - timeline_changed || order_changed + let names_changed = matches!( + kind, + TrackKind::Style | TrackKind::Image | TrackKind::Text | TrackKind::Mask | TrackKind::Audio + ) && delete_track_name(&mut project.track_names, kind, lane); + timeline_changed || order_changed || names_changed +} + +fn delete_track_name( + names: &mut std::collections::BTreeMap, + kind: TrackKind, + deleted: u32, +) -> bool { + let prefix = format!("{}:", kind.name_key()); + let lanes: Vec<(u32, String)> = names + .iter() + .filter_map(|(key, name)| { + let lane = key.strip_prefix(&prefix)?.parse::().ok()?; + (lane >= deleted).then(|| (lane, name.clone())) + }) + .collect(); + if lanes.is_empty() { + return false; + } + for (lane, _) in &lanes { + names.remove(&format!("{prefix}{lane}")); + } + for (lane, name) in lanes { + if lane > deleted { + names.insert(format!("{prefix}{}", lane - 1), name); + } + } + true } pub fn reorder_overlay_track( @@ -1207,6 +1238,102 @@ pub fn reorder_overlay_track( true } +fn reordered_lane(lane: u32, from: u32, to: u32) -> u32 { + if lane == from { + to + } else if from < to && lane > from && lane <= to { + lane - 1 + } else if from > to && lane >= to && lane < from { + lane + 1 + } else { + lane + } +} + +pub fn reorder_track_names( + names: &mut std::collections::BTreeMap, + kind: TrackKind, + from: u32, + to: u32, +) -> bool { + let before = names.clone(); + let prefix = format!("{}:", kind.name_key()); + let moved: Vec<(u32, String)> = names + .iter() + .filter_map(|(key, name)| { + let lane = key.strip_prefix(&prefix)?.parse::().ok()?; + Some((lane, name.clone())) + }) + .collect(); + names.retain(|key, _| !key.starts_with(&prefix)); + for (lane, name) in moved { + names.insert(format!("{prefix}{}", reordered_lane(lane, from, to)), name); + } + *names != before +} + +/// Style and audio deletes renumber the lanes that still hold segments +/// densely from zero, so names follow those lanes; a named lane left empty +/// keeps its name below them. +pub fn delete_segments_with_names( + project: &mut ProjectConfiguration, + kind: TrackKind, + indices: &[usize], +) -> bool { + fn surviving_lanes(segments: &[T], deleted: &[usize]) -> Vec { + let mut lanes: Vec = segments + .iter() + .enumerate() + .filter(|(index, _)| !deleted.contains(index)) + .map(|(_, segment)| segment.lane()) + .collect(); + lanes.sort_unstable(); + lanes.dedup(); + lanes + } + let Some(timeline) = project.timeline.as_mut() else { + return false; + }; + let lanes = match kind { + TrackKind::Style => Some(surviving_lanes(&timeline.style_segments, indices)), + TrackKind::Audio => Some(surviving_lanes(&timeline.audio_segments, indices)), + _ => None, + }; + if !delete_segments(timeline, kind, indices) { + return false; + } + if let Some(lanes) = lanes { + renumber_track_names(&mut project.track_names, kind, &lanes); + } + true +} + +fn renumber_track_names( + names: &mut std::collections::BTreeMap, + kind: TrackKind, + kept_lanes: &[u32], +) { + let prefix = format!("{}:", kind.name_key()); + let named: Vec<(u32, String)> = names + .iter() + .filter_map(|(key, name)| { + let lane = key.strip_prefix(&prefix)?.parse::().ok()?; + Some((lane, name.clone())) + }) + .collect(); + names.retain(|key, _| !key.starts_with(&prefix)); + for (lane, name) in named { + let new_lane = match kept_lanes.iter().position(|kept| *kept == lane) { + Some(position) => position, + None => { + let kept_below = kept_lanes.iter().filter(|kept| **kept < lane).count(); + kept_lanes.len() + lane as usize - kept_below + } + }; + names.insert(format!("{prefix}{new_lane}"), name); + } +} + pub fn reorder_track_lane( timeline: &mut TimelineConfiguration, kind: TrackKind, @@ -1226,15 +1353,7 @@ pub fn reorder_track_lane( let mut changed = false; for segment in segments { let lane = segment.lane(); - let next = if lane == from { - to - } else if from < to && lane > from && lane <= to { - lane - 1 - } else if from > to && lane >= to && lane < from { - lane + 1 - } else { - lane - }; + let next = reordered_lane(lane, from, to); if next != lane { set(segment, next); changed = true; @@ -3163,6 +3282,158 @@ mod tests { // -- Selection ---------------------------------------------------------- + #[test] + fn deleting_a_lane_drops_its_name_and_shifts_the_names_above() { + let mut project = config(serde_json::json!({ + "timeline": { + "segments": [{ "recordingSegment": 0, "timescale": 1.0, "start": 0.0, "end": 30.0 }], + "zoomSegments": [], + "audioSegments": [ + { "start": 0.0, "end": 5.0, "track": 0, "path": "voice.mp3", "name": "Voice", "duration": 5.0 }, + { "start": 0.0, "end": 5.0, "track": 1, "path": "music.mp3", "name": "Music", "duration": 5.0 } + ] + }, + "trackNames": { "audio:0": "Voice", "audio:1": "Music", "text:0": "Titles" } + })); + assert!(delete_track_lane_and_order( + &mut project, + &[], + TrackKind::Audio, + 0 + )); + let names = |project: &ProjectConfiguration| { + project + .track_names + .iter() + .map(|(key, name)| (key.clone(), name.clone())) + .collect::>() + }; + assert_eq!( + names(&project), + [ + ("audio:0".to_string(), "Music".to_string()), + ("text:0".to_string(), "Titles".to_string()) + ] + ); + + let mut empty_lane = config(serde_json::json!({ + "timeline": { + "segments": [{ "recordingSegment": 0, "timescale": 1.0, "start": 0.0, "end": 30.0 }], + "zoomSegments": [] + }, + "trackNames": { "text:0": "Empty", "text:1": "Above" } + })); + assert!(delete_track_lane_and_order( + &mut empty_lane, + &[], + TrackKind::Text, + 0 + )); + assert_eq!( + names(&empty_lane), + [("text:0".to_string(), "Above".to_string())] + ); + } + + #[test] + fn deleting_a_lanes_last_segment_moves_the_names_with_the_lanes() { + let mut project = config(serde_json::json!({ + "timeline": { + "segments": [{ "recordingSegment": 0, "timescale": 1.0, "start": 0.0, "end": 30.0 }], + "zoomSegments": [], + "audioSegments": [ + { "start": 0.0, "end": 5.0, "track": 0, "path": "voice.mp3", "name": "Voice", "duration": 5.0 }, + { "start": 0.0, "end": 5.0, "track": 1, "path": "music.mp3", "name": "Music", "duration": 5.0 } + ] + }, + "trackNames": { "audio:0": "Voice", "audio:1": "Music", "style:0": "Intro" } + })); + assert!(delete_segments_with_names( + &mut project, + TrackKind::Audio, + &[0] + )); + assert_eq!( + project.timeline.as_ref().unwrap().audio_segments[0].track, + 0 + ); + assert_eq!( + project + .track_names + .iter() + .map(|(key, name)| (key.as_str(), name.as_str())) + .collect::>(), + [ + ("audio:0", "Music"), + ("audio:1", "Voice"), + ("style:0", "Intro") + ] + ); + } + + #[test] + fn deleting_a_segment_keeps_the_gaps_between_empty_named_lanes() { + let mut project = config(serde_json::json!({ + "timeline": { + "segments": [{ "recordingSegment": 0, "timescale": 1.0, "start": 0.0, "end": 30.0 }], + "zoomSegments": [], + "audioSegments": [ + { "start": 0.0, "end": 5.0, "track": 0, "path": "voice.mp3", "name": "Voice", "duration": 5.0 }, + { "start": 6.0, "end": 9.0, "track": 0, "path": "voice.mp3", "name": "Voice", "duration": 3.0 } + ] + }, + "trackNames": { "audio:2": "Music" } + })); + assert!(delete_segments_with_names( + &mut project, + TrackKind::Audio, + &[1] + )); + assert_eq!( + project + .track_names + .iter() + .map(|(key, name)| (key.as_str(), name.as_str())) + .collect::>(), + [("audio:2", "Music")] + ); + } + + #[test] + fn reordering_empty_named_lanes_still_moves_their_names() { + let mut names = std::collections::BTreeMap::from([ + ("audio:0".to_string(), "A".to_string()), + ("audio:1".to_string(), "B".to_string()), + ]); + assert!(reorder_track_names(&mut names, TrackKind::Audio, 0, 1)); + assert_eq!(names.get("audio:0").map(String::as_str), Some("B")); + assert_eq!(names.get("audio:1").map(String::as_str), Some("A")); + let mut unnamed = std::collections::BTreeMap::new(); + assert!(!reorder_track_names(&mut unnamed, TrackKind::Audio, 0, 1)); + } + + #[test] + fn lane_names_follow_their_lane_when_lanes_are_reordered() { + let mut names = std::collections::BTreeMap::from([ + ("audio:0".to_string(), "Voice".to_string()), + ("audio:1".to_string(), "Music".to_string()), + ("style:0".to_string(), "Intro".to_string()), + ]); + reorder_track_names(&mut names, TrackKind::Audio, 1, 0); + assert_eq!(names.get("audio:0").map(String::as_str), Some("Music")); + assert_eq!(names.get("audio:1").map(String::as_str), Some("Voice")); + assert_eq!(names.get("style:0").map(String::as_str), Some("Intro")); + + let mut names = std::collections::BTreeMap::from([ + ("audio:0".to_string(), "A".to_string()), + ("audio:2".to_string(), "C".to_string()), + ]); + reorder_track_names(&mut names, TrackKind::Audio, 0, 2); + assert_eq!(names.get("audio:2").map(String::as_str), Some("A")); + assert_eq!(names.get("audio:1").map(String::as_str), Some("C")); + assert!(!names.contains_key("audio:0")); + } + #[test] fn a_plain_click_selects_one_segment() { let selection = click_selection(None, TrackKind::Zoom, 3, false, false); diff --git a/apps/desktop-gpui/src/editor_timeline.rs b/apps/desktop-gpui/src/editor_timeline.rs index 7b11b9c17f4..835bd1c6f22 100644 --- a/apps/desktop-gpui/src/editor_timeline.rs +++ b/apps/desktop-gpui/src/editor_timeline.rs @@ -983,6 +983,23 @@ pub enum TrackKind { } impl TrackKind { + pub fn name_key(self) -> &'static str { + match self { + Self::Clip => "clip", + Self::Style => "style", + Self::Image => "image", + Self::Caption => "caption", + Self::Keyboard => "keyboard", + Self::Text => "text", + Self::Shape => "shape", + Self::Mask => "mask", + Self::Audio => "audio", + Self::Zoom => "zoom", + Self::ThreeD => "3d", + Self::Scene => "scene", + } + } + /// `trackDefinitions` (`TL/index.tsx:89-144`) and `trackIcons` (`:70-80`). pub fn label(self) -> &'static str { match self { @@ -1348,6 +1365,7 @@ impl TrackRow { /// Everything the timeline draws, derived once per project-config change. #[derive(Debug, Clone, Default)] pub struct TimelineModel { + pub track_names: std::collections::BTreeMap, pub style: Vec, pub image: Vec, pub rows: Vec, @@ -1609,6 +1627,7 @@ impl TimelineModel { }) .collect(); let mut model = Self { + track_names: Default::default(), style, image, rows: Vec::new(), @@ -1649,6 +1668,12 @@ impl TimelineModel { ) -> Self { let mut model = Self::build(config, has_camera, multiple_clips); model.rows = build_rows(config, &model, has_camera, lanes); + model.track_names = config + .track_names + .iter() + .filter(|(_, name)| !name.trim().is_empty()) + .map(|(key, name)| (key.clone(), SharedString::from(name.clone()))) + .collect(); model } } @@ -1970,10 +1995,14 @@ impl SegmentUi<'_> { // Rendering // --------------------------------------------------------------------------- +pub fn track_name_key(row: TrackRow) -> String { + format!("{}:{}", row.kind.name_key(), row.lane) +} + /// The gutter cell: a tinted 22px tile carrying the track's glyph, then the /// track's name. The saturated pill the source draws /// (`TL/TrackManager.tsx:264-281`) is gone. -pub fn track_chip(theme: &Theme, kind: TrackKind) -> impl IntoElement { +pub fn track_chip(theme: &Theme, kind: TrackKind, name: Option) -> impl IntoElement { let color = kind.color(); div() .w_full() @@ -2008,7 +2037,7 @@ pub fn track_chip(theme: &Theme, kind: TrackKind) -> impl IntoElement { .text_size(px(11.)) .line_height(px(14.)) .font_weight(FontWeight::MEDIUM) - .child(kind.label()), + .child(name.unwrap_or_else(|| SharedString::new_static(kind.label()))), ) } @@ -2305,7 +2334,11 @@ pub fn render_row( .w(px(TRACK_GUTTER)) .flex_none() .relative() - .child(track_chip(theme, row.kind)), + .child(track_chip( + theme, + row.kind, + model.track_names.get(&track_name_key(row)).cloned(), + )), ) .child( div() @@ -4127,6 +4160,39 @@ mod tests { const AUDIO_SAMPLE_RATE: usize = 48_000; + #[test] + fn lane_names_come_from_the_project_by_track_and_lane() { + let mut config = ProjectConfiguration::default(); + config.track_names.insert("audio:1".into(), "Music".into()); + config.track_names.insert("text:0".into(), " ".into()); + let lanes = TrackLanes { + style: 0, + image: 0, + caption: false, + keyboard: false, + scene: false, + three_d: false, + text: 1, + shape: 0, + mask: 0, + audio: 2, + }; + let model = TimelineModel::build_with_lanes(&config, false, false, &lanes); + let audio = TrackRow { + kind: TrackKind::Audio, + lane: 1, + }; + assert_eq!(track_name_key(audio), "audio:1"); + assert_eq!( + model.track_names.get("audio:1").map(|n| n.as_ref()), + Some("Music") + ); + assert!( + !model.track_names.contains_key("text:0"), + "blank names are ignored" + ); + } + // -- The ruler ---------------------------------------------------------- #[test] diff --git a/apps/desktop-gpui/src/editor_window.rs b/apps/desktop-gpui/src/editor_window.rs index d19371448c6..46666798d34 100644 --- a/apps/desktop-gpui/src/editor_window.rs +++ b/apps/desktop-gpui/src/editor_window.rs @@ -1658,6 +1658,8 @@ pub struct EditorWindow { presets_menu: Option, preset_dialog: Option, style_presets: style_preset_ui::StylePresetsState, + track_rename: Option, + track_name_input: Entity, caption_sync_signature: Option, pub(crate) export: Option, pub(crate) sharing: Option, @@ -2140,6 +2142,19 @@ impl EditorWindow { }, )); let markers_state = markers::MarkersState::new(window, cx, &mut text_events); + let track_name_input = cx.new(|cx| ui::TextInputState::single_line(window, cx)); + text_events.push(cx.subscribe_in( + &track_name_input, + window, + |this: &mut Self, _input, event: &ui::TextInputEvent, window, cx| match event { + ui::TextInputEvent::Confirmed => this.commit_track_rename(window, cx), + ui::TextInputEvent::Cancelled => { + this.track_rename = None; + cx.notify(); + } + _ => {} + }, + )); let player_frame_rect = crate::editor_canvas::canvas_rect_cell(); let preview = cx.new(|_| PreviewFrameView::new(player_frame_rect.clone())); let editor = cx.entity(); @@ -2263,6 +2278,8 @@ impl EditorWindow { hex_inputs, picker_hex, preset_name_input, + track_rename: None, + track_name_input, fields: HashMap::new(), field_editing: None, _text_events: text_events, @@ -5277,14 +5294,21 @@ impl EditorWindow { edits::reorder_overlay_track(&mut self.project, &available, from, reorder.target_index) } else { rows.get(reorder.target_index).is_some_and(|target| { - self.project.timeline.as_mut().is_some_and(|timeline| { + let moved = self.project.timeline.as_mut().is_some_and(|timeline| { edits::reorder_track_lane( timeline, reorder.source.kind, reorder.source.lane, target.lane, ) - }) + }); + let renamed = edits::reorder_track_names( + &mut self.project.track_names, + reorder.source.kind, + reorder.source.lane, + target.lane, + ); + moved || renamed }) }; if changed { @@ -6813,8 +6837,10 @@ impl EditorWindow { cx, ) } else { - self.edit( - |timeline| edits::delete_segments(timeline, selection.track, &selection.indices), + self.edit_timeline_project( + |project| { + edits::delete_segments_with_names(project, selection.track, &selection.indices) + }, window, cx, ) @@ -8067,6 +8093,145 @@ impl EditorWindow { cx.notify(); } + fn open_track_rename(&mut self, row: TrackRow, window: &mut Window, cx: &mut Context) { + if !self.project_ready() { + return; + } + let current = self + .project + .track_names + .get(&timeline::track_name_key(row)) + .cloned() + .unwrap_or_else(|| row.kind.label().to_string()); + self.track_rename = Some(row); + self.track_name_input.update(cx, |input, cx| { + input.set_placeholder(tr::editor::window::track_rename::placeholder()); + input.set_text(current, cx); + input.focus_and_select_all(window, cx); + }); + cx.notify(); + } + + fn commit_track_rename(&mut self, window: &mut Window, cx: &mut Context) { + let Some(row) = self.track_rename.take() else { + return; + }; + let name = self.track_name_input.read(cx).text().trim().to_string(); + let key = timeline::track_name_key(row); + let default = name.is_empty() || name == row.kind.label(); + // Written straight to the project: `edit_project` goes through an + // open style group's apply path, which keeps only style settings. + let track_names = &mut self.project.track_names; + let changed = if default { + track_names.remove(&key).is_some() + } else if track_names.get(&key) == Some(&name) { + false + } else { + track_names.insert(key, name); + true + }; + if changed && self.project_ready() { + self.project_changed(window, cx); + self.note_project_edit("track-rename"); + } + let focus = self.focus.clone(); + window.focus(&focus, cx); + cx.notify(); + } + + fn render_track_rename(&self, cx: &mut Context) -> Option { + self.track_rename?; + let theme = self.theme; + Some( + div() + .absolute() + .top_0() + .left_0() + .size_full() + .flex() + .items_center() + .justify_center() + .child( + div() + .id("track-rename-backdrop") + .absolute() + .top_0() + .left_0() + .size_full() + .bg(gpui::hsla(0., 0., 0., 0.5)) + .on_click(cx.listener(|this, _, _window, cx| { + this.track_rename = None; + cx.notify(); + })), + ) + .child( + div() + .w(px(360.)) + .flex() + .flex_col() + .gap(px(12.)) + .p(px(16.)) + .rounded(px(12.)) + .border_1() + .border_color(Hsla::from(theme.editor.line)) + .bg(Hsla::from(theme.editor.card)) + .shadow(theme.editor.pop_shadow()) + .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation()) + .child( + div() + .text_size(px(14.)) + .font_weight(FontWeight::SEMIBOLD) + .text_color(Hsla::from(theme.editor.text_1)) + .child(tr::editor::window::track_rename::title()), + ) + .child( + ui::TextInput::plain(&theme, "track-name", &self.track_name_input) + .padding_x(px(12.)) + .height(px(36.)) + .radius(px(8.)) + .text_size(px(14.)), + ) + .child( + div() + .flex() + .flex_row() + .justify_end() + .gap(px(8.)) + .child( + ui::Button::plain( + &theme, + "track-rename-cancel", + ui::ButtonVariant::Gray, + ui::ButtonSize::Md, + ) + .label(tr::common::cancel()) + .on_click(cx.listener( + |this, _, _window, cx| { + this.track_rename = None; + cx.notify(); + }, + )), + ) + .child( + ui::Button::plain( + &theme, + "track-rename-confirm", + ui::ButtonVariant::Blue, + ui::ButtonSize::Md, + ) + .label(tr::editor::window::track_rename::confirm()) + .on_click(cx.listener( + |this, _, window, cx| { + this.commit_track_rename(window, cx); + }, + )), + ), + ), + ) + .into_any_element(), + ) + } + fn scene_available(&self) -> bool { timeline::scene_available(&self.project, self.has_camera) } @@ -12113,7 +12278,9 @@ impl EditorWindow { MouseButton::Left, cx.listener(move |this, event: &MouseDownEvent, window, cx| { if f32::from(event.position.x) < timeline::content_left() { - if can_reorder { + if event.click_count == 2 { + this.open_track_rename(track_row, window, cx); + } else if can_reorder { this.begin_lane_reorder(track_row, event.position, window, cx); } else { this.select_lane_header(kind, lane, cx); @@ -13253,6 +13420,7 @@ impl Render for EditorWindow { .children(self.render_style_presets_menu(cx)) .children(self.render_preset_dialog(cx)) .children(self.render_marker_overlays(window, cx)) + .children(self.render_track_rename(cx)) // The clips overlays: import menu, record modal, and the card // drag's window-wide layer with its floating ghost. .children(self.render_clips_overlays(cx)) diff --git a/apps/desktop-gpui/src/i18n/editor_shell_surface_tests.rs b/apps/desktop-gpui/src/i18n/editor_shell_surface_tests.rs index 05e50b7b5a8..c5836eed7c7 100644 --- a/apps/desktop-gpui/src/i18n/editor_shell_surface_tests.rs +++ b/apps/desktop-gpui/src/i18n/editor_shell_surface_tests.rs @@ -1441,6 +1441,12 @@ fn editor_shell_surfaces_match_the_literals_they_replaced() { tr::editor::timeline::picker::shape(), "Draw arrows, boxes, circles and highlights over your recording.", ), + (tr::editor::window::track_rename::title(), "Rename track"), + ( + tr::editor::window::track_rename::placeholder(), + "Track name", + ), + (tr::editor::window::track_rename::confirm(), "Rename"), ]; for (translated, literal) in pairs { assert_eq!(translated, literal); diff --git a/crates/editor/src/audio.rs b/crates/editor/src/audio.rs index db1004fef56..69bf085033b 100644 --- a/crates/editor/src/audio.rs +++ b/crates/editor/src/audio.rs @@ -2113,6 +2113,7 @@ fn audio_project_key(project: &ProjectConfiguration) -> Option> { text_size_version: _, text_anim_version: _, markers: _, + track_names: _, } = project; let timeline = timeline.as_ref().map(|timeline| { let TimelineConfiguration { diff --git a/crates/project/src/configuration.rs b/crates/project/src/configuration.rs index be8638b50e0..33cf923085d 100644 --- a/crates/project/src/configuration.rs +++ b/crates/project/src/configuration.rs @@ -3094,6 +3094,8 @@ pub struct ProjectConfiguration { skip_serializing_if = "Vec::is_empty" )] pub markers: Vec, + #[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")] + pub track_names: std::collections::BTreeMap, } pub const TEXT_SIZE_VERSION: u32 = 1; @@ -3147,6 +3149,7 @@ impl Default for ProjectConfiguration { text_size_version: TEXT_SIZE_VERSION, text_anim_version: TEXT_ANIM_VERSION, markers: Vec::new(), + track_names: Default::default(), } } }