public static bool SelectLeftItem(bool shift = false) { if (ClipAreaActive()) { var items = SelectionManager.SelectedItems().ToList(); var clipOnly = FilterItems(ref items); var item = items.Last(); var prev = item.PreviousItem(clipOnly); if (prev != null) { if (shift) { if (SelectionManager.Contains(prev)) { SelectionManager.Remove(item); } SelectionManager.Add(prev); } else { SelectionManager.SelectOnly(prev); } TimelineHelpers.FrameItems(new[] { prev }); } else if (item != null && !shift && item.parentTrack != TimelineEditor.inspectedAsset.markerTrack) { SelectionManager.SelectOnly(item.parentTrack); } return(true); } return(false); }
public static bool SelectUpItem() { if (ClipAreaActive()) { var refItem = SelectionManager.SelectedItems().Last(); var prevTrack = refItem.parentTrack.PreviousTrack(); while (prevTrack != null) { var selectionItem = GetClosestItem(prevTrack, refItem); if (selectionItem == null) { prevTrack = prevTrack.PreviousTrack(); continue; } SelectionManager.SelectOnly(selectionItem); TimelineHelpers.FrameItems(new[] { selectionItem }); FrameTrackHeader(GetVisibleTracks().First(x => x.track == selectionItem.parentTrack)); break; } return(true); } return(false); }
public static bool SelectRightItem(bool shift = false) { if (ClipAreaActive()) { var items = SelectionManager.SelectedItems().ToList(); var clipOnly = FilterItems(ref items); var item = items.Last(); var next = item.NextItem(clipOnly); if (next != null) { if (shift) { if (SelectionManager.Contains(next)) { SelectionManager.Remove(item); } SelectionManager.Add(next); } else { SelectionManager.SelectOnly(next); } TimelineHelpers.FrameItems(new[] { next }); return(true); } } return(false); }
internal bool Execute(WindowState state, Func <ITimelineItem, ITimelineItem, double> gapBetweenItems) { var selectedItems = SelectionManager.SelectedItems().ToItemsPerTrack().ToList(); if (selectedItems.Any()) { var requestedTime = CalculateDuplicateTime(selectedItems, gapBetweenItems); var duplicatedItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(state, TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector, selectedItems, requestedTime, "Duplicate Items"); TimelineHelpers.FrameItems(state, duplicatedItems); SelectionManager.RemoveTimelineSelection(); foreach (var item in duplicatedItems) { SelectionManager.Add(item); } } var tracks = SelectionManager.SelectedTracks().ToArray(); if (tracks.Length > 0) { TrackAction.Invoke <DuplicateTracks>(state, tracks); } state.Refresh(); return(true); }
internal bool Execute(ActionContext context, Func <ITimelineItem, ITimelineItem, double> gapBetweenItems) { List <ITimelineItem> items = new List <ITimelineItem>(); items.AddRange(context.clips.Select(p => p.ToItem())); items.AddRange(context.markers.Select(p => p.ToItem())); List <ItemsPerTrack> selectedItems = items.ToItemsPerTrack().ToList(); if (selectedItems.Any()) { var requestedTime = CalculateDuplicateTime(selectedItems, gapBetweenItems); var duplicatedItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector, selectedItems, requestedTime, "Duplicate Items"); TimelineHelpers.FrameItems(duplicatedItems); SelectionManager.RemoveTimelineSelection(); foreach (var item in duplicatedItems) { SelectionManager.Add(item); } } var tracks = context.tracks.ToArray(); if (tracks.Length > 0) { tracks.Invoke <DuplicateTracks>(); } TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved); return(true); }
static bool SelectFirstClipStartingFrom(TrackAsset track) { List <TrackAsset> visibleTracks = GetVisibleTracks().Select(x => x.track).ToList(); int idx = visibleTracks.IndexOf(track); ITimelineItem item = null; for (int i = idx; i < visibleTracks.Count; ++i) { var items = visibleTracks[i].GetItems().OfType <ClipItem>(); if (!items.Any() || visibleTracks[i].lockedInHierarchy) { continue; } item = items.First(); break; } if (item != null) { SelectionManager.SelectOnly(item); TimelineHelpers.FrameItems(new[] { item }); return(true); } return(false); }
/// <summary> /// Tries to select the first clip from a list of tracks /// </summary> /// <param name="tracks"></param> /// <returns>true if any expanded, false otherwise</returns> public static bool TrySelectFirstChild(IEnumerable <TrackAsset> tracks) { foreach (var track in tracks) { //Try to navigate in group tracks first if (track is GroupTrack) { if (track.GetChildTracks().Any()) { SelectionManager.SelectOnly(track.GetChildTracks().First()); return(true); } //Group tracks should not halt navigation continue; } //if track is locked or has no clips, do nothing if (track.lockedInHierarchy || !track.clips.Any()) { continue; } var firstClip = track.clips.First(); SelectionManager.SelectOnly(firstClip); TimelineHelpers.FrameItems(new ITimelineItem[] { firstClip.ToItem() }); return(true); } return(false); }
public static bool UnCollapseGroup() { if (TrackHeadActive()) { var quit = false; foreach (var track in SelectionManager.SelectedTracks()) { if (!track.GetChildTracks().Any()) { continue; } if (!quit && track.GetCollapsed()) { quit = true; } track.SetCollapsed(false); } if (quit) { TimelineEditor.Refresh(RefreshReason.ContentsModified); return(true); } // Transition to Clip area var visibleTracks = GetVisibleTracks().Select(x => x.track).ToList(); var idx = visibleTracks.IndexOf(SelectionManager.SelectedTracks().Last()); ITimelineItem item = null; for (var i = idx; i < visibleTracks.Count; ++i) { var items = visibleTracks[i].GetItems().OfType <ClipItem>(); if (!items.Any()) { continue; } item = items.First(); break; } if (item != null) { SelectionManager.SelectOnly(item); TimelineHelpers.FrameItems(new[] { item }); return(true); } } return(false); }
static void PasteItems(WindowState state, Vector2?mousePosition) { var copiedItems = TimelineEditor.clipboard.GetCopiedItems().ToList(); var numberOfUniqueParentsInClipboard = copiedItems.Count(); if (numberOfUniqueParentsInClipboard == 0) { return; } List <ITimelineItem> newItems; //if the copied items were on a single parent, then use the mouse position to get the parent OR the original parent if (numberOfUniqueParentsInClipboard == 1) { var itemsGroup = copiedItems.First(); TrackAsset target; if (mousePosition.HasValue) { target = state.spacePartitioner.GetItemsAtPosition <IRowGUI>(mousePosition.Value).First().asset; } else { target = FindSuitableParentForSingleTrackPasteWithoutMouse(itemsGroup); } var candidateTime = TimelineHelpers.GetCandidateTime(state, mousePosition, target); newItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(state, itemsGroup, target, candidateTime, "Paste Items").ToList(); } //if copied items were on multiple parents, then the destination parents are the same as the original parents else { var time = TimelineHelpers.GetCandidateTime(state, mousePosition, copiedItems.Select(c => c.targetTrack).ToArray()); newItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(state, copiedItems, time, "Paste Items").ToList(); } TimelineHelpers.FrameItems(state, newItems); SelectionManager.RemoveTimelineSelection(); foreach (var item in newItems) { SelectionManager.Add(item); } }
static void PasteItems(double?invocationTime) { var copiedItems = TimelineEditor.clipboard.GetCopiedItems().ToList(); var numberOfUniqueParentsInClipboard = copiedItems.Count(); if (numberOfUniqueParentsInClipboard == 0) { return; } List <ITimelineItem> newItems; //if the copied items were on a single parent, then use the mouse position to get the parent OR the original parent if (numberOfUniqueParentsInClipboard == 1) { var itemsGroup = copiedItems.First(); TrackAsset target = null; if (invocationTime.HasValue) { target = GetPickedTrack(); } if (target == null) { target = FindSuitableParentForSingleTrackPasteWithoutMouse(itemsGroup); } var candidateTime = invocationTime ?? TimelineHelpers.GetCandidateTime(null, target); newItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(TimelineEditor.clipboard.exposedPropertyTable, TimelineEditor.inspectedDirector, itemsGroup, target, candidateTime, "Paste Items").ToList(); } //if copied items were on multiple parents, then the destination parents are the same as the original parents else { var time = invocationTime ?? TimelineHelpers.GetCandidateTime(null, copiedItems.Select(c => c.targetTrack).ToArray()); newItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(TimelineEditor.clipboard.exposedPropertyTable, TimelineEditor.inspectedDirector, copiedItems, time, "Paste Items").ToList(); } TimelineHelpers.FrameItems(newItems); SelectionManager.RemoveTimelineSelection(); foreach (var item in newItems) { SelectionManager.Add(item); } }
public static bool SelectDownItem() { if (ClipAreaActive()) { var refItem = SelectionManager.SelectedItems().Last(); var nextTrack = refItem.parentTrack.NextTrack(); while (nextTrack != null) { var selectionItem = GetClosestItem(nextTrack, refItem); if (selectionItem == null || nextTrack.lockedInHierarchy) { nextTrack = nextTrack.NextTrack(); continue; } SelectionManager.SelectOnly(selectionItem); TimelineHelpers.FrameItems(new[] { selectionItem }); FrameTrackHeader(GetVisibleTracks().First(x => x.track == selectionItem.parentTrack)); break; } return(true); } return(false); }