use group layers instead of linked tracks

This commit is contained in:
Skyler Lehmkuhl
2026-03-01 09:00:55 -05:00
parent 520776c6e5
commit b87e4325c2
18 changed files with 1040 additions and 164 deletions
@@ -101,6 +101,9 @@ impl Action for AddClipInstanceAction {
AnyLayer::Effect(_) => {
return Err("Cannot add clip instances to effect layers".to_string());
}
AnyLayer::Group(_) => {
return Err("Cannot add clip instances directly to group layers".to_string());
}
}
self.executed = true;
@@ -136,6 +139,9 @@ impl Action for AddClipInstanceAction {
AnyLayer::Effect(_) => {
// Effect layers don't have clip instances, nothing to rollback
}
AnyLayer::Group(_) => {
// Group layers don't have clip instances, nothing to rollback
}
}
self.executed = false;
@@ -15,6 +15,9 @@ pub struct AddLayerAction {
/// If Some, add to this VectorClip's layers instead of root
target_clip_id: Option<Uuid>,
/// If Some, add as a child of this GroupLayer instead of root
target_group_id: Option<Uuid>,
/// ID of the created layer (set after execution)
created_layer_id: Option<Uuid>,
}
@@ -30,6 +33,7 @@ impl AddLayerAction {
Self {
layer: AnyLayer::Vector(layer),
target_clip_id: None,
target_group_id: None,
created_layer_id: None,
}
}
@@ -43,6 +47,7 @@ impl AddLayerAction {
Self {
layer,
target_clip_id: None,
target_group_id: None,
created_layer_id: None,
}
}
@@ -53,6 +58,12 @@ impl AddLayerAction {
self
}
/// Set the target group for this action (add layer inside a group layer)
pub fn with_target_group(mut self, group_id: Uuid) -> Self {
self.target_group_id = Some(group_id);
self
}
/// Get the ID of the created layer (after execution)
pub fn created_layer_id(&self) -> Option<Uuid> {
self.created_layer_id
@@ -61,7 +72,18 @@ impl AddLayerAction {
impl Action for AddLayerAction {
fn execute(&mut self, document: &mut Document) -> Result<(), String> {
let layer_id = if let Some(clip_id) = self.target_clip_id {
let layer_id = if let Some(group_id) = self.target_group_id {
// Add layer inside a group layer
let id = self.layer.id();
if let Some(AnyLayer::Group(g)) = document.root.children.iter_mut()
.find(|l| l.id() == group_id)
{
g.add_child(self.layer.clone());
} else {
return Err(format!("Target group {} not found", group_id));
}
id
} else if let Some(clip_id) = self.target_clip_id {
// Add layer inside a vector clip (movie clip)
let clip = document.vector_clips.get_mut(&clip_id)
.ok_or_else(|| format!("Target clip {} not found", clip_id))?;
@@ -84,7 +106,14 @@ impl Action for AddLayerAction {
fn rollback(&mut self, document: &mut Document) -> Result<(), String> {
// Remove the created layer if it exists
if let Some(layer_id) = self.created_layer_id {
if let Some(clip_id) = self.target_clip_id {
if let Some(group_id) = self.target_group_id {
// Remove from group layer
if let Some(AnyLayer::Group(g)) = document.root.children.iter_mut()
.find(|l| l.id() == group_id)
{
g.children.retain(|l| l.id() != layer_id);
}
} else if let Some(clip_id) = self.target_clip_id {
// Remove from vector clip
if let Some(clip) = document.vector_clips.get_mut(&clip_id) {
clip.layers.roots.retain(|node| node.data.id() != layer_id);
@@ -107,6 +136,7 @@ impl Action for AddLayerAction {
AnyLayer::Audio(_) => "Add audio layer",
AnyLayer::Video(_) => "Add video layer",
AnyLayer::Effect(_) => "Add effect layer",
AnyLayer::Group(_) => "Add group layer",
}
.to_string()
}
@@ -35,6 +35,7 @@ impl Action for LoopClipInstancesAction {
AnyLayer::Audio(al) => &mut al.clip_instances,
AnyLayer::Video(vl) => &mut vl.clip_instances,
AnyLayer::Effect(el) => &mut el.clip_instances,
AnyLayer::Group(_) => continue,
};
for (instance_id, _old_dur, new_dur, _old_lb, new_lb) in loops {
@@ -57,6 +58,7 @@ impl Action for LoopClipInstancesAction {
AnyLayer::Audio(al) => &mut al.clip_instances,
AnyLayer::Video(vl) => &mut vl.clip_instances,
AnyLayer::Effect(el) => &mut el.clip_instances,
AnyLayer::Group(_) => continue,
};
for (instance_id, old_dur, _new_dur, old_lb, _new_lb) in loops {
@@ -29,6 +29,7 @@ pub mod set_keyframe;
pub mod group_shapes;
pub mod convert_to_movie_clip;
pub mod region_split;
pub mod toggle_group_expansion;
pub use add_clip_instance::AddClipInstanceAction;
pub use add_effect::AddEffectAction;
@@ -56,3 +57,4 @@ pub use set_keyframe::SetKeyframeAction;
pub use group_shapes::GroupAction;
pub use convert_to_movie_clip::ConvertToMovieClipAction;
pub use region_split::RegionSplitAction;
pub use toggle_group_expansion::ToggleGroupExpansionAction;
@@ -56,6 +56,7 @@ impl Action for MoveClipInstancesAction {
AnyLayer::Audio(al) => &al.clip_instances,
AnyLayer::Video(vl) => &vl.clip_instances,
AnyLayer::Effect(el) => &el.clip_instances,
AnyLayer::Group(_) => &[],
};
if let Some(instance) = clip_instances.iter().find(|ci| ci.id == *member_instance_id) {
@@ -93,6 +94,7 @@ impl Action for MoveClipInstancesAction {
AnyLayer::Video(vl) => &vl.clip_instances,
AnyLayer::Vector(vl) => &vl.clip_instances,
AnyLayer::Effect(el) => &el.clip_instances,
AnyLayer::Group(_) => &[],
};
let group: Vec<(Uuid, f64, f64)> = moves.iter().filter_map(|(id, old_start, _)| {
@@ -126,6 +128,7 @@ impl Action for MoveClipInstancesAction {
AnyLayer::Audio(al) => &mut al.clip_instances,
AnyLayer::Video(vl) => &mut vl.clip_instances,
AnyLayer::Effect(el) => &mut el.clip_instances,
AnyLayer::Group(_) => continue,
};
// Update timeline_start for each clip instance
@@ -151,6 +154,7 @@ impl Action for MoveClipInstancesAction {
AnyLayer::Audio(al) => &mut al.clip_instances,
AnyLayer::Video(vl) => &mut vl.clip_instances,
AnyLayer::Effect(el) => &mut el.clip_instances,
AnyLayer::Group(_) => continue,
};
// Restore original timeline_start for each clip instance
@@ -44,6 +44,7 @@ impl Action for RemoveClipInstancesAction {
AnyLayer::Audio(al) => &mut al.clip_instances,
AnyLayer::Video(vl) => &mut vl.clip_instances,
AnyLayer::Effect(el) => &mut el.clip_instances,
AnyLayer::Group(_) => continue,
};
// Find and remove the instance, saving it for rollback
@@ -68,6 +69,7 @@ impl Action for RemoveClipInstancesAction {
AnyLayer::Audio(al) => &mut al.clip_instances,
AnyLayer::Video(vl) => &mut vl.clip_instances,
AnyLayer::Effect(el) => &mut el.clip_instances,
AnyLayer::Group(_) => continue,
};
clip_instances.push(instance);
@@ -112,6 +112,7 @@ impl Action for SplitClipInstanceAction {
AnyLayer::Audio(al) => &al.clip_instances,
AnyLayer::Video(vl) => &vl.clip_instances,
AnyLayer::Effect(el) => &el.clip_instances,
AnyLayer::Group(_) => return Err("Cannot split clip instances on group layers".to_string()),
};
let instance = clip_instances
@@ -228,6 +229,9 @@ impl Action for SplitClipInstanceAction {
}
el.clip_instances.push(right_instance);
}
AnyLayer::Group(_) => {
return Err("Cannot split clip instances on group layers".to_string());
}
}
self.executed = true;
@@ -283,6 +287,9 @@ impl Action for SplitClipInstanceAction {
inst.timeline_duration = self.original_timeline_duration;
}
}
AnyLayer::Group(_) => {
// Group layers don't have clip instances, nothing to rollback
}
}
self.executed = false;
@@ -0,0 +1,62 @@
//! Toggle group layer expansion state (collapsed/expanded in timeline)
use crate::action::Action;
use crate::document::Document;
use crate::layer::AnyLayer;
use uuid::Uuid;
/// Action that toggles a group layer's expanded/collapsed state
pub struct ToggleGroupExpansionAction {
group_id: Uuid,
new_expanded: bool,
old_expanded: Option<bool>,
}
impl ToggleGroupExpansionAction {
pub fn new(group_id: Uuid, expanded: bool) -> Self {
Self {
group_id,
new_expanded: expanded,
old_expanded: None,
}
}
}
impl Action for ToggleGroupExpansionAction {
fn execute(&mut self, document: &mut Document) -> Result<(), String> {
if let Some(AnyLayer::Group(g)) = document
.root
.children
.iter_mut()
.find(|l| l.id() == self.group_id)
{
self.old_expanded = Some(g.expanded);
g.expanded = self.new_expanded;
Ok(())
} else {
Err(format!("Group layer {} not found", self.group_id))
}
}
fn rollback(&mut self, document: &mut Document) -> Result<(), String> {
if let Some(old) = self.old_expanded {
if let Some(AnyLayer::Group(g)) = document
.root
.children
.iter_mut()
.find(|l| l.id() == self.group_id)
{
g.expanded = old;
}
}
Ok(())
}
fn description(&self) -> String {
if self.new_expanded {
"Expand group".to_string()
} else {
"Collapse group".to_string()
}
}
}
@@ -99,6 +99,7 @@ impl Action for TransformClipInstancesAction {
}
}
AnyLayer::Effect(_) => {}
AnyLayer::Group(_) => {}
}
Ok(())
}
@@ -136,6 +137,7 @@ impl Action for TransformClipInstancesAction {
}
}
AnyLayer::Effect(_) => {}
AnyLayer::Group(_) => {}
}
Ok(())
}
@@ -99,6 +99,7 @@ impl Action for TrimClipInstancesAction {
AnyLayer::Audio(al) => &al.clip_instances,
AnyLayer::Video(vl) => &vl.clip_instances,
AnyLayer::Effect(el) => &el.clip_instances,
AnyLayer::Group(_) => &[],
};
if let Some(instance) = clip_instances.iter().find(|ci| ci.id == *member_instance_id) {
@@ -134,6 +135,7 @@ impl Action for TrimClipInstancesAction {
AnyLayer::Audio(al) => &al.clip_instances,
AnyLayer::Video(vl) => &vl.clip_instances,
AnyLayer::Effect(el) => &el.clip_instances,
AnyLayer::Group(_) => &[],
};
if let Some(instance) = clip_instances.iter().find(|ci| ci.id == *member_instance_id) {
@@ -176,6 +178,7 @@ impl Action for TrimClipInstancesAction {
AnyLayer::Video(vl) => &vl.clip_instances,
AnyLayer::Vector(vl) => &vl.clip_instances,
AnyLayer::Effect(el) => &el.clip_instances,
AnyLayer::Group(_) => &[],
};
let instance = clip_instances.iter()
@@ -267,6 +270,7 @@ impl Action for TrimClipInstancesAction {
AnyLayer::Audio(al) => &mut al.clip_instances,
AnyLayer::Video(vl) => &mut vl.clip_instances,
AnyLayer::Effect(el) => &mut el.clip_instances,
AnyLayer::Group(_) => continue,
};
// Apply trims
@@ -305,6 +309,7 @@ impl Action for TrimClipInstancesAction {
AnyLayer::Audio(al) => &mut al.clip_instances,
AnyLayer::Video(vl) => &mut vl.clip_instances,
AnyLayer::Effect(el) => &mut el.clip_instances,
AnyLayer::Group(_) => continue,
};
// Restore original trim values
@@ -115,6 +115,7 @@ impl VectorClip {
AnyLayer::Audio(al) => &al.clip_instances,
AnyLayer::Video(vl) => &vl.clip_instances,
AnyLayer::Effect(el) => &el.clip_instances,
AnyLayer::Group(_) => &[],
};
for ci in clip_instances {
let end = if let Some(td) = ci.timeline_duration {
@@ -31,6 +31,7 @@ impl ClipboardLayerType {
AudioLayerType::Midi => ClipboardLayerType::AudioMidi,
},
AnyLayer::Effect(_) => ClipboardLayerType::Effect,
AnyLayer::Group(_) => ClipboardLayerType::Vector, // Groups don't have a direct clipboard type; treat as vector
}
}
@@ -44,14 +44,62 @@ impl GraphicsObject {
id
}
/// Get a child layer by ID
/// Get a child layer by ID (searches direct children and recurses into groups)
pub fn get_child(&self, id: &Uuid) -> Option<&AnyLayer> {
self.children.iter().find(|l| &l.id() == id)
for layer in &self.children {
if &layer.id() == id {
return Some(layer);
}
if let AnyLayer::Group(group) = layer {
if let Some(found) = Self::find_in_group(&group.children, id) {
return Some(found);
}
}
}
None
}
/// Get a mutable child layer by ID
/// Get a mutable child layer by ID (searches direct children and recurses into groups)
pub fn get_child_mut(&mut self, id: &Uuid) -> Option<&mut AnyLayer> {
self.children.iter_mut().find(|l| &l.id() == id)
for layer in &mut self.children {
if &layer.id() == id {
return Some(layer);
}
if let AnyLayer::Group(group) = layer {
if let Some(found) = Self::find_in_group_mut(&mut group.children, id) {
return Some(found);
}
}
}
None
}
fn find_in_group<'a>(children: &'a [AnyLayer], id: &Uuid) -> Option<&'a AnyLayer> {
for child in children {
if &child.id() == id {
return Some(child);
}
if let AnyLayer::Group(group) = child {
if let Some(found) = Self::find_in_group(&group.children, id) {
return Some(found);
}
}
}
None
}
fn find_in_group_mut<'a>(children: &'a mut [AnyLayer], id: &Uuid) -> Option<&'a mut AnyLayer> {
for child in children {
if &child.id() == id {
return Some(child);
}
if let AnyLayer::Group(group) = child {
if let Some(found) = Self::find_in_group_mut(&mut group.children, id) {
return Some(found);
}
}
}
None
}
/// Remove a child layer by ID
@@ -371,6 +419,52 @@ impl Document {
}
}
}
crate::layer::AnyLayer::Group(group) => {
// Recurse into group children to find their clip instance endpoints
fn process_group_children(
children: &[crate::layer::AnyLayer],
doc: &Document,
max_end: &mut f64,
calc_end: &dyn Fn(&ClipInstance, f64) -> f64,
) {
for child in children {
match child {
crate::layer::AnyLayer::Vector(vl) => {
for inst in &vl.clip_instances {
if let Some(clip) = doc.vector_clips.get(&inst.clip_id) {
*max_end = max_end.max(calc_end(inst, clip.duration));
}
}
}
crate::layer::AnyLayer::Audio(al) => {
for inst in &al.clip_instances {
if let Some(clip) = doc.audio_clips.get(&inst.clip_id) {
*max_end = max_end.max(calc_end(inst, clip.duration));
}
}
}
crate::layer::AnyLayer::Video(vl) => {
for inst in &vl.clip_instances {
if let Some(clip) = doc.video_clips.get(&inst.clip_id) {
*max_end = max_end.max(calc_end(inst, clip.duration));
}
}
}
crate::layer::AnyLayer::Effect(el) => {
for inst in &el.clip_instances {
if let Some(dur) = doc.get_clip_duration(&inst.clip_id) {
*max_end = max_end.max(calc_end(inst, dur));
}
}
}
crate::layer::AnyLayer::Group(g) => {
process_group_children(&g.children, doc, max_end, calc_end);
}
}
}
}
process_group_children(&group.children, self, &mut max_end_time, &calculate_instance_end);
}
}
}
@@ -489,7 +583,16 @@ impl Document {
/// Get all layers across the entire document (root + inside all vector clips).
pub fn all_layers(&self) -> Vec<&AnyLayer> {
let mut layers: Vec<&AnyLayer> = self.root.children.iter().collect();
let mut layers: Vec<&AnyLayer> = Vec::new();
fn collect_layers<'a>(list: &'a [AnyLayer], out: &mut Vec<&'a AnyLayer>) {
for layer in list {
out.push(layer);
if let AnyLayer::Group(g) = layer {
collect_layers(&g.children, out);
}
}
}
collect_layers(&self.root.children, &mut layers);
for clip in self.vector_clips.values() {
layers.extend(clip.layers.root_data());
}
@@ -718,6 +821,7 @@ impl Document {
AnyLayer::Video(video) => &video.clip_instances,
AnyLayer::Vector(vector) => &vector.clip_instances,
AnyLayer::Effect(effect) => &effect.clip_instances,
AnyLayer::Group(_) => &[],
};
let instance = instances.iter().find(|inst| &inst.id == instance_id)?;
@@ -756,6 +860,7 @@ impl Document {
AnyLayer::Video(video) => &video.clip_instances,
AnyLayer::Vector(vector) => &vector.clip_instances,
AnyLayer::Effect(effect) => &effect.clip_instances,
AnyLayer::Group(_) => &[],
};
for instance in instances {
@@ -799,7 +904,7 @@ impl Document {
let desired_start = desired_start.max(0.0);
// Vector layers don't need overlap adjustment, but still respect timeline start
if matches!(layer, AnyLayer::Vector(_)) {
if matches!(layer, AnyLayer::Vector(_) | AnyLayer::Group(_)) {
return Some(desired_start);
}
@@ -816,6 +921,7 @@ impl Document {
AnyLayer::Video(video) => &video.clip_instances,
AnyLayer::Effect(effect) => &effect.clip_instances,
AnyLayer::Vector(_) => return Some(desired_start), // Shouldn't reach here
AnyLayer::Group(_) => return Some(desired_start), // Groups don't have own clips
};
let mut occupied_ranges: Vec<(f64, f64, Uuid)> = Vec::new();
@@ -898,7 +1004,7 @@ impl Document {
let Some(layer) = self.get_layer(layer_id) else {
return desired_offset;
};
if matches!(layer, AnyLayer::Vector(_)) {
if matches!(layer, AnyLayer::Vector(_) | AnyLayer::Group(_)) {
return desired_offset;
}
@@ -909,6 +1015,7 @@ impl Document {
AnyLayer::Video(v) => &v.clip_instances,
AnyLayer::Effect(e) => &e.clip_instances,
AnyLayer::Vector(v) => &v.clip_instances,
AnyLayer::Group(_) => &[],
};
// Collect non-group clip ranges
@@ -966,8 +1073,8 @@ impl Document {
};
// Only check audio, video, and effect layers
if matches!(layer, AnyLayer::Vector(_)) {
return current_timeline_start; // No limit for vector layers
if matches!(layer, AnyLayer::Vector(_) | AnyLayer::Group(_)) {
return current_timeline_start; // No limit for vector/group layers
};
// Find the nearest clip to the left
@@ -978,6 +1085,7 @@ impl Document {
AnyLayer::Video(video) => &video.clip_instances,
AnyLayer::Effect(effect) => &effect.clip_instances,
AnyLayer::Vector(vector) => &vector.clip_instances,
AnyLayer::Group(_) => &[],
};
for other in instances {
@@ -1015,8 +1123,8 @@ impl Document {
};
// Only check audio, video, and effect layers
if matches!(layer, AnyLayer::Vector(_)) {
return f64::MAX; // No limit for vector layers
if matches!(layer, AnyLayer::Vector(_) | AnyLayer::Group(_)) {
return f64::MAX; // No limit for vector/group layers
}
let instances: &[ClipInstance] = match layer {
@@ -1024,6 +1132,7 @@ impl Document {
AnyLayer::Video(video) => &video.clip_instances,
AnyLayer::Effect(effect) => &effect.clip_instances,
AnyLayer::Vector(vector) => &vector.clip_instances,
AnyLayer::Group(_) => &[],
};
let mut nearest_start = f64::MAX;
@@ -1060,7 +1169,7 @@ impl Document {
return current_effective_start;
};
if matches!(layer, AnyLayer::Vector(_)) {
if matches!(layer, AnyLayer::Vector(_) | AnyLayer::Group(_)) {
return current_effective_start;
}
@@ -1069,6 +1178,7 @@ impl Document {
AnyLayer::Video(video) => &video.clip_instances,
AnyLayer::Effect(effect) => &effect.clip_instances,
AnyLayer::Vector(vector) => &vector.clip_instances,
AnyLayer::Group(_) => &[],
};
let mut nearest_end = 0.0;
@@ -25,6 +25,8 @@ pub enum LayerType {
Automation,
/// Visual effects layer
Effect,
/// Group layer containing child layers (e.g. video + audio)
Group,
}
/// Common trait for all layer types
@@ -694,6 +696,80 @@ impl VideoLayer {
}
}
/// Group layer containing child layers (e.g. video + audio).
/// Collapsible in the timeline; when collapsed shows a merged clip view.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GroupLayer {
/// Base layer properties
pub layer: Layer,
/// Child layers in this group (typically one VideoLayer + one AudioLayer)
pub children: Vec<AnyLayer>,
/// Whether the group is expanded in the timeline
#[serde(default = "default_true")]
pub expanded: bool,
}
fn default_true() -> bool {
true
}
impl LayerTrait for GroupLayer {
fn id(&self) -> Uuid { self.layer.id }
fn name(&self) -> &str { &self.layer.name }
fn set_name(&mut self, name: String) { self.layer.name = name; }
fn has_custom_name(&self) -> bool { self.layer.has_custom_name }
fn set_has_custom_name(&mut self, custom: bool) { self.layer.has_custom_name = custom; }
fn visible(&self) -> bool { self.layer.visible }
fn set_visible(&mut self, visible: bool) { self.layer.visible = visible; }
fn opacity(&self) -> f64 { self.layer.opacity }
fn set_opacity(&mut self, opacity: f64) { self.layer.opacity = opacity; }
fn volume(&self) -> f64 { self.layer.volume }
fn set_volume(&mut self, volume: f64) { self.layer.volume = volume; }
fn muted(&self) -> bool { self.layer.muted }
fn set_muted(&mut self, muted: bool) { self.layer.muted = muted; }
fn soloed(&self) -> bool { self.layer.soloed }
fn set_soloed(&mut self, soloed: bool) { self.layer.soloed = soloed; }
fn locked(&self) -> bool { self.layer.locked }
fn set_locked(&mut self, locked: bool) { self.layer.locked = locked; }
}
impl GroupLayer {
/// Create a new group layer
pub fn new(name: impl Into<String>) -> Self {
Self {
layer: Layer::new(LayerType::Group, name),
children: Vec::new(),
expanded: true,
}
}
/// Add a child layer to this group
pub fn add_child(&mut self, layer: AnyLayer) {
self.children.push(layer);
}
/// Get clip instances from all child layers as (child_layer_id, &ClipInstance) pairs
pub fn all_child_clip_instances(&self) -> Vec<(Uuid, &ClipInstance)> {
let mut result = Vec::new();
for child in &self.children {
let child_id = child.id();
let instances: &[ClipInstance] = match child {
AnyLayer::Audio(l) => &l.clip_instances,
AnyLayer::Video(l) => &l.clip_instances,
AnyLayer::Vector(l) => &l.clip_instances,
AnyLayer::Effect(l) => &l.clip_instances,
AnyLayer::Group(_) => &[], // no nested groups
};
for ci in instances {
result.push((child_id, ci));
}
}
result
}
}
/// Unified layer enum for polymorphic handling
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum AnyLayer {
@@ -701,6 +777,7 @@ pub enum AnyLayer {
Audio(AudioLayer),
Video(VideoLayer),
Effect(EffectLayer),
Group(GroupLayer),
}
impl LayerTrait for AnyLayer {
@@ -710,6 +787,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.id(),
AnyLayer::Video(l) => l.id(),
AnyLayer::Effect(l) => l.id(),
AnyLayer::Group(l) => l.id(),
}
}
@@ -719,6 +797,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.name(),
AnyLayer::Video(l) => l.name(),
AnyLayer::Effect(l) => l.name(),
AnyLayer::Group(l) => l.name(),
}
}
@@ -728,6 +807,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.set_name(name),
AnyLayer::Video(l) => l.set_name(name),
AnyLayer::Effect(l) => l.set_name(name),
AnyLayer::Group(l) => l.set_name(name),
}
}
@@ -737,6 +817,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.has_custom_name(),
AnyLayer::Video(l) => l.has_custom_name(),
AnyLayer::Effect(l) => l.has_custom_name(),
AnyLayer::Group(l) => l.has_custom_name(),
}
}
@@ -746,6 +827,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.set_has_custom_name(custom),
AnyLayer::Video(l) => l.set_has_custom_name(custom),
AnyLayer::Effect(l) => l.set_has_custom_name(custom),
AnyLayer::Group(l) => l.set_has_custom_name(custom),
}
}
@@ -755,6 +837,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.visible(),
AnyLayer::Video(l) => l.visible(),
AnyLayer::Effect(l) => l.visible(),
AnyLayer::Group(l) => l.visible(),
}
}
@@ -764,6 +847,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.set_visible(visible),
AnyLayer::Video(l) => l.set_visible(visible),
AnyLayer::Effect(l) => l.set_visible(visible),
AnyLayer::Group(l) => l.set_visible(visible),
}
}
@@ -773,6 +857,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.opacity(),
AnyLayer::Video(l) => l.opacity(),
AnyLayer::Effect(l) => l.opacity(),
AnyLayer::Group(l) => l.opacity(),
}
}
@@ -782,6 +867,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.set_opacity(opacity),
AnyLayer::Video(l) => l.set_opacity(opacity),
AnyLayer::Effect(l) => l.set_opacity(opacity),
AnyLayer::Group(l) => l.set_opacity(opacity),
}
}
@@ -791,6 +877,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.volume(),
AnyLayer::Video(l) => l.volume(),
AnyLayer::Effect(l) => l.volume(),
AnyLayer::Group(l) => l.volume(),
}
}
@@ -800,6 +887,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.set_volume(volume),
AnyLayer::Video(l) => l.set_volume(volume),
AnyLayer::Effect(l) => l.set_volume(volume),
AnyLayer::Group(l) => l.set_volume(volume),
}
}
@@ -809,6 +897,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.muted(),
AnyLayer::Video(l) => l.muted(),
AnyLayer::Effect(l) => l.muted(),
AnyLayer::Group(l) => l.muted(),
}
}
@@ -818,6 +907,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.set_muted(muted),
AnyLayer::Video(l) => l.set_muted(muted),
AnyLayer::Effect(l) => l.set_muted(muted),
AnyLayer::Group(l) => l.set_muted(muted),
}
}
@@ -827,6 +917,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.soloed(),
AnyLayer::Video(l) => l.soloed(),
AnyLayer::Effect(l) => l.soloed(),
AnyLayer::Group(l) => l.soloed(),
}
}
@@ -836,6 +927,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.set_soloed(soloed),
AnyLayer::Video(l) => l.set_soloed(soloed),
AnyLayer::Effect(l) => l.set_soloed(soloed),
AnyLayer::Group(l) => l.set_soloed(soloed),
}
}
@@ -845,6 +937,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.locked(),
AnyLayer::Video(l) => l.locked(),
AnyLayer::Effect(l) => l.locked(),
AnyLayer::Group(l) => l.locked(),
}
}
@@ -854,6 +947,7 @@ impl LayerTrait for AnyLayer {
AnyLayer::Audio(l) => l.set_locked(locked),
AnyLayer::Video(l) => l.set_locked(locked),
AnyLayer::Effect(l) => l.set_locked(locked),
AnyLayer::Group(l) => l.set_locked(locked),
}
}
}
@@ -866,6 +960,7 @@ impl AnyLayer {
AnyLayer::Audio(l) => &l.layer,
AnyLayer::Video(l) => &l.layer,
AnyLayer::Effect(l) => &l.layer,
AnyLayer::Group(l) => &l.layer,
}
}
@@ -876,6 +971,7 @@ impl AnyLayer {
AnyLayer::Audio(l) => &mut l.layer,
AnyLayer::Video(l) => &mut l.layer,
AnyLayer::Effect(l) => &mut l.layer,
AnyLayer::Group(l) => &mut l.layer,
}
}
@@ -295,6 +295,17 @@ pub fn render_layer_isolated(
.collect();
return RenderedLayer::effect_layer(layer_id, opacity, active_effects);
}
AnyLayer::Group(group_layer) => {
// Render each child layer's content into the group's scene
for child in &group_layer.children {
render_layer(
document, time, child, &mut rendered.scene, base_transform,
1.0, // Full opacity - layer opacity handled in compositing
image_cache, video_manager, camera_frame,
);
}
rendered.has_content = !group_layer.children.is_empty();
}
}
rendered
@@ -434,6 +445,12 @@ fn render_layer(
AnyLayer::Effect(_) => {
// Effect layers are processed during GPU compositing, not rendered to scene
}
AnyLayer::Group(group_layer) => {
// Render each child layer in the group
for child in &group_layer.children {
render_layer(document, time, child, scene, base_transform, parent_opacity, image_cache, video_manager, camera_frame);
}
}
}
}