Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Sync camera preview shape with project config

Richie McIlroy293be488a57f
diff --git a/apps/desktop/src-tauri/src/camera.rs b/apps/desktop/src-tauri/src/camera.rs
index 6cb00db29..b1766d58e 100644
--- a/apps/desktop/src-tauri/src/camera.rs
+++ b/apps/desktop/src-tauri/src/camera.rs
@@ -43,9 +43,9 @@ pub enum CameraPreviewShape {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Type)]
pub struct CameraPreviewState {
- size: f32,
- shape: CameraPreviewShape,
- mirrored: bool,
+ pub size: f32,
+ pub shape: CameraPreviewShape,
+ pub mirrored: bool,
}
impl Default for CameraPreviewState {
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rs
index a5a0ecc00..e5f301906 100644
--- a/apps/desktop/src-tauri/src/recording.rs
+++ b/apps/desktop/src-tauri/src/recording.rs
@@ -3,10 +3,10 @@ use cap_fail::fail;
use cap_project::CursorMoveEvent;
use cap_project::cursor::SHORT_CURSOR_SHAPE_DEBOUNCE_MS;
use cap_project::{
- CursorClickEvent, InstantRecordingMeta, MultipleSegments, Platform, ProjectConfiguration,
- RecordingMeta, RecordingMetaInner, SharingMeta, StudioRecordingMeta, StudioRecordingStatus,
- TimelineConfiguration, TimelineSegment, UploadMeta, ZoomMode, ZoomSegment,
- cursor::CursorEvents,
+ CameraShape, CursorClickEvent, InstantRecordingMeta, MultipleSegments, Platform,
+ ProjectConfiguration, RecordingMeta, RecordingMetaInner, SharingMeta, StudioRecordingMeta,
+ StudioRecordingStatus, TimelineConfiguration, TimelineSegment, UploadMeta, ZoomMode,
+ ZoomSegment, cursor::CursorEvents,
};
use cap_recording::feeds::camera::CameraFeedLock;
#[cfg(target_os = "macos")]
@@ -42,6 +42,7 @@ use tauri_plugin_dialog::{DialogExt, MessageDialogBuilder};
use tauri_specta::Event;
use tracing::*;
+use crate::camera::{CameraPreviewManager, CameraPreviewShape};
use crate::web_api::AuthedApiError;
use crate::{
App, CurrentRecordingChanged, MutableState, NewStudioRecordingAdded, RecordingState,
@@ -1680,6 +1681,24 @@ fn project_config_from_recording(
let mut config = default_config.unwrap_or_default();
+ let camera_preview_manager = CameraPreviewManager::new(app);
+ if let Ok(camera_preview_state) = camera_preview_manager.get_state() {
+ match camera_preview_state.shape {
+ CameraPreviewShape::Round => {
+ config.camera.shape = CameraShape::Square;
+ config.camera.rounding = 100.0;
+ }
+ CameraPreviewShape::Square => {
+ config.camera.shape = CameraShape::Square;
+ config.camera.rounding = 25.0;
+ }
+ CameraPreviewShape::Full => {
+ config.camera.shape = CameraShape::Source;
+ config.camera.rounding = 25.0;
+ }
+ }
+ }
+
let timeline_segments = recordings
.segments
.iter()