Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ CAP_DESKTOP_SENTRY_URL=
RUST_BACKTRACE=full



### @cap/web
NODE_ENV=development
WEB_PORT=3000
Expand Down
6 changes: 1 addition & 5 deletions apps/desktop/src/routes/editor/ConfigSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
type BackgroundSource,
StereoMode,
ZoomSegment,
commands
commands,
} from "~/utils/tauri";
import { useEditorContext } from "./context";
import {
Expand Down Expand Up @@ -86,7 +86,6 @@ const BACKGROUND_SOURCES_LIST = [
"gradient",
] satisfies Array<BackgroundSource["type"]>;


const BACKGROUND_COLORS = [
"#FF0000", // Red
"#FF4500", // Orange-Red
Expand Down Expand Up @@ -1676,15 +1675,12 @@ function ZoomSegmentConfig(props: {
<KTabs.Trigger
value="auto"
class="z-10 flex-1 py-2.5 text-gray-11 transition-colors duration-100 outline-none ui-selected:text-gray-12 peer"
// onClick={() => setSelectedTab(item.id)}
disabled
>
Auto
</KTabs.Trigger>
<KTabs.Trigger
value="manual"
class="z-10 flex-1 py-2.5 text-gray-11 transition-colors duration-100 outline-none ui-selected:text-gray-12 peer"
// onClick={() => setSelectedTab(item.id)}
>
Manual
</KTabs.Trigger>
Expand Down
1 change: 1 addition & 0 deletions crates/editor/src/editor_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ impl EditorInstance {
frame_number,
fps,
resolution_base,
&segment.cursor,
),
segment.cursor.clone(),
)
Expand Down
1 change: 1 addition & 0 deletions crates/editor/src/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl Playback {
frame_number,
fps,
resolution_base,
&segment.cursor,
);

self.renderer
Expand Down
62 changes: 62 additions & 0 deletions crates/project/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,68 @@ impl CursorEvents {
let file = File::open(path).map_err(|e| format!("Failed to open cursor file: {}", e))?;
serde_json::from_reader(file).map_err(|e| format!("Failed to parse cursor data: {}", e))
}

pub fn cursor_position_at(&self, time: f64) -> Option<XY<f64>> {
// Debug print to understand what we're looking for
println!("Looking for cursor position at time: {}", time);
println!("Total cursor events: {}", self.moves.len());

// Check if we have any move events at all
if self.moves.is_empty() {
println!("No cursor move events available");
return None;
}

// Find the move event closest to the given time, preferring events that happened before
let filtered_events = self
.moves
.iter()
.filter(|event| event.time_ms <= time * 1000.0)
.collect::<Vec<_>>();

println!(
"Found {} events before or at time {}",
filtered_events.len(),
time
);

if !filtered_events.is_empty() {
// Take the most recent one before the given time
let closest = filtered_events
.iter()
.max_by(|a, b| {
a.time_ms
.partial_cmp(&b.time_ms)
.unwrap_or(std::cmp::Ordering::Equal)
})
.unwrap();

println!(
"Selected event at time {} with pos ({}, {})",
closest.time_ms, closest.x, closest.y
);

return Some(XY::new(closest.x, closest.y));
}

// If no events happened before, find the earliest one
let earliest = self.moves.iter().min_by(|a, b| {
a.time_ms
.partial_cmp(&b.time_ms)
.unwrap_or(std::cmp::Ordering::Equal)
});

if let Some(event) = earliest {
println!(
"No events before requested time, using earliest at {} with pos ({}, {})",
event.time_ms, event.x, event.y
);
return Some(XY::new(event.x, event.y));
}

println!("Could not find any usable cursor position");
None
}
}

impl From<CursorData> for CursorEvents {
Expand Down
2 changes: 1 addition & 1 deletion crates/project/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod configuration;
mod cursor;
pub mod cursor;
mod meta;

pub use configuration::*;
Expand Down
13 changes: 10 additions & 3 deletions crates/rendering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,14 @@ pub async fn render_video_to_channel(
.get_frames(segment_time as f32, !project.camera.hide)
.await
{
let uniforms =
ProjectUniforms::new(&constants, &project, frame_number, fps, resolution_base);
let uniforms = ProjectUniforms::new(
&constants,
&project,
frame_number,
fps,
resolution_base,
&segment.cursor,
);

let frame = frame_renderer
.render(segment_frames, uniforms, &segment.cursor)
Expand Down Expand Up @@ -684,6 +690,7 @@ impl ProjectUniforms {
frame_number: u32,
fps: u32,
resolution_base: XY<u32>,
cursor_events: &CursorEvents,
) -> Self {
let options = &constants.options;
let output_size = Self::get_output_size(options, project, resolution_base);
Expand Down Expand Up @@ -723,7 +730,7 @@ impl ProjectUniforms {
.unwrap_or(&[]),
);

let zoom = InterpolatedZoom::new(segment_cursor);
let zoom = InterpolatedZoom::new(segment_cursor, Some(cursor_events));

let display = {
let output_size = XY::new(output_size.0 as f64, output_size.1 as f64);
Expand Down
Loading
Loading