Beispiel #1
0
        public static TimelineClip CreateClipOnTrack(Object asset, TrackAsset parentTrack, ITimelineState state, Vector2 mousePosition)
        {
            double       end          = parentTrack.end;
            TimelineClip timelineClip = parentTrack.CreateClipFromAsset(asset);

            if (timelineClip != null)
            {
                SelectionManager.Clear();
                timelineClip.timeScale = 1.0;
                if (!float.IsPositiveInfinity(mousePosition.x) && !float.IsPositiveInfinity(mousePosition.y))
                {
                    timelineClip.start = (double)state.ScreenSpacePixelToTimeAreaTime(mousePosition.x);
                }
                else
                {
                    timelineClip.start = state.SnapToFrameIfRequired(end);
                }
                timelineClip.start       = Math.Max(0.0, timelineClip.start);
                timelineClip.mixInCurve  = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
                timelineClip.mixOutCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
                SelectionManager.Add(timelineClip);
                parentTrack.CalculateExtrapolationTimes();
                state.Refresh();
            }
            return(timelineClip);
        }
        private static double CalculateMarkerTimeForMousePosition(TrackAsset trackAsset, ITimelineState state, Vector3 mousePosition)
        {
            double time = 0.0;

            if (!float.IsPositiveInfinity(mousePosition.x) && !float.IsPositiveInfinity(mousePosition.y))
            {
                time = (double)state.ScreenSpacePixelToTimeAreaTime(mousePosition.x);
            }
            else if (trackAsset != null)
            {
                time = trackAsset.end + 0.5;
            }
            return(Math.Max(0.0, state.SnapToFrameIfRequired(time)));
        }
Beispiel #3
0
        public static double FindBestInsertionTime(ITimelineState state, TimelineClip clip, TrackAsset track, Vector2 mousePosition)
        {
            double       droppedTime  = state.SnapToFrameIfRequired((double)state.ScreenSpacePixelToTimeAreaTime(mousePosition.x));
            TimelineClip timelineClip = (from c in track.clips
                                         where c != clip && c.start - TimeUtility.kTimeEpsilon <= droppedTime
                                         orderby c.start
                                         select c).LastOrDefault <TimelineClip>();
            double result;

            if (timelineClip != null)
            {
                double num  = timelineClip.start + timelineClip.duration;
                double num2 = (double)state.TimeAreaPixelToTime(0f);
                if (num < num2)
                {
                    result = droppedTime;
                }
                else if (!float.IsPositiveInfinity(mousePosition.x) && droppedTime > num)
                {
                    result = droppedTime;
                }
                else
                {
                    result = num;
                }
            }
            else
            {
                timelineClip = (from c in track.clips
                                where c != clip
                                orderby c.start + c.duration
                                select c).LastOrDefault <TimelineClip>();
                if (timelineClip != null)
                {
                    result = timelineClip.start + timelineClip.duration;
                }
                else
                {
                    result = 0.0;
                }
            }
            return(result);
        }