public static bool SelectDownTrack(bool shift = false)
        {
            if (TrackHeadActive())
            {
                var nextTrack = SelectionManager.SelectedTracks().Last().NextTrack();
                if (nextTrack != null)
                {
                    if (shift)
                    {
                        if (SelectionManager.Contains(nextTrack))
                        {
                            SelectionManager.Remove(SelectionManager.SelectedTracks().Last());
                        }
                        SelectionManager.Add(nextTrack);
                    }
                    else
                    {
                        SelectionManager.SelectOnly(nextTrack);
                    }

                    FrameTrackHeader(GetVisibleTracks().First(x => x.track == nextTrack));
                }
                return(true);
            }

            return(false);
        }
        protected override bool ContextClick(Event evt, WindowState state)
        {
            if (evt.alt)
            {
                return(false);
            }

            var selectable = PickerUtils.PickedSelectable();

            if (selectable != null && selectable.IsSelected())
            {
                SequencerContextMenu.ShowItemContextMenu(evt.mousePosition);
                return(true);
            }

            var trackGUI = PickerUtils.PickedTrackBaseGUI();

            if (trackGUI != null)
            {
                SelectionManager.SelectOnly(trackGUI.track);
                trackGUI.drawer.trackMenuContext.clipTimeCreation = TrackDrawer.TrackMenuContext.ClipTimeCreation.Mouse;
                trackGUI.drawer.trackMenuContext.mousePosition    = evt.mousePosition;
                trackGUI.DisplayTrackMenu();
                return(true);
            }

            return(false);
        }
 public static bool SelectUpTrack(bool shift = false)
 {
     if (TrackHeadActive())
     {
         var prevTrack = PreviousTrack(SelectionManager.SelectedTracks().Last());
         if (prevTrack != null)
         {
             if (shift)
             {
                 if (SelectionManager.Contains(prevTrack))
                 {
                     SelectionManager.Remove(SelectionManager.SelectedTracks().Last());
                 }
                 SelectionManager.Add(prevTrack);
             }
             else
             {
                 SelectionManager.SelectOnly(prevTrack);
             }
             FrameTrackHeader(GetVisibleTracks().First(x => x.track == prevTrack));
         }
         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);
        }
        public static bool CollapseGroup()
        {
            if (TrackHeadActive())
            {
                var quit = false;
                foreach (var track in SelectionManager.SelectedTracks())
                {
                    if (!track.GetChildTracks().Any())
                    {
                        continue;
                    }
                    if (!quit && !track.GetCollapsed())
                    {
                        quit = true;
                    }
                    track.SetCollapsed(true);
                }
                if (quit)
                {
                    TimelineEditor.Refresh(RefreshReason.ContentsModified);
                    return(true);
                }

                var selectedTrack = SelectionManager.SelectedTracks().LastOrDefault();
                var parent        = selectedTrack != null ? selectedTrack.parent as TrackAsset : null;
                if (parent)
                {
                    SelectionManager.SelectOnly(parent);
                    FrameTrackHeader(GetVisibleTracks().First(x => x.track == parent));
                    return(true);
                }
            }
            return(false);
        }
        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);
        }
Пример #8
0
        /// <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);
        }
        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);
        }
 static void DrawTrackDropDownMenu(Rect rect)
 {
     if (GUI.Button(rect, GUIContent.none, DirectorStyles.Instance.trackOptions))
     {
         SelectionManager.SelectOnly(TimelineEditor.inspectedAsset.markerTrack);
         SequencerContextMenu.ShowTrackContextMenu(null);
     }
 }
Пример #11
0
        protected override bool MouseDown(Event evt, WindowState state)
        {
            if (evt.button != 0 || !IsMouseOverMarkerHeader(evt.mousePosition, state))
            {
                return(false);
            }

            SelectionManager.SelectOnly(state.editSequence.asset.markerTrack);
            return(true);
        }
Пример #12
0
        protected override bool ContextClick(Event evt, WindowState state)
        {
            if (!IsMouseOverMarkerHeader(evt.mousePosition, state))
            {
                return(false);
            }

            SelectionManager.SelectOnly(state.editSequence.asset.markerTrack);
            SequencerContextMenu.ShowTrackContextMenu(evt.mousePosition);
            return(true);
        }
        static bool SelectAndShowParentTrack(TrackAsset track)
        {
            TrackAsset parent = track != null ? track.parent as TrackAsset : null;

            if (parent)
            {
                SelectionManager.SelectOnly(parent);
                FrameTrackHeader(GetVisibleTracks().First(x => x.track == parent));
                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);
        }
        public static bool FocusFirstVisibleItem(IEnumerable <TrackAsset> focusTracks = null)
        {
            var timeRange = TimelineEditor.visibleTimeRange;

            var tracks = focusTracks ?? TimelineWindow.instance.treeView.visibleTracks.Where(x => x.IsVisibleRecursive() && x.GetItems().Any());
            var items  = tracks.SelectMany(t => t.GetItems().OfType <ClipItem>().Where(x => x.end >= timeRange.x && x.end <= timeRange.y ||
                                                                                       x.start >= timeRange.x && x.start <= timeRange.y)).ToList();
            var itemFullyInView = items.Where(x => x.end >= timeRange.x && x.end <= timeRange.y &&
                                              x.start >= timeRange.x && x.start <= timeRange.y);
            var itemToSelect = itemFullyInView.FirstOrDefault() ?? items.FirstOrDefault();

            if (itemToSelect != null)
            {
                SelectionManager.SelectOnly(itemToSelect);
                return(true);
            }
            return(false);
        }
Пример #16
0
        public override bool Execute(ActionContext actionContext)
        {
            if (KeyboardNavigation.TrackHeadActive())
            {
                return(KeyboardNavigation.FocusFirstVisibleItem(actionContext.tracks));
            }

            if (!KeyboardNavigation.ClipAreaActive())
            {
                return(KeyboardNavigation.FocusFirstVisibleItem());
            }

            var item = KeyboardNavigation.GetVisibleSelectedItems().LastOrDefault();

            if (item != null)
            {
                SelectionManager.SelectOnly(item.parentTrack);
            }
            return(true);
        }
        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);
        }
Пример #18
0
 public void SelectCurves()
 {
     SelectionManager.SelectOnly(clip);
     SelectionManager.SelectInlineCurveEditor(this);
 }