screencapturekit/stream/configuration/
captured_elements.rs

1//! Captured elements configuration
2//!
3//! Methods for configuring which elements are included in the capture
4//! (cursor, shadows, etc.).
5
6use super::internal::SCStreamConfiguration;
7
8impl SCStreamConfiguration {
9    /// Show or hide the cursor in captured frames
10    ///
11    /// # Examples
12    ///
13    /// ```
14    /// use screencapturekit::prelude::*;
15    ///
16    /// let mut config = SCStreamConfiguration::default();
17    /// config.set_shows_cursor(true);
18    /// assert!(config.shows_cursor());
19    /// ```
20    pub fn set_shows_cursor(&mut self, shows_cursor: bool) -> &mut Self {
21        unsafe {
22            crate::ffi::sc_stream_configuration_set_shows_cursor(self.as_ptr(), shows_cursor);
23        }
24        self
25    }
26
27    /// Show or hide the cursor (builder pattern)
28    #[must_use]
29    pub fn with_shows_cursor(mut self, shows_cursor: bool) -> Self {
30        self.set_shows_cursor(shows_cursor);
31        self
32    }
33
34    /// Check if cursor is shown in capture
35    pub fn shows_cursor(&self) -> bool {
36        unsafe { crate::ffi::sc_stream_configuration_get_shows_cursor(self.as_ptr()) }
37    }
38
39    /// Show mouse click indicators (macOS 15.0+)
40    ///
41    /// When enabled, draws a circle around the cursor when clicked.
42    /// This helps viewers track mouse activity in recordings.
43    ///
44    /// # Availability
45    /// macOS 15.0+. On earlier versions, this setting has no effect.
46    ///
47    /// # Examples
48    /// ```
49    /// use screencapturekit::prelude::*;
50    ///
51    /// let config = SCStreamConfiguration::new()
52    ///     .with_shows_cursor(true)
53    ///     .with_shows_mouse_clicks(true);
54    /// ```
55    #[cfg(feature = "macos_15_0")]
56    pub fn set_shows_mouse_clicks(&mut self, shows_mouse_clicks: bool) -> &mut Self {
57        unsafe {
58            crate::ffi::sc_stream_configuration_set_shows_mouse_clicks(
59                self.as_ptr(),
60                shows_mouse_clicks,
61            );
62        }
63        self
64    }
65
66    /// Show mouse click indicators (builder pattern)
67    #[cfg(feature = "macos_15_0")]
68    #[must_use]
69    pub fn with_shows_mouse_clicks(mut self, shows_mouse_clicks: bool) -> Self {
70        self.set_shows_mouse_clicks(shows_mouse_clicks);
71        self
72    }
73
74    /// Check if mouse click indicators are shown (macOS 15.0+)
75    #[cfg(feature = "macos_15_0")]
76    pub fn shows_mouse_clicks(&self) -> bool {
77        unsafe { crate::ffi::sc_stream_configuration_get_shows_mouse_clicks(self.as_ptr()) }
78    }
79
80    /// Capture only window shadows (macOS 14.0+)
81    ///
82    /// When set to `true`, the stream captures only the shadows of windows,
83    /// not the actual window content. This is useful for creating transparency
84    /// or blur effects in compositing applications.
85    ///
86    /// # Availability
87    /// macOS 14.0+. On earlier versions, this setting has no effect.
88    ///
89    /// # Examples
90    /// ```no_run
91    /// use screencapturekit::prelude::*;
92    ///
93    /// let config = SCStreamConfiguration::new()
94    ///     .with_width(1920)
95    ///     .with_height(1080)
96    ///     .with_captures_shadows_only(true);
97    /// ```
98    #[cfg(feature = "macos_14_0")]
99    pub fn set_captures_shadows_only(&mut self, captures_shadows_only: bool) -> &mut Self {
100        unsafe {
101            crate::ffi::sc_stream_configuration_set_captures_shadows_only(
102                self.as_ptr(),
103                captures_shadows_only,
104            );
105        }
106        self
107    }
108
109    /// Capture only window shadows (builder pattern)
110    #[cfg(feature = "macos_14_0")]
111    #[must_use]
112    pub fn with_captures_shadows_only(mut self, captures_shadows_only: bool) -> Self {
113        self.set_captures_shadows_only(captures_shadows_only);
114        self
115    }
116
117    /// Get whether only window shadows are captured (macOS 14.0+).
118    #[cfg(feature = "macos_14_0")]
119    pub fn captures_shadows_only(&self) -> bool {
120        unsafe { crate::ffi::sc_stream_configuration_get_captures_shadows_only(self.as_ptr()) }
121    }
122
123    /// Ignore shadows for display capture (macOS 14.0+)
124    ///
125    /// When set to `true`, window shadows are excluded from display capture.
126    ///
127    /// # Availability
128    /// macOS 14.0+. On earlier versions, this setting has no effect.
129    #[cfg(feature = "macos_14_0")]
130    pub fn set_ignores_shadows_display(&mut self, ignores_shadows: bool) -> &mut Self {
131        unsafe {
132            crate::ffi::sc_stream_configuration_set_ignores_shadows_display(
133                self.as_ptr(),
134                ignores_shadows,
135            );
136        }
137        self
138    }
139
140    /// Ignore shadows for display capture (builder pattern)
141    #[cfg(feature = "macos_14_0")]
142    #[must_use]
143    pub fn with_ignores_shadows_display(mut self, ignores_shadows: bool) -> Self {
144        self.set_ignores_shadows_display(ignores_shadows);
145        self
146    }
147
148    /// Check if shadows are ignored for display capture (macOS 14.0+)
149    #[cfg(feature = "macos_14_0")]
150    pub fn ignores_shadows_display(&self) -> bool {
151        unsafe { crate::ffi::sc_stream_configuration_get_ignores_shadows_display(self.as_ptr()) }
152    }
153
154    /// Ignore global clip for display capture (macOS 14.0+)
155    ///
156    /// When set to `true`, the global clip region is ignored for display capture.
157    ///
158    /// # Availability
159    /// macOS 14.0+. On earlier versions, this setting has no effect.
160    #[cfg(feature = "macos_14_0")]
161    pub fn set_ignore_global_clip_display(&mut self, ignore: bool) -> &mut Self {
162        unsafe {
163            crate::ffi::sc_stream_configuration_set_ignore_global_clip_display(
164                self.as_ptr(),
165                ignore,
166            );
167        }
168        self
169    }
170
171    /// Ignore global clip for display capture (builder pattern)
172    #[cfg(feature = "macos_14_0")]
173    #[must_use]
174    pub fn with_ignore_global_clip_display(mut self, ignore: bool) -> Self {
175        self.set_ignore_global_clip_display(ignore);
176        self
177    }
178
179    /// Check if global clip is ignored for display capture (macOS 14.0+)
180    #[cfg(feature = "macos_14_0")]
181    pub fn ignore_global_clip_display(&self) -> bool {
182        unsafe { crate::ffi::sc_stream_configuration_get_ignore_global_clip_display(self.as_ptr()) }
183    }
184
185    /// Ignore global clip for single window capture (macOS 14.0+)
186    ///
187    /// When set to `true`, the global clip region is ignored for single window capture.
188    ///
189    /// # Availability
190    /// macOS 14.0+. On earlier versions, this setting has no effect.
191    #[cfg(feature = "macos_14_0")]
192    pub fn set_ignore_global_clip_single_window(&mut self, ignore: bool) -> &mut Self {
193        unsafe {
194            crate::ffi::sc_stream_configuration_set_ignore_global_clip_single_window(
195                self.as_ptr(),
196                ignore,
197            );
198        }
199        self
200    }
201
202    /// Ignore global clip for single window capture (builder pattern)
203    #[cfg(feature = "macos_14_0")]
204    #[must_use]
205    pub fn with_ignore_global_clip_single_window(mut self, ignore: bool) -> Self {
206        self.set_ignore_global_clip_single_window(ignore);
207        self
208    }
209
210    /// Check if global clip is ignored for single window capture (macOS 14.0+)
211    #[cfg(feature = "macos_14_0")]
212    pub fn ignore_global_clip_single_window(&self) -> bool {
213        unsafe {
214            crate::ffi::sc_stream_configuration_get_ignore_global_clip_single_window(self.as_ptr())
215        }
216    }
217}