static bool ValidateItemDrag(ItemsPerTrack itemsGroup)
        {
            //TODO-marker: this is to prevent the drag operation from being canceled when moving only markers
            if (itemsGroup.clips.Any())
            {
                if (itemsGroup.targetTrack == null)
                {
                    return(false);
                }

                if (itemsGroup.targetTrack.lockedInHierarchy)
                {
                    return(false);
                }

                if (itemsGroup.items.Any(i => !i.IsCompatibleWithTrack(itemsGroup.targetTrack)))
                {
                    return(false);
                }

                return(EditMode.ValidateDrag(itemsGroup));
            }

            return(true);
        }
Beispiel #2
0
        internal static ItemsPerTrack DuplicateItems(ItemsPerTrack items, TrackAsset target, WindowState state, string undoOperation)
        {
            var duplicatedItems = new List <ITimelineItem>();

            PlayableDirector director = null;

            if (state != null)
            {
                director = state.editSequence.director;
            }

            var clips = items.clips.ToList();

            if (clips.Any())
            {
                TimelineUndo.PushUndo(target, undoOperation);
                duplicatedItems.AddRange(DuplicateClips(clips, director, target).ToItems());
                TimelineUndo.PushUndo(target, undoOperation); // second undo causes reference fixups on redo (case 1063868)
            }

            var markers = items.markers.ToList();

            if (markers.Any())
            {
                duplicatedItems.AddRange(MarkerModifier.CloneMarkersToParent(markers, target).ToItems());
            }

            return(new ItemsPerTrack(target, duplicatedItems.ToArray()));
        }
Beispiel #3
0
        static TrackAsset FindSuitableParentForSingleTrackPasteWithoutMouse(ItemsPerTrack itemsGroup)
        {
            var groupParent    = itemsGroup.targetTrack; //set a main parent in the clipboard
            var selectedTracks = SelectionManager.SelectedTracks();

            if (selectedTracks.Contains(groupParent))
            {
                return(groupParent);
            }

            //find a selected track suitable for all items
            var itemsToPaste    = itemsGroup.items;
            var compatibleTrack = selectedTracks.FirstOrDefault(t => IsTrackValidForItems(t, itemsToPaste));

            return(compatibleTrack != null ? compatibleTrack : groupParent);
        }
Beispiel #4
0
        static TrackAsset FindSuitableParentForSingleTrackPasteWithoutMouse(ItemsPerTrack itemsGroup)
        {
            var groupParent    = itemsGroup.targetTrack; //set a main parent in the clipboard
            var selectedTracks = SelectionManager.SelectedTracks();

            if (selectedTracks.Contains(groupParent))
            {
                return(groupParent);
            }

            //find a selected track suitable for all items
            var itemsToPaste    = itemsGroup.items;
            var compatibleTrack = selectedTracks.Where(t => !t.lockedInHierarchy).FirstOrDefault(t => itemsToPaste.All(i => i.IsCompatibleWithTrack(t)));

            return(compatibleTrack != null ? compatibleTrack : groupParent);
        }
        public double AdjustStartTime(WindowState state, ItemsPerTrack itemsGroup, double time)
        {
            var track = itemsGroup.targetTrack;

            if (track == null)
            {
                return(time);
            }

            double start;
            double end;

            if (EditModeUtils.IsInfiniteTrack(track))
            {
                EditModeUtils.GetInfiniteClipBoundaries(track, out start, out end);
            }
            else
            {
                var siblings             = ItemsUtils.GetItemsExcept(track, itemsGroup.items);
                var firstIntersectedItem = EditModeUtils.GetFirstIntersectedItem(siblings, time);

                if (firstIntersectedItem == null)
                {
                    return(time);
                }

                start = firstIntersectedItem.start;
                end   = firstIntersectedItem.end;
            }

            var closestTime = Math.Abs(time - start) < Math.Abs(time - end) ? start : end;

            var pixelTime        = state.TimeToPixel(time);
            var pixelClosestTime = state.TimeToPixel(closestTime);

            if (Math.Abs(pixelTime - pixelClosestTime) < k_SnapToEdgeDistance)
            {
                return(closestTime);
            }

            return(time);
        }
Beispiel #6
0
        public bool ValidateMove(ItemsPerTrack itemsGroup)
        {
            var track = itemsGroup.targetTrack;
            var items = itemsGroup.items;

            if (EditModeUtils.IsInfiniteTrack(track))
            {
                double startTime;
                double stopTime;
                EditModeUtils.GetInfiniteClipBoundaries(track, out startTime, out stopTime);

                return(items.All(item =>
                                 !EditModeUtils.IsItemWithinRange(item, startTime, stopTime) &&
                                 !EditModeUtils.IsRangeWithinItem(startTime, stopTime, item)));
            }

            var siblings = ItemsUtils.GetItemsExcept(itemsGroup.targetTrack, items);

            return(items.All(item => EditModeMixUtils.GetPlacementValidity(item, siblings) == PlacementValidity.Valid));
        }
Beispiel #7
0
        internal static ItemsPerTrack DuplicateItems(ItemsPerTrack items, TrackAsset target, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, string undoOperation)
        {
            var duplicatedItems = new List <ITimelineItem>();
            var clips           = items.clips.ToList();

            if (clips.Any())
            {
                TimelineUndo.PushUndo(target, undoOperation);
                duplicatedItems.AddRange(DuplicateClips(clips, sourceTable, destTable, target).ToItems());
                TimelineUndo.PushUndo(target, undoOperation); // second undo causes reference fixups on redo (case 1063868)
            }

            var markers = items.markers.ToList();

            if (markers.Any())
            {
                duplicatedItems.AddRange(MarkerModifier.CloneMarkersToParent(markers, target).ToItems());
            }

            return(new ItemsPerTrack(target, duplicatedItems.ToArray()));
        }
Beispiel #8
0
        public static IEnumerable <ITimelineItem> DuplicateItemsUsingCurrentEditMode(WindowState state, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, ItemsPerTrack items, TrackAsset targetParent, double candidateTime, string undoOperation)
        {
            if (targetParent != null)
            {
                var aTrack = targetParent as AnimationTrack;
                if (aTrack != null)
                {
                    aTrack.ConvertToClipMode();
                }

                var duplicatedItems = DuplicateItems(items, targetParent, sourceTable, destTable, undoOperation);
                FinalizeInsertItemsUsingCurrentEditMode(state, new[] { duplicatedItems }, candidateTime);
                return(duplicatedItems.items);
            }

            return(Enumerable.Empty <ITimelineItem>());
        }
 public bool ValidateMove(ItemsPerTrack itemsGroup)
 {
     return(true);
 }
 public static bool ValidateDrag(ItemsPerTrack itemsGroup)
 {
     return(moveMode.ValidateMove(itemsGroup));
 }
 public static double AdjustStartTime(WindowState state, ItemsPerTrack itemsGroup, double time)
 {
     return(moveMode.AdjustStartTime(state, itemsGroup, time));
 }
 public double AdjustStartTime(WindowState state, ItemsPerTrack itemsGroup, double time)
 {
     return(time);
 }