public override bool Execute(WindowState state)
        {
            if (SelectionManager.GetCurrentInlineEditorCurve() != null)
            {
                return(false);
            }

            if (!CanDelete(state))
            {
                return(false);
            }

            var selectedItems = SelectionManager.SelectedItems();

            DeleteItems(selectedItems);

            var tracks = SelectionManager.SelectedTracks().ToArray();

            if (tracks.Any())
            {
                TrackAction.Invoke <DeleteTracks>(state, tracks);
            }

            state.Refresh();
            return(selectedItems.Any() || tracks.Length > 0);
        }
        static bool CanExecute(WindowState state, ActionContext context)
        {
            if (context.timeline == null)
            {
                return(false);
            }

            if (context.markers.Any())
            {
                return(false);
            }

            if (context.tracks.ContainsTimelineMarkerTrack(context.timeline))
            {
                return(false);
            }

            IClipCurveEditorOwner curveSelected = SelectionManager.GetCurrentInlineEditorCurve();

            // Can't have an inline curve selected and have multiple tracks also.
            if (curveSelected != null)
            {
                return(state.IsArmedForRecord(curveSelected.owner));
            }

            return(GetKeyableTracks(state, context).Any());
        }
Exemplo n.º 3
0
        // CurveEditor uses an hardcoded shortcut to execute the FrameAll action, preventing the ShortcutManager from
        // ever picking it up. We have to hijack it to ensure our code is being run when framing inline curves.
        protected override bool KeyDown(Event evt, WindowState state)
        {
            var inlineCurveEditor = SelectionManager.GetCurrentInlineEditorCurve();

            if (inlineCurveEditor == null || !inlineCurveEditor.inlineCurvesSelected)
            {
                return(false);
            }

            // Not conflicting with the hardcoded value
            if (evt.keyCode != KeyCode.A)
            {
                return(false);
            }

            var combination = ShortcutManager.instance.GetShortcutBinding(Shortcuts.Timeline.frameAll)
                              .keyCombinationSequence.ToList();

            var shortcutCombination = combination.First();
            var currentCombination  = KeyCombination.FromKeyboardInput(evt);

            // User is not actually pressing the correct key combination for FrameAll
            if (combination.Count == 1 && shortcutCombination.Equals(currentCombination))
            {
                Invoker.InvokeWithSelected <FrameAllAction>();
            }

            return(true);
        }
        void OnSelectionChange()
        {
            //Sanitize the inline curve selection
            SelectionManager.GetCurrentInlineEditorCurve()?.ValidateCurvesSelection();

            RefreshSelection(false);
        }
Exemplo n.º 5
0
        public override bool Execute(TimelineWindow.TimelineState state)
        {
            bool result;

            if (SelectionManager.GetCurrentInlineEditorCurve() != null)
            {
                result = false;
            }
            else
            {
                ITimelineItem[] array = (from x in SelectionManager.SelectedItemGUI()
                                         select x.selectableObject as ITimelineItem).ToArray <ITimelineItem>();
                if (array.Length > 0)
                {
                    ItemActionInvoker.InvokeByName <TimelineClip>("DeleteClips", state, array);
                    ItemActionInvoker.InvokeByName <TimelineMarker>("DeleteMarkers", state, array);
                }
                TrackAsset[] array2 = SelectionManager.SelectedTracks().ToArray <TrackAsset>();
                if (array2.Length > 0)
                {
                    TrackAction.InvokeByName("DeleteTracks", state, array2);
                }
                result = (array.Length > 0 || array2.Length > 0);
            }
            return(result);
        }
        public override bool Execute(WindowState state)
        {
            var inlineCurveEditor = SelectionManager.GetCurrentInlineEditorCurve();

            if (inlineCurveEditor != null && inlineCurveEditor.inlineCurvesSelected)
            {
                FrameSelectedAction.FrameInlineCurves(inlineCurveEditor, state, false);
                return(true);
            }

            if (state.IsEditingASubItem())
            {
                return(false);
            }

            var w = state.GetWindow();

            if (w == null || w.treeView == null)
            {
                return(false);
            }

            var visibleTracks = w.treeView.visibleTracks.ToList();

            if (state.editSequence.asset != null && state.editSequence.asset.markerTrack != null)
            {
                visibleTracks.Add(state.editSequence.asset.markerTrack);
            }

            if (visibleTracks.Count == 0)
            {
                return(false);
            }

            var startTime = float.MaxValue;
            var endTime   = float.MinValue;

            foreach (var t in visibleTracks)
            {
                if (t == null)
                {
                    continue;
                }

                double trackStart, trackEnd;
                t.GetItemRange(out trackStart, out trackEnd);
                startTime = Mathf.Min(startTime, (float)trackStart);
                endTime   = Mathf.Max(endTime, (float)(trackEnd));
            }

            if (startTime != float.MinValue)
            {
                FrameSelectedAction.FrameRange(startTime, endTime, state);
                return(true);
            }

            return(false);
        }
        public override bool Execute(WindowState state)
        {
            if (SelectionManager.GetCurrentInlineEditorCurve() != null)
            {
                return(false);
            }

            var clips = SelectionManager.SelectedClips().ToArray();

            return(clips.Length > 0 && ClipModifier.MatchContent(clips));
        }
Exemplo n.º 8
0
        public override bool Execute(ActionContext actionContext)
        {
            var inlineCurveEditor = SelectionManager.GetCurrentInlineEditorCurve();

            if (FrameSelectedAction.ShouldHandleInlineCurve(inlineCurveEditor))
            {
                FrameSelectedAction.FrameInlineCurves(inlineCurveEditor, false);
                return(true);
            }

            if (TimelineWindow.instance.state.IsCurrentEditingASequencerTextField())
            {
                return(false);
            }

            var visibleTracks = TimelineWindow.instance.treeView.visibleTracks.ToList();

            if (TimelineEditor.inspectedAsset != null && TimelineEditor.inspectedAsset.markerTrack != null)
            {
                visibleTracks.Add(TimelineEditor.inspectedAsset.markerTrack);
            }

            if (visibleTracks.Count == 0)
            {
                return(false);
            }

            var startTime = float.MaxValue;
            var endTime   = float.MinValue;

            foreach (var t in visibleTracks)
            {
                if (t == null)
                {
                    continue;
                }

                // time range based on track's curves and clips.
                double trackStart, trackEnd, trackDuration;
                t.GetSequenceTime(out trackStart, out trackDuration);
                trackEnd = trackStart + trackDuration;

                // take track's markers into account
                double itemsStart, itemsEnd;
                ItemsUtils.GetItemRange(t, out itemsStart, out itemsEnd);

                startTime = Mathf.Min(startTime, (float)trackStart, (float)itemsStart);
                endTime   = Mathf.Max(endTime, (float)(trackEnd), (float)itemsEnd);
            }

            FrameSelectedAction.FrameRange(startTime, endTime);
            return(true);
        }
Exemplo n.º 9
0
        public override bool Execute(ActionContext actionContext)
        {
            var inlineCurveEditor = SelectionManager.GetCurrentInlineEditorCurve();

            if (ShouldHandleInlineCurve(inlineCurveEditor))
            {
                FrameInlineCurves(inlineCurveEditor, true);
                return(true);
            }

            if (TimelineWindow.instance.state.IsCurrentEditingASequencerTextField())
            {
                return(false);
            }

            if (SelectionManager.Count() == 0)
            {
                actionContext.Invoke <FrameAllAction>();
                return(true);
            }

            var startTime = float.MaxValue;
            var endTime   = float.MinValue;

            var clips   = actionContext.clips.Select(ItemToItemGui.GetGuiForClip);
            var markers = actionContext.markers;

            if (!clips.Any() && !markers.Any())
            {
                return(false);
            }

            foreach (var c in clips)
            {
                startTime = Mathf.Min(startTime, (float)c.clip.start);
                endTime   = Mathf.Max(endTime, (float)c.clip.end);
                if (c.clipCurveEditor != null)
                {
                    c.clipCurveEditor.FrameClip();
                }
            }

            foreach (var marker in markers)
            {
                startTime = Mathf.Min(startTime, (float)marker.time);
                endTime   = Mathf.Max(endTime, (float)marker.time);
            }

            FrameRange(startTime, endTime);

            return(true);
        }
Exemplo n.º 10
0
        public override bool Execute(WindowState state)
        {
            var inlineCurveEditor = SelectionManager.GetCurrentInlineEditorCurve();

            if (ShouldHandleInlineCurve(inlineCurveEditor))
            {
                FrameInlineCurves(inlineCurveEditor, state, true);
                return(true);
            }

            if (state.IsCurrentEditingASequencerTextField())
            {
                return(false);
            }

            if (SelectionManager.Count() == 0)
            {
                Invoke <FrameAllAction>(state);
                return(true);
            }

            var startTime = float.MaxValue;
            var endTime   = float.MinValue;

            var clips   = SelectionManager.SelectedClipGUI();
            var markers = SelectionManager.SelectedMarkers();

            if (!clips.Any() && !markers.Any())
            {
                return(false);
            }

            foreach (var c in clips)
            {
                startTime = Mathf.Min(startTime, (float)c.clip.start);
                endTime   = Mathf.Max(endTime, (float)c.clip.end);
                if (c.clipCurveEditor != null)
                {
                    c.clipCurveEditor.FrameClip();
                }
            }

            foreach (var marker in markers)
            {
                startTime = Mathf.Min(startTime, (float)marker.time);
                endTime   = Mathf.Max(endTime, (float)marker.time);
            }

            FrameRange(startTime, endTime, state);

            return(true);
        }
        public override MenuActionDisplayState GetDisplayState(WindowState state)
        {
            var clips = SelectionManager.SelectedClips().ToArray();

            if (!clips.Any() || SelectionManager.GetCurrentInlineEditorCurve() != null)
            {
                return(MenuActionDisplayState.Hidden);
            }

            return(clips.Any(TimelineHelpers.HasUsableAssetDuration)
                ? MenuActionDisplayState.Visible
                : MenuActionDisplayState.Disabled);
        }
        public override bool Execute(ActionContext actionContext)
        {
            var inlineCurveEditor = SelectionManager.GetCurrentInlineEditorCurve();

            if (FrameSelectedAction.ShouldHandleInlineCurve(inlineCurveEditor))
            {
                FrameSelectedAction.FrameInlineCurves(inlineCurveEditor, false);
                return(true);
            }

            if (TimelineWindow.instance.state.IsCurrentEditingASequencerTextField())
            {
                return(false);
            }

            var visibleTracks = TimelineWindow.instance.treeView.visibleTracks.ToList();

            if (TimelineEditor.inspectedAsset != null && TimelineEditor.inspectedAsset.markerTrack != null)
            {
                visibleTracks.Add(TimelineEditor.inspectedAsset.markerTrack);
            }

            if (visibleTracks.Count == 0)
            {
                return(false);
            }

            var startTime = float.MaxValue;
            var endTime   = float.MinValue;

            foreach (var t in visibleTracks)
            {
                if (t == null)
                {
                    continue;
                }

                double trackStart, trackEnd;
                t.GetItemRange(out trackStart, out trackEnd);
                startTime = Mathf.Min(startTime, (float)trackStart);
                endTime   = Mathf.Max(endTime, (float)(trackEnd));
            }

            if (startTime != float.MinValue)
            {
                FrameSelectedAction.FrameRange(startTime, endTime);
                return(true);
            }

            return(false);
        }
Exemplo n.º 13
0
        public override bool Execute(ActionContext context)
        {
            if (!CanDelete(context))
            {
                return(false);
            }

            var selectedItems = context.clips.Select(p => p.ToItem()).ToList();

            selectedItems.AddRange(context.markers.Select(p => p.ToItem()));
            DeleteItems(selectedItems);

            if (context.tracks.Any() && SelectionManager.GetCurrentInlineEditorCurve() == null)
            {
                context.tracks.Invoke <DeleteTracks>();
            }

            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
            return(selectedItems.Any() || context.tracks.Any());
        }
        public override bool Execute(TimelineWindow.TimelineState state)
        {
            IClipCurveEditorOwner currentInlineEditorCurve = SelectionManager.GetCurrentInlineEditorCurve();
            bool result;

            if (currentInlineEditorCurve != null && currentInlineEditorCurve.clipCurveEditor != null)
            {
                currentInlineEditorCurve.clipCurveEditor.SelectAllKeys();
                result = true;
            }
            else
            {
                SelectionManager.Clear();
                state.GetWindow().allTracks.ForEach(delegate(TimelineTrackBaseGUI x)
                {
                    SelectionManager.Add(x.track);
                });
                result = true;
            }
            return(result);
        }
Exemplo n.º 15
0
        protected override bool ExecuteCommand(Event evt, WindowState state)
        {
            if (state.IsCurrentEditingASequencerTextField())
            {
                return(false);
            }

            var inlineCurveEditor = SelectionManager.GetCurrentInlineEditorCurve();

            if (inlineCurveEditor == null || !inlineCurveEditor.inlineCurvesSelected)
            {
                return(false);
            }

            if (evt.commandName != EventCommandNames.FrameSelected)
            {
                return(false);
            }

            Invoker.InvokeWithSelected <FrameSelectedAction>();
            return(true);
        }
        public override bool Execute(ActionContext actionContext)
        {
            WindowState      state    = TimelineEditor.state;
            PlayableDirector director = TimelineEditor.inspectedDirector;

            if (!CanExecute(state, actionContext) || director == null)
            {
                return(false);
            }

            IEnumerable <TrackAsset> keyableTracks = GetKeyableTracks(state, actionContext);

            var curveSelected = SelectionManager.GetCurrentInlineEditorCurve();

            if (curveSelected != null)
            {
                var sel = curveSelected.clipCurveEditor.GetSelectedProperties().ToList();
                var go  = (director.GetGenericBinding(curveSelected.owner) as Component).gameObject;
                if (sel.Count > 0)
                {
                    TimelineRecording.KeyProperties(go, state, sel);
                }
                else
                {
                    var binding = director.GetGenericBinding(curveSelected.owner) as Component;
                    TimelineRecording.KeyAllProperties(binding, state);
                }
            }
            else
            {
                foreach (var track in keyableTracks)
                {
                    var binding = director.GetGenericBinding(track) as Component;
                    TimelineRecording.KeyAllProperties(binding, state);
                }
            }
            return(true);
        }