void HandleDragAndDrop() { if (TimelineWindow.instance.state.editSequence.isReadOnly) { return; } if (Event.current == null || Event.current.type != EventType.DragUpdated && Event.current.type != EventType.DragPerform && Event.current.type != EventType.DragExited) { return; } timeline.CreateMarkerTrack(); // Ensure Marker track is created. var objectsBeingDropped = DragAndDrop.objectReferences.OfType <Object>(); var candidateTime = TimelineHelpers.GetCandidateTime(Event.current.mousePosition); var perform = Event.current.type == EventType.DragPerform; var director = state.editSequence != null ? state.editSequence.director : null; DragAndDrop.visualMode = TimelineDragging.HandleClipPaneObjectDragAndDrop(objectsBeingDropped, timeline.markerTrack, perform, timeline, null, director, candidateTime, TimelineDragging.ResolveType); if (perform && DragAndDrop.visualMode == DragAndDropVisualMode.Copy) { DragAndDrop.AcceptDrag(); } }
public static void ShowItemContextMenu(Vector2 mousePosition) { var menu = new GenericMenu(); var state = TimelineWindow.instance.state; TimelineAction.AddToMenu(menu, state, mousePosition); if (SelectionManager.SelectedClips().Any()) { ItemAction <TimelineClip> .AddToMenu(menu, state); } if (SelectionManager.SelectedMarkers().Any()) { ItemAction <IMarker> .AddToMenu(menu, state); } var clipGUI = PickerUtils.PickedLayerableOfType <TimelineClipGUI>(); if (clipGUI != null && clipGUI.drawer != null) { var clips = SelectionManager.SelectedClips().ToArray(); if (clips.Length > 0) { clipGUI.drawer.OnBuildClipContextMenu(menu, clips, state); AddMarkerMenuCommands(menu, clipGUI.clip.parentTrack, TimelineHelpers.GetCandidateTime(state, mousePosition)); } } menu.ShowAsContext(); }
public static void BuildTrackContextMenu(List <MenuActionItem> items, Vector2?mousePosition) { var tracks = SelectionManager.SelectedTracks().ToArray(); if (tracks.Length == 0) { return; } ActionManager.GetMenuEntries(ActionManager.TimelineActions, mousePosition, items); ActionManager.GetMenuEntries(ActionManager.TrackActions, items); AddLayeredTrackCommands(items, tracks); var first = tracks.First().GetType(); var allTheSame = tracks.All(t => t.GetType() == first); if (allTheSame) { if (first != typeof(GroupTrack)) { var candidateTime = TimelineHelpers.GetCandidateTime(mousePosition, tracks); AddClipMenuCommands(items, tracks, candidateTime); AddMarkerMenuCommands(items, tracks, candidateTime); } else { BuildNewTracksContextMenu(items, tracks, TimelineWindow.instance.state, Styles.addItemTemplate); } } }
public virtual void OnBuildTrackContextMenu(GenericMenu menu, TrackAsset trackAsset, WindowState state) { var mousePosition = trackMenuContext.mousePosition; var candidateTime = TimelineHelpers.GetCandidateTime(state, mousePosition, trackAsset); SequencerContextMenu.AddClipMenuCommands(menu, trackAsset, candidateTime); SequencerContextMenu.AddMarkerMenuCommands(menu, trackAsset, candidateTime); }
public static void ShowMenu(Vector2?mousePosition, WindowState state) { var menu = new GenericMenu(); ContextMenus.markerHeaderMenu.AddToMenu(menu, state); var timeline = state.editSequence.asset; var time = TimelineHelpers.GetCandidateTime(state, mousePosition); var enabled = timeline.markerTrack == null || !timeline.markerTrack.lockedInHierarchy && !state.editSequence.isReadOnly; var addMarkerCommand = new Func <Type, IMarker>(type => AddMarkerCommand(type, time, state)); SequencerContextMenu.AddMarkerMenuCommands(menu, timeline.markerTrack, addMarkerCommand, enabled); menu.ShowAsContext(); }
public static void BuildMarkerHeaderContextMenu(List <MenuActionItem> menu, Vector2?mousePosition, WindowState state) { ActionManager.GetMenuEntries(ActionManager.TimelineActions, null, menu, MenuFilter.MarkerHeader); var timeline = state.editSequence.asset; var time = TimelineHelpers.GetCandidateTime(mousePosition); var enabled = timeline.markerTrack == null || !timeline.markerTrack.lockedInHierarchy; var addMarkerCommand = new Action <Type, Object> ( (type, obj) => AddSingleMarkerCallback(type, time, timeline, state.editSequence.director, obj) ); AddMarkerMenuCommands(menu, new TrackAsset[] { timeline.markerTrack }, addMarkerCommand, enabled); }
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 void ShowMenu(Vector2?mousePosition, WindowState state) { var menu = new GenericMenu(); ContextMenus.markerHeaderMenu.AddToMenu(menu, state); var timeline = state.editSequence.asset; var markerTypes = TypeUtility.GetMarkerTypes(); // Marker track supports all Markers for now if (markerTypes.Any()) { menu.AddSeparator(string.Empty); var time = TimelineHelpers.GetCandidateTime(state, mousePosition); var addMarkerCommand = new Func <Type, IMarker>(type => AddMarkerCommand(type, time, state)); var enabled = timeline.markerTrack == null || !timeline.markerTrack.lockedInHierarchy; SequencerContextMenu.AddMarkerMenuCommands(menu, markerTypes, addMarkerCommand, enabled); } if (timeline.markerTrack != null) { SequencerContextMenu.RemoveInvalidMarkersMenuItem(menu, timeline.markerTrack); } menu.ShowAsContext(); }
public static void BuildItemContextMenu(List <MenuActionItem> items, Vector2 mousePosition) { ActionManager.GetMenuEntries(ActionManager.TimelineActions, mousePosition, items); ActionManager.GetMenuEntries(ActionManager.ClipActions, items); ActionManager.GetMenuEntries(ActionManager.MarkerActions, items); var clips = TimelineEditor.selectedClips; if (clips.Length > 0) { AddMarkerMenuCommands(items, clips.Select(c => c.parentTrack).Distinct().ToList(), TimelineHelpers.GetCandidateTime(mousePosition)); } }
internal static void BuildItemContextMenu(List <MenuActionItem> items, Vector2 mousePosition, TimelineClip[] clips, IMarker[] markers) { var state = TimelineWindow.instance.state; TimelineAction.GetMenuEntries(TimelineAction.MenuActions, mousePosition, items); ItemAction <TimelineClip> .GetMenuEntries(clips, items); ItemAction <IMarker> .GetMenuEntries(markers, items); if (clips.Length > 0) { AddMarkerMenuCommands(items, clips.Select(c => c.parentTrack).Distinct().ToList(), TimelineHelpers.GetCandidateTime(state, mousePosition)); } }