Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Merge remote-tracking branch 'origin/main' into chrvasile/text-style-copy-paste
chrvasilea0783808032e
diff --cc apps/desktop-gpui/src/editor_panels.rsindex deefaa4f5,8410fc8fc..193e0fd8e--- a/apps/desktop-gpui/src/editor_panels.rs+++ b/apps/desktop-gpui/src/editor_panels.rs@@@ -8035,91 -7951,86 +8050,171 @@@ impl EditorWindowmod tests {use super::*;+ #[test]+ fn unchanged_timing_fields_preserve_redo() {+ use crate::editor_edits::ProjectHistory;++ for base in [2., 2.3456] {+ for caption in [true, false] {+ for start in [true, false] {+ for paused in [true, false] {+ let mut project: cap_project::ProjectConfiguration =+ serde_json::from_value(serde_json::json!({+ "timeline": {+ "segments": [],+ "zoomSegments": [],+ "captionSegments": [{ "id": "caption", "start": base, "end": base + 4., "text": "hello" }],+ "keyboardSegments": [{ "id": "keyboard", "start": base, "end": base + 4., "displayText": "A", "keys": [] }]+ }+ }))+ .unwrap();+ let initial = serde_json::to_value(&project).unwrap();+ let mut history = ProjectHistory::new(project.clone());+ let commit = |project: &mut cap_project::ProjectConfiguration,+ text: &str| {+ let value = text.parse().unwrap();+ let timeline = project.timeline.as_mut().unwrap();+ if caption {+ commit_segment_timing(+ &mut timeline.caption_segments[0],+ start,+ text,+ value,+ )+ } else {+ commit_segment_timing(+ &mut timeline.keyboard_segments[0],+ start,+ text,+ value,+ )+ }+ };+ let before = if start { base } else { base + 4. };+ assert!(commit(&mut project, &format!("{:.2}", before + 1.)));+ history.record(&project);+ let edited = serde_json::to_value(&project).unwrap();+ project = history.undo().unwrap().clone();+ assert_eq!(serde_json::to_value(&project).unwrap(), initial);++ if paused {+ history.pause();+ }+ if commit(&mut project, &format!("{before:.2}")) {+ history.record(&project);+ }+ if paused {+ history.resume(&project);+ }+ let context = format!(+ "base={base}, caption={caption}, start={start}, paused={paused}"+ );+ assert_eq!(+ serde_json::to_value(&project).unwrap(),+ initial,+ "{context}"+ );+ assert!(history.can_redo(), "{context}");+ assert!(!history.can_undo(), "{context}");+ assert_eq!(+ serde_json::to_value(history.redo().unwrap()).unwrap(),+ edited+ );+ assert_eq!(+ serde_json::to_value(history.undo().unwrap()).unwrap(),+ initial+ );+ }+ }+ }+ }+ }++ #[test]+ fn pasting_a_text_style_keeps_content_timing_position_and_layout() {+ let mut source = crate::editor_edits::default_text_segment(0., 2., 0);+ source.content = "Hello".into();+ source.font_family = "Georgia".into();+ source.font_size = 96.;+ source.font_weight = 400.;+ source.italic = true;+ source.uppercase = true;+ source.letter_spacing = 3.;+ source.color = "#ff0000".into();+ source.background_color = Some("#00000080".into());+ source.gradient_color = Some("#00ff00".into());+ source.animation_in = TextAnimation::Pop;+ source.animation_out = TextAnimation::Wipe;+ source.animation_in_duration = 0.4;+ source.animation_out_duration = 0.6;+ source.center = XY::new(0.2, 0.2);+ source.layout = TextLayout::Fullscreen;++ let mut target = crate::editor_edits::default_text_segment(5., 8., 1);+ target.content = "World".into();+ target.center = XY::new(0.7, 0.8);+ target.size = XY::new(0.2, 0.1);++ assert!(TextStyle::of(&source).apply_to(&mut target));++ assert_eq!(target.content, "World");+ assert_eq!(target.start, 5.);+ assert_eq!(target.end, 8.);+ assert_eq!(target.track, 1);+ assert_eq!(target.layout, TextLayout::Overlay);+ assert_eq!(target.center.x, 0.7);+ assert_eq!(target.font_family, "Georgia");+ assert_eq!(target.font_size, 96.);+ assert!(target.italic && target.uppercase);+ assert_eq!(target.letter_spacing, 3.);+ assert_eq!(target.color, "#ff0000");+ assert_eq!(target.background_color.as_deref(), Some("#00000080"));+ assert_eq!(target.gradient_color.as_deref(), Some("#00ff00"));+ assert_eq!(target.animation_in, TextAnimation::Pop);+ assert_eq!(target.animation_out, TextAnimation::Wipe);+ assert_eq!(target.animation_in_duration, 0.4);+ assert_eq!(target.animation_out_duration, 0.6);+ assert_eq!(TextStyle::of(&target), TextStyle::of(&source));+ }++ #[test]+ fn pasting_a_text_style_scales_the_box_from_its_top_edge() {+ let mut source = crate::editor_edits::default_text_segment(0., 2., 0);+ source.font_size = 96.;+ let mut target = crate::editor_edits::default_text_segment(0., 2., 0);+ target.font_size = 48.;+ target.center = XY::new(0.5, 0.5);+ target.size = XY::new(0.2, 0.1);++ assert!(TextStyle::of(&source).apply_to(&mut target));++ assert!((target.size.x - 0.4).abs() < 1e-9);+ assert!((target.size.y - 0.2).abs() < 1e-9);+ assert!((target.center.y - 0.55).abs() < 1e-9);+ assert_eq!(target.center.x, 0.5);+ }++ #[test]+ fn pasting_a_text_style_onto_its_own_source_changes_nothing() {+ for (center, size) in [+ (XY::new(0.3, 0.6), XY::new(0.25, 0.08)),+ (XY::new(0.5, 0.9), XY::new(0.3, 0.4)),+ ] {+ let mut segment = crate::editor_edits::default_text_segment(0., 2., 0);+ segment.color = "#ff0000".into();+ segment.center = center;+ segment.size = size;+ let style = TextStyle::of(&segment);+ let before = segment.clone();++ assert!(!style.apply_to(&mut segment));++ assert_eq!(TextStyle::of(&segment), style);+ assert_eq!(segment.center, before.center);+ assert_eq!(segment.size, before.size);+ }+ }+fn camera3d(start: f64, end: f64) -> Camera3DSegment {Camera3DSegment {start,