Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(desktop-gpui): let the empty zoom lane add a zoom while the generate prompt shows
Richie McIlroycc664e454a58
diff --git a/apps/desktop-gpui/src/editor_window.rs b/apps/desktop-gpui/src/editor_window.rsindex 7ca983337..de1afbea0 100644--- a/apps/desktop-gpui/src/editor_window.rs+++ b/apps/desktop-gpui/src/editor_window.rs@@ -11128,24 +11128,25 @@ impl EditorWindow {let hovering = self.hovering_generate_zoom;div().id("zoom-generate-prompt")+ .debug_selector(|| "zoom-generate-prompt".into()).absolute().left(px(timeline::TRACK_GUTTER)).right_0().top_0().bottom_0()+ // Only the copy and its buttons take the press;+ // the rest of the lane still creates a zoom+ // (`TL/ZoomTrack.tsx:308-313`)..child(div()- .id("zoom-generate-hit").absolute().inset_0().flex().flex_row().items_center().justify_center()- .gap(px(10.)).pl(px(10.)).pr(px(32.))- .rounded(px(8.)).text_size(px(12.)).line_height(px(16.)).text_color(Hsla::from(if hovering {@@ -11153,42 +11154,58 @@ impl EditorWindow {} else {theme.editor.text_3}))- .on_mouse_down(- MouseButton::Left,- cx.listener(|_, _, _, cx| cx.stop_propagation()),- )- .on_hover(cx.listener(|this, hovered: &bool, _, cx| {- if this.hovering_generate_zoom != *hovered {- this.hovering_generate_zoom = *hovered;- cx.notify();- }- }))- .child(div().min_w_0().truncate().child(- self.auto_zoom_message.unwrap_or("Add zooms automatically"),- )).child(- ui::Button::plain(- &theme,- "zoom-generate-button",- ui::ButtonVariant::Primary,- ui::ButtonSize::Sm,- )- .label(if generating {- "Generating…"- } else {- "Generate"- })- .radius(px(7.))- .disabled(generating)- .on_click(- cx.listener(|this, _, window, cx| {- this.generate_auto_zoom(window, cx);- }),- ),+ div()+ .id("zoom-generate-hit")+ .debug_selector(|| "zoom-generate-hit".into())+ .min_w_0()+ .flex()+ .flex_row()+ .items_center()+ .gap(px(10.))+ .on_mouse_down(+ MouseButton::Left,+ cx.listener(|_, _, _, cx| cx.stop_propagation()),+ )+ .on_hover(cx.listener(|this, hovered: &bool, _, cx| {+ if this.hovering_generate_zoom != *hovered {+ this.hovering_generate_zoom = *hovered;+ cx.notify();+ }+ }))+ .child(+ div().min_w_0().truncate().child(+ self.auto_zoom_message+ .unwrap_or("Add zooms automatically"),+ ),+ )+ .child(+ ui::Button::plain(+ &theme,+ "zoom-generate-button",+ ui::ButtonVariant::Primary,+ ui::ButtonSize::Sm,+ )+ .label(if generating {+ "Generating…"+ } else {+ "Generate"+ })+ .radius(px(7.))+ .disabled(generating)+ .on_click(cx.listener(|this, _, window, cx| {+ this.generate_auto_zoom(window, cx);+ })),+ ),),).child(div()+ .id("zoom-generate-dismiss-hit")+ .on_mouse_down(+ MouseButton::Left,+ cx.listener(|_, _, _, cx| cx.stop_propagation()),+ ).absolute().top(px((model.track_height() - 20.) / 2.)).right(px(6.))@@ -13546,6 +13563,110 @@ mod tests {}}+ // gpui's test windows have no platform window handle on macOS or Windows, which the editor needs.+ #[cfg(target_os = "linux")]+ mod empty_zoom_lane {+ use super::*;++ struct LaneView {+ editor: Entity<EditorWindow>,+ _driver: TransportDriver,+ _project: tempfile::TempDir,+ }++ impl Render for LaneView {+ fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {+ let viewport_width = f32::from(window.viewport_size().width);+ self.editor.update(cx, |editor, cx| {+ div()+ .size_full()+ .child(editor.render_timeline_body(viewport_width, cx))+ })+ }+ }++ // A loaded studio project with recorded cursor data and no zooms yet,+ // which is when the lane shows its Generate prompt.+ fn fixture(+ cx: &mut gpui::TestAppContext,+ ) -> (Entity<EditorWindow>, &mut gpui::VisualTestContext) {+ let project = tempfile::tempdir().unwrap();+ let (handle, driver, _) = transport();+ let (view, cx) = cx.add_window_view(move |window, cx| {+ let editor = cx.new(|cx| EditorWindow::new(project.path().into(), window, cx));+ editor.update(cx, |editor, cx| {+ let config: ProjectConfiguration = serde_json::from_value(serde_json::json!({+ "timeline": {+ "segments": [{ "recordingSegment": 0, "timescale": 1.0, "start": 0.0, "end": 30.0 }]+ }+ }))+ .unwrap();+ editor.set_summary(+ ProjectSummary {+ recordings: Arc::new(ProjectRecordingsMeta {+ segments: Vec::new(),+ }),+ pretty_name: "Recording".into(),+ timeline: TimelineModel::build(&config, false, false),+ duration: 30.,+ has_camera: false,+ has_cursor_data: true,+ recorded_cursor_family: None,+ clip_display_durations: vec![30.],+ recording_duration: 30.,+ multiple_clips: false,+ has_microphone: false,+ has_system_audio: false,+ mic_channels: None,+ recording_clips: 1,+ },+ window,+ cx,+ );+ editor.set_project(config, window, cx);+ editor.transport = Some(handle);+ });+ LaneView {+ editor,+ _driver: driver,+ _project: project,+ }+ });+ (view.read_with(cx, |view, _| view.editor.clone()), cx)+ }++ fn press(cx: &mut gpui::VisualTestContext, position: Point<Pixels>) {+ cx.simulate_mouse_move(position, None, gpui::Modifiers::default());+ cx.simulate_mouse_down(position, MouseButton::Left, gpui::Modifiers::default());+ }++ #[gpui::test]+ fn a_press_beside_the_generate_prompt_starts_a_new_zoom(cx: &mut gpui::TestAppContext) {+ let (editor, cx) = fixture(cx);+ let lane = cx.debug_bounds("zoom-generate-prompt").unwrap();+ let prompt = cx.debug_bounds("zoom-generate-hit").unwrap();+ let beside = point(lane.left() + px(24.), lane.center().y);+ assert!(!prompt.contains(&beside));+ press(cx, beside);+ editor.read_with(cx, |editor, _| {+ assert!(matches!(+ editor.drag.as_ref().map(|drag| &drag.kind),+ Some(DragKind::CreateZoom { .. })+ ));+ });+ }++ #[gpui::test]+ fn a_press_on_the_generate_prompt_copy_does_not_start_a_zoom(+ cx: &mut gpui::TestAppContext,+ ) {+ let (editor, cx) = fixture(cx);+ let prompt = cx.debug_bounds("zoom-generate-hit").unwrap();+ press(cx, point(prompt.left() + px(4.), prompt.center().y));+ editor.read_with(cx, |editor, _| assert!(editor.drag.is_none()));+ }+ }+// gpui's test windows have no platform window handle on macOS or Windows, which the editor needs.#[cfg(target_os = "linux")]#[gpui::test]