Group shapes
This commit is contained in:
@@ -440,84 +440,82 @@ fn generate_vector_thumbnail(clip: &VectorClip, bg_color: egui::Color32) -> Vec<
|
||||
// Iterate through layers and render shapes
|
||||
for layer_node in clip.layers.iter() {
|
||||
if let AnyLayer::Vector(vector_layer) = &layer_node.data {
|
||||
// Render each shape instance
|
||||
for shape_instance in &vector_layer.shape_instances {
|
||||
if let Some(shape) = vector_layer.shapes.get(&shape_instance.shape_id) {
|
||||
// Get the path (frame 0)
|
||||
let kurbo_path = shape.path();
|
||||
// Render each shape at time 0.0 (frame 0)
|
||||
for shape in vector_layer.shapes_at_time(0.0) {
|
||||
// Get the path (frame 0)
|
||||
let kurbo_path = shape.path();
|
||||
|
||||
// Convert kurbo BezPath to tiny-skia PathBuilder
|
||||
let mut path_builder = PathBuilder::new();
|
||||
for el in kurbo_path.iter() {
|
||||
match el {
|
||||
PathEl::MoveTo(p) => {
|
||||
let x = (p.x * scale + offset_x) as f32;
|
||||
let y = (p.y * scale + offset_y) as f32;
|
||||
path_builder.move_to(x, y);
|
||||
}
|
||||
PathEl::LineTo(p) => {
|
||||
let x = (p.x * scale + offset_x) as f32;
|
||||
let y = (p.y * scale + offset_y) as f32;
|
||||
path_builder.line_to(x, y);
|
||||
}
|
||||
PathEl::QuadTo(p1, p2) => {
|
||||
let x1 = (p1.x * scale + offset_x) as f32;
|
||||
let y1 = (p1.y * scale + offset_y) as f32;
|
||||
let x2 = (p2.x * scale + offset_x) as f32;
|
||||
let y2 = (p2.y * scale + offset_y) as f32;
|
||||
path_builder.quad_to(x1, y1, x2, y2);
|
||||
}
|
||||
PathEl::CurveTo(p1, p2, p3) => {
|
||||
let x1 = (p1.x * scale + offset_x) as f32;
|
||||
let y1 = (p1.y * scale + offset_y) as f32;
|
||||
let x2 = (p2.x * scale + offset_x) as f32;
|
||||
let y2 = (p2.y * scale + offset_y) as f32;
|
||||
let x3 = (p3.x * scale + offset_x) as f32;
|
||||
let y3 = (p3.y * scale + offset_y) as f32;
|
||||
path_builder.cubic_to(x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
PathEl::ClosePath => {
|
||||
path_builder.close();
|
||||
}
|
||||
// Convert kurbo BezPath to tiny-skia PathBuilder
|
||||
let mut path_builder = PathBuilder::new();
|
||||
for el in kurbo_path.iter() {
|
||||
match el {
|
||||
PathEl::MoveTo(p) => {
|
||||
let x = (p.x * scale + offset_x) as f32;
|
||||
let y = (p.y * scale + offset_y) as f32;
|
||||
path_builder.move_to(x, y);
|
||||
}
|
||||
PathEl::LineTo(p) => {
|
||||
let x = (p.x * scale + offset_x) as f32;
|
||||
let y = (p.y * scale + offset_y) as f32;
|
||||
path_builder.line_to(x, y);
|
||||
}
|
||||
PathEl::QuadTo(p1, p2) => {
|
||||
let x1 = (p1.x * scale + offset_x) as f32;
|
||||
let y1 = (p1.y * scale + offset_y) as f32;
|
||||
let x2 = (p2.x * scale + offset_x) as f32;
|
||||
let y2 = (p2.y * scale + offset_y) as f32;
|
||||
path_builder.quad_to(x1, y1, x2, y2);
|
||||
}
|
||||
PathEl::CurveTo(p1, p2, p3) => {
|
||||
let x1 = (p1.x * scale + offset_x) as f32;
|
||||
let y1 = (p1.y * scale + offset_y) as f32;
|
||||
let x2 = (p2.x * scale + offset_x) as f32;
|
||||
let y2 = (p2.y * scale + offset_y) as f32;
|
||||
let x3 = (p3.x * scale + offset_x) as f32;
|
||||
let y3 = (p3.y * scale + offset_y) as f32;
|
||||
path_builder.cubic_to(x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
PathEl::ClosePath => {
|
||||
path_builder.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ts_path) = path_builder.finish() {
|
||||
// Draw fill if present
|
||||
if let Some(fill_color) = &shape.fill_color {
|
||||
if let Some(ts_path) = path_builder.finish() {
|
||||
// Draw fill if present
|
||||
if let Some(fill_color) = &shape.fill_color {
|
||||
let mut paint = Paint::default();
|
||||
paint.set_color(shape_color_to_tiny_skia(fill_color));
|
||||
paint.anti_alias = true;
|
||||
pixmap.fill_path(
|
||||
&ts_path,
|
||||
&paint,
|
||||
tiny_skia::FillRule::Winding,
|
||||
TsTransform::identity(),
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
// Draw stroke if present
|
||||
if let Some(stroke_color) = &shape.stroke_color {
|
||||
if let Some(stroke_style) = &shape.stroke_style {
|
||||
let mut paint = Paint::default();
|
||||
paint.set_color(shape_color_to_tiny_skia(fill_color));
|
||||
paint.set_color(shape_color_to_tiny_skia(stroke_color));
|
||||
paint.anti_alias = true;
|
||||
pixmap.fill_path(
|
||||
|
||||
let stroke = tiny_skia::Stroke {
|
||||
width: (stroke_style.width * scale) as f32,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
pixmap.stroke_path(
|
||||
&ts_path,
|
||||
&paint,
|
||||
tiny_skia::FillRule::Winding,
|
||||
&stroke,
|
||||
TsTransform::identity(),
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
// Draw stroke if present
|
||||
if let Some(stroke_color) = &shape.stroke_color {
|
||||
if let Some(stroke_style) = &shape.stroke_style {
|
||||
let mut paint = Paint::default();
|
||||
paint.set_color(shape_color_to_tiny_skia(stroke_color));
|
||||
paint.anti_alias = true;
|
||||
|
||||
let stroke = tiny_skia::Stroke {
|
||||
width: (stroke_style.width * scale) as f32,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
pixmap.stroke_path(
|
||||
&ts_path,
|
||||
&paint,
|
||||
&stroke,
|
||||
TsTransform::identity(),
|
||||
None,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,82 +117,78 @@ impl InfopanelPane {
|
||||
let mut first = true;
|
||||
|
||||
for instance_id in &info.instance_ids {
|
||||
if let Some(instance) = vector_layer.get_object(instance_id) {
|
||||
info.shape_ids.push(instance.shape_id);
|
||||
if let Some(shape) = vector_layer.get_shape_in_keyframe(instance_id, *shared.playback_time) {
|
||||
info.shape_ids.push(*instance_id);
|
||||
|
||||
if first {
|
||||
// First instance - set initial values
|
||||
info.x = Some(instance.transform.x);
|
||||
info.y = Some(instance.transform.y);
|
||||
info.rotation = Some(instance.transform.rotation);
|
||||
info.scale_x = Some(instance.transform.scale_x);
|
||||
info.scale_y = Some(instance.transform.scale_y);
|
||||
info.skew_x = Some(instance.transform.skew_x);
|
||||
info.skew_y = Some(instance.transform.skew_y);
|
||||
info.opacity = Some(instance.opacity);
|
||||
// First shape - set initial values
|
||||
info.x = Some(shape.transform.x);
|
||||
info.y = Some(shape.transform.y);
|
||||
info.rotation = Some(shape.transform.rotation);
|
||||
info.scale_x = Some(shape.transform.scale_x);
|
||||
info.scale_y = Some(shape.transform.scale_y);
|
||||
info.skew_x = Some(shape.transform.skew_x);
|
||||
info.skew_y = Some(shape.transform.skew_y);
|
||||
info.opacity = Some(shape.opacity);
|
||||
|
||||
// Get shape properties
|
||||
if let Some(shape) = vector_layer.shapes.get(&instance.shape_id) {
|
||||
info.fill_color = Some(shape.fill_color);
|
||||
info.stroke_color = Some(shape.stroke_color);
|
||||
info.stroke_width = shape
|
||||
.stroke_style
|
||||
.as_ref()
|
||||
.map(|s| Some(s.width))
|
||||
.unwrap_or(Some(1.0));
|
||||
}
|
||||
info.fill_color = Some(shape.fill_color);
|
||||
info.stroke_color = Some(shape.stroke_color);
|
||||
info.stroke_width = shape
|
||||
.stroke_style
|
||||
.as_ref()
|
||||
.map(|s| Some(s.width))
|
||||
.unwrap_or(Some(1.0));
|
||||
|
||||
first = false;
|
||||
} else {
|
||||
// Check if values differ (set to None if mixed)
|
||||
if info.x != Some(instance.transform.x) {
|
||||
if info.x != Some(shape.transform.x) {
|
||||
info.x = None;
|
||||
}
|
||||
if info.y != Some(instance.transform.y) {
|
||||
if info.y != Some(shape.transform.y) {
|
||||
info.y = None;
|
||||
}
|
||||
if info.rotation != Some(instance.transform.rotation) {
|
||||
if info.rotation != Some(shape.transform.rotation) {
|
||||
info.rotation = None;
|
||||
}
|
||||
if info.scale_x != Some(instance.transform.scale_x) {
|
||||
if info.scale_x != Some(shape.transform.scale_x) {
|
||||
info.scale_x = None;
|
||||
}
|
||||
if info.scale_y != Some(instance.transform.scale_y) {
|
||||
if info.scale_y != Some(shape.transform.scale_y) {
|
||||
info.scale_y = None;
|
||||
}
|
||||
if info.skew_x != Some(instance.transform.skew_x) {
|
||||
if info.skew_x != Some(shape.transform.skew_x) {
|
||||
info.skew_x = None;
|
||||
}
|
||||
if info.skew_y != Some(instance.transform.skew_y) {
|
||||
if info.skew_y != Some(shape.transform.skew_y) {
|
||||
info.skew_y = None;
|
||||
}
|
||||
if info.opacity != Some(instance.opacity) {
|
||||
if info.opacity != Some(shape.opacity) {
|
||||
info.opacity = None;
|
||||
}
|
||||
|
||||
// Check shape properties
|
||||
if let Some(shape) = vector_layer.shapes.get(&instance.shape_id) {
|
||||
// Compare fill colors - set to None if mixed
|
||||
if let Some(current_fill) = &info.fill_color {
|
||||
if *current_fill != shape.fill_color {
|
||||
info.fill_color = None;
|
||||
}
|
||||
// Compare fill colors - set to None if mixed
|
||||
if let Some(current_fill) = &info.fill_color {
|
||||
if *current_fill != shape.fill_color {
|
||||
info.fill_color = None;
|
||||
}
|
||||
// Compare stroke colors - set to None if mixed
|
||||
if let Some(current_stroke) = &info.stroke_color {
|
||||
if *current_stroke != shape.stroke_color {
|
||||
info.stroke_color = None;
|
||||
}
|
||||
}
|
||||
let stroke_w = shape
|
||||
.stroke_style
|
||||
.as_ref()
|
||||
.map(|s| s.width)
|
||||
.unwrap_or(1.0);
|
||||
if info.stroke_width != Some(stroke_w) {
|
||||
info.stroke_width = None;
|
||||
}
|
||||
// Compare stroke colors - set to None if mixed
|
||||
if let Some(current_stroke) = &info.stroke_color {
|
||||
if *current_stroke != shape.stroke_color {
|
||||
info.stroke_color = None;
|
||||
}
|
||||
}
|
||||
let stroke_w = shape
|
||||
.stroke_style
|
||||
.as_ref()
|
||||
.map(|s| s.width)
|
||||
.unwrap_or(1.0);
|
||||
if info.stroke_width != Some(stroke_w) {
|
||||
info.stroke_width = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -488,6 +484,7 @@ impl InfopanelPane {
|
||||
for instance_id in instance_ids {
|
||||
let action = SetInstancePropertiesAction::new(
|
||||
layer_id,
|
||||
*shared.playback_time,
|
||||
*instance_id,
|
||||
make_change(v),
|
||||
);
|
||||
@@ -507,6 +504,7 @@ impl InfopanelPane {
|
||||
for instance_id in instance_ids {
|
||||
let action = SetInstancePropertiesAction::new(
|
||||
layer_id,
|
||||
*shared.playback_time,
|
||||
*instance_id,
|
||||
make_change(v),
|
||||
);
|
||||
@@ -564,6 +562,7 @@ impl InfopanelPane {
|
||||
let action = SetShapePropertiesAction::set_fill_color(
|
||||
layer_id,
|
||||
*shape_id,
|
||||
*shared.playback_time,
|
||||
new_color,
|
||||
);
|
||||
shared.pending_actions.push(Box::new(action));
|
||||
@@ -578,6 +577,7 @@ impl InfopanelPane {
|
||||
let action = SetShapePropertiesAction::set_fill_color(
|
||||
layer_id,
|
||||
*shape_id,
|
||||
*shared.playback_time,
|
||||
default_fill,
|
||||
);
|
||||
shared.pending_actions.push(Box::new(action));
|
||||
@@ -612,6 +612,7 @@ impl InfopanelPane {
|
||||
let action = SetShapePropertiesAction::set_stroke_color(
|
||||
layer_id,
|
||||
*shape_id,
|
||||
*shared.playback_time,
|
||||
new_color,
|
||||
);
|
||||
shared.pending_actions.push(Box::new(action));
|
||||
@@ -626,6 +627,7 @@ impl InfopanelPane {
|
||||
let action = SetShapePropertiesAction::set_stroke_color(
|
||||
layer_id,
|
||||
*shape_id,
|
||||
*shared.playback_time,
|
||||
default_stroke,
|
||||
);
|
||||
shared.pending_actions.push(Box::new(action));
|
||||
@@ -654,6 +656,7 @@ impl InfopanelPane {
|
||||
let action = SetShapePropertiesAction::set_stroke_width(
|
||||
layer_id,
|
||||
*shape_id,
|
||||
*shared.playback_time,
|
||||
width,
|
||||
);
|
||||
shared.pending_actions.push(Box::new(action));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,50 @@ const MIN_PIXELS_PER_SECOND: f32 = 1.0; // Allow zooming out to see 10+ minutes
|
||||
const MAX_PIXELS_PER_SECOND: f32 = 500.0;
|
||||
const EDGE_DETECTION_PIXELS: f32 = 8.0; // Distance from edge to detect trim handles
|
||||
const LOOP_CORNER_SIZE: f32 = 12.0; // Size of loop corner hotzone at top-right of clip
|
||||
const MIN_CLIP_WIDTH_PX: f32 = 8.0; // Minimum visible width for very short clips (e.g. groups)
|
||||
|
||||
/// Calculate vertical bounds for a clip instance within a layer row.
|
||||
/// For vector layers with multiple clip instances, stacks them vertically.
|
||||
/// Returns (y_min, y_max) relative to the layer top.
|
||||
fn clip_instance_y_bounds(
|
||||
layer: &AnyLayer,
|
||||
clip_index: usize,
|
||||
clip_count: usize,
|
||||
) -> (f32, f32) {
|
||||
if matches!(layer, AnyLayer::Vector(_)) && clip_count > 1 {
|
||||
let usable_height = LAYER_HEIGHT - 20.0; // 10px padding top/bottom
|
||||
let row_height = (usable_height / clip_count as f32).min(20.0);
|
||||
let top = 10.0 + clip_index as f32 * row_height;
|
||||
(top, top + row_height - 1.0)
|
||||
} else {
|
||||
(10.0, LAYER_HEIGHT - 10.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the effective clip duration for a clip instance on a given layer.
|
||||
/// For groups on vector layers, the duration spans all consecutive keyframes
|
||||
/// where the group is present. For regular clips, returns the clip's internal duration.
|
||||
fn effective_clip_duration(
|
||||
document: &lightningbeam_core::document::Document,
|
||||
layer: &AnyLayer,
|
||||
clip_instance: &ClipInstance,
|
||||
) -> Option<f64> {
|
||||
match layer {
|
||||
AnyLayer::Vector(vl) => {
|
||||
let vc = document.get_vector_clip(&clip_instance.clip_id)?;
|
||||
if vc.is_group {
|
||||
let frame_duration = 1.0 / document.framerate;
|
||||
let end = vl.group_visibility_end(&clip_instance.id, clip_instance.timeline_start, frame_duration);
|
||||
Some((end - clip_instance.timeline_start).max(0.0))
|
||||
} else {
|
||||
Some(vc.duration)
|
||||
}
|
||||
}
|
||||
AnyLayer::Audio(_) => document.get_audio_clip(&clip_instance.clip_id).map(|c| c.duration),
|
||||
AnyLayer::Video(_) => document.get_video_clip(&clip_instance.clip_id).map(|c| c.duration),
|
||||
AnyLayer::Effect(_) => Some(lightningbeam_core::effect::EFFECT_DURATION),
|
||||
}
|
||||
}
|
||||
|
||||
/// Type of clip drag operation
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
@@ -304,7 +348,6 @@ impl TimelinePane {
|
||||
return None;
|
||||
}
|
||||
|
||||
let hover_time = self.x_to_time(pointer_pos.x - content_rect.min.x);
|
||||
let relative_y = pointer_pos.y - header_rect.min.y + self.viewport_scroll_y;
|
||||
let hovered_layer_index = (relative_y / LAYER_HEIGHT) as usize;
|
||||
|
||||
@@ -324,34 +367,29 @@ impl TimelinePane {
|
||||
};
|
||||
|
||||
// Check each clip instance
|
||||
for clip_instance in clip_instances {
|
||||
let clip_duration = match layer {
|
||||
lightningbeam_core::layer::AnyLayer::Vector(_) => {
|
||||
document.get_vector_clip(&clip_instance.clip_id).map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Audio(_) => {
|
||||
document.get_audio_clip(&clip_instance.clip_id).map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Video(_) => {
|
||||
document.get_video_clip(&clip_instance.clip_id).map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Effect(_) => {
|
||||
Some(lightningbeam_core::effect::EFFECT_DURATION)
|
||||
}
|
||||
}?;
|
||||
let clip_count = clip_instances.len();
|
||||
for (ci_idx, clip_instance) in clip_instances.iter().enumerate() {
|
||||
let clip_duration = effective_clip_duration(document, layer, clip_instance)?;
|
||||
|
||||
let instance_start = clip_instance.effective_start();
|
||||
let instance_duration = clip_instance.total_duration(clip_duration);
|
||||
let instance_end = instance_start + instance_duration;
|
||||
|
||||
if hover_time >= instance_start && hover_time <= instance_end {
|
||||
let start_x = self.time_to_x(instance_start);
|
||||
let end_x = self.time_to_x(instance_end);
|
||||
let mouse_x = pointer_pos.x - content_rect.min.x;
|
||||
let start_x = self.time_to_x(instance_start);
|
||||
let end_x = self.time_to_x(instance_end).max(start_x + MIN_CLIP_WIDTH_PX);
|
||||
let mouse_x = pointer_pos.x - content_rect.min.x;
|
||||
|
||||
if mouse_x >= start_x && mouse_x <= end_x {
|
||||
// Check vertical bounds for stacked vector layer clips
|
||||
let layer_top = header_rect.min.y + (hovered_layer_index as f32 * LAYER_HEIGHT) - self.viewport_scroll_y;
|
||||
let (cy_min, cy_max) = clip_instance_y_bounds(layer, ci_idx, clip_count);
|
||||
let mouse_rel_y = pointer_pos.y - layer_top;
|
||||
if mouse_rel_y < cy_min || mouse_rel_y > cy_max {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Determine drag type based on edge proximity (check both sides of edge)
|
||||
let is_audio_layer = matches!(layer, lightningbeam_core::layer::AnyLayer::Audio(_));
|
||||
let layer_top = header_rect.min.y + (hovered_layer_index as f32 * LAYER_HEIGHT) - self.viewport_scroll_y;
|
||||
let mouse_in_top_corner = pointer_pos.y < layer_top + LOOP_CORNER_SIZE;
|
||||
|
||||
let is_looping = clip_instance.timeline_duration.is_some() || clip_instance.loop_before.is_some();
|
||||
@@ -1047,25 +1085,10 @@ impl TimelinePane {
|
||||
None
|
||||
};
|
||||
|
||||
for clip_instance in clip_instances {
|
||||
let clip_instance_count = clip_instances.len();
|
||||
for (clip_instance_index, clip_instance) in clip_instances.iter().enumerate() {
|
||||
// Get the clip to determine duration
|
||||
let clip_duration = match layer {
|
||||
lightningbeam_core::layer::AnyLayer::Vector(_) => {
|
||||
document.get_vector_clip(&clip_instance.clip_id)
|
||||
.map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Audio(_) => {
|
||||
document.get_audio_clip(&clip_instance.clip_id)
|
||||
.map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Video(_) => {
|
||||
document.get_video_clip(&clip_instance.clip_id)
|
||||
.map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Effect(_) => {
|
||||
Some(lightningbeam_core::effect::EFFECT_DURATION)
|
||||
}
|
||||
};
|
||||
let clip_duration = effective_clip_duration(document, layer, clip_instance);
|
||||
|
||||
if let Some(clip_duration) = clip_duration {
|
||||
// Calculate effective duration accounting for trimming
|
||||
@@ -1245,7 +1268,7 @@ impl TimelinePane {
|
||||
let instance_end = instance_start + instance_duration;
|
||||
|
||||
let start_x = self.time_to_x(instance_start);
|
||||
let end_x = self.time_to_x(instance_end);
|
||||
let end_x = self.time_to_x(instance_end).max(start_x + MIN_CLIP_WIDTH_PX);
|
||||
|
||||
// Only draw if any part is visible in viewport
|
||||
if end_x >= 0.0 && start_x <= rect.width() {
|
||||
@@ -1280,9 +1303,11 @@ impl TimelinePane {
|
||||
),
|
||||
};
|
||||
|
||||
let (cy_min, cy_max) = clip_instance_y_bounds(layer, clip_instance_index, clip_instance_count);
|
||||
|
||||
let clip_rect = egui::Rect::from_min_max(
|
||||
egui::pos2(rect.min.x + visible_start_x, y + 10.0),
|
||||
egui::pos2(rect.min.x + visible_end_x, y + LAYER_HEIGHT - 10.0),
|
||||
egui::pos2(rect.min.x + visible_start_x, y + cy_min),
|
||||
egui::pos2(rect.min.x + visible_end_x, y + cy_max),
|
||||
);
|
||||
|
||||
// Draw the clip instance background(s)
|
||||
@@ -1639,6 +1664,31 @@ impl TimelinePane {
|
||||
}
|
||||
}
|
||||
|
||||
// Draw shape keyframe markers for vector layers
|
||||
if let lightningbeam_core::layer::AnyLayer::Vector(vl) = layer {
|
||||
for kf in &vl.keyframes {
|
||||
let x = self.time_to_x(kf.time);
|
||||
if x >= 0.0 && x <= rect.width() {
|
||||
let cx = rect.min.x + x;
|
||||
let cy = y + LAYER_HEIGHT - 8.0;
|
||||
let size = 5.0;
|
||||
// Draw diamond shape
|
||||
let diamond = [
|
||||
egui::pos2(cx, cy - size),
|
||||
egui::pos2(cx + size, cy),
|
||||
egui::pos2(cx, cy + size),
|
||||
egui::pos2(cx - size, cy),
|
||||
];
|
||||
let color = egui::Color32::from_rgb(255, 220, 100);
|
||||
painter.add(egui::Shape::convex_polygon(
|
||||
diamond.to_vec(),
|
||||
color,
|
||||
egui::Stroke::new(1.0, egui::Color32::from_rgb(180, 150, 50)),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Separator line at bottom
|
||||
painter.line_segment(
|
||||
[
|
||||
@@ -1709,8 +1759,6 @@ impl TimelinePane {
|
||||
if pos.y >= header_rect.min.y && pos.x >= content_rect.min.x {
|
||||
let relative_y = pos.y - header_rect.min.y + self.viewport_scroll_y;
|
||||
let clicked_layer_index = (relative_y / LAYER_HEIGHT) as usize;
|
||||
let click_time = self.x_to_time(pos.x - content_rect.min.x);
|
||||
|
||||
// Get the layer at this index (accounting for reversed display order)
|
||||
if clicked_layer_index < layer_count {
|
||||
let layers: Vec<_> = document.root.children.iter().rev().collect();
|
||||
@@ -1726,33 +1774,25 @@ impl TimelinePane {
|
||||
};
|
||||
|
||||
// Check if click is within any clip instance
|
||||
for clip_instance in clip_instances {
|
||||
// Get the clip to determine duration
|
||||
let clip_duration = match layer {
|
||||
lightningbeam_core::layer::AnyLayer::Vector(_) => {
|
||||
document.get_vector_clip(&clip_instance.clip_id)
|
||||
.map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Audio(_) => {
|
||||
document.get_audio_clip(&clip_instance.clip_id)
|
||||
.map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Video(_) => {
|
||||
document.get_video_clip(&clip_instance.clip_id)
|
||||
.map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Effect(_) => {
|
||||
Some(lightningbeam_core::effect::EFFECT_DURATION)
|
||||
}
|
||||
};
|
||||
let click_clip_count = clip_instances.len();
|
||||
let click_layer_top = pos.y - (relative_y % LAYER_HEIGHT);
|
||||
for (ci_idx, clip_instance) in clip_instances.iter().enumerate() {
|
||||
let clip_duration = effective_clip_duration(document, layer, clip_instance);
|
||||
|
||||
if let Some(clip_duration) = clip_duration {
|
||||
let instance_duration = clip_instance.total_duration(clip_duration);
|
||||
let instance_start = clip_instance.effective_start();
|
||||
let instance_end = instance_start + instance_duration;
|
||||
|
||||
// Check if click is within this clip instance's time range
|
||||
if click_time >= instance_start && click_time <= instance_end {
|
||||
// Check if click is within this clip instance's pixel range and vertical bounds
|
||||
let ci_start_x = self.time_to_x(instance_start);
|
||||
let ci_end_x = self.time_to_x(instance_end).max(ci_start_x + MIN_CLIP_WIDTH_PX);
|
||||
let click_x = pos.x - content_rect.min.x;
|
||||
let (cy_min, cy_max) = clip_instance_y_bounds(layer, ci_idx, click_clip_count);
|
||||
let click_rel_y = pos.y - click_layer_top;
|
||||
if click_x >= ci_start_x && click_x <= ci_end_x
|
||||
&& click_rel_y >= cy_min && click_rel_y <= cy_max
|
||||
{
|
||||
// Found a clicked clip instance!
|
||||
if shift_held {
|
||||
// Shift+click: add to selection
|
||||
@@ -1919,27 +1959,7 @@ impl TimelinePane {
|
||||
// Find selected clip instances in this layer
|
||||
for clip_instance in clip_instances {
|
||||
if selection.contains_clip_instance(&clip_instance.id) {
|
||||
// Get clip duration to validate trim bounds
|
||||
let clip_duration = match layer {
|
||||
lightningbeam_core::layer::AnyLayer::Vector(_) => {
|
||||
document
|
||||
.get_vector_clip(&clip_instance.clip_id)
|
||||
.map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Audio(_) => {
|
||||
document
|
||||
.get_audio_clip(&clip_instance.clip_id)
|
||||
.map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Video(_) => {
|
||||
document
|
||||
.get_video_clip(&clip_instance.clip_id)
|
||||
.map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Effect(_) => {
|
||||
Some(lightningbeam_core::effect::EFFECT_DURATION)
|
||||
}
|
||||
};
|
||||
let clip_duration = effective_clip_duration(document, layer, clip_instance);
|
||||
|
||||
if let Some(clip_duration) = clip_duration {
|
||||
match drag_type {
|
||||
@@ -2528,24 +2548,7 @@ impl PaneRenderer for TimelinePane {
|
||||
};
|
||||
|
||||
for clip_instance in clip_instances {
|
||||
// Get clip duration
|
||||
let clip_duration = match layer {
|
||||
lightningbeam_core::layer::AnyLayer::Vector(_) => {
|
||||
document.get_vector_clip(&clip_instance.clip_id)
|
||||
.map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Audio(_) => {
|
||||
document.get_audio_clip(&clip_instance.clip_id)
|
||||
.map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Video(_) => {
|
||||
document.get_video_clip(&clip_instance.clip_id)
|
||||
.map(|c| c.duration)
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Effect(_) => {
|
||||
Some(lightningbeam_core::effect::EFFECT_DURATION)
|
||||
}
|
||||
};
|
||||
let clip_duration = effective_clip_duration(document, layer, clip_instance);
|
||||
|
||||
if let Some(clip_duration) = clip_duration {
|
||||
let instance_duration = clip_instance.effective_duration(clip_duration);
|
||||
|
||||
Reference in New Issue
Block a user