コード例 #1
0
        private void UpdateDragTarget(TimelineClipGUI uiClip, Vector2 point, TimelineWindow.TimelineState state)
        {
            List <IBounds>   elementsAtPosition = Manipulator.GetElementsAtPosition(state.quadTree, point);
            TimelineTrackGUI timelineTrackGUI   = elementsAtPosition.OfType <TimelineTrackGUI>().FirstOrDefault((TimelineTrackGUI t) => MoveClip.ValidateClipDrag(t.track, uiClip.clip));

            this.m_HasValidDropTarget = (timelineTrackGUI != null && timelineTrackGUI.track.IsCompatibleWithItem(uiClip.clip));
            if (this.m_HasValidDropTarget)
            {
                AnimationTrack animationTrack = timelineTrackGUI.track as AnimationTrack;
                float          start          = state.PixelToTime(this.m_PreviewRect.get_x());
                float          end            = state.PixelToTime(this.m_PreviewRect.get_xMax());
                bool           hasValidDropTarget;
                if (animationTrack != null && animationTrack.CanConvertToClipMode())
                {
                    hasValidDropTarget = ((animationTrack.animClip.get_startTime() < start || animationTrack.animClip.get_stopTime() > end) && (start <animationTrack.animClip.get_startTime() || end> animationTrack.animClip.get_stopTime()));
                }
                else
                {
                    float num = end - start;
                    start = Math.Max(start, 0f);
                    end   = start + num;
                    hasValidDropTarget = (!timelineTrackGUI.track.clips.Any((TimelineClip x) => x.start >= (double)start && x.end <= (double)end) && !timelineTrackGUI.track.clips.Any((TimelineClip x) => (double)start >= x.start && (double)end <= x.end));
                }
                this.m_HasValidDropTarget = hasValidDropTarget;
            }
            this.m_DropTarget = ((!this.m_HasValidDropTarget) ? null : timelineTrackGUI);
        }
コード例 #2
0
        public void Draw(double beginTime, double endTime, MagnetEngine magnetEngine)
        {
            TimelineWindow.TimelineState state = TimelineWindow.instance.state;
            Rect timeAreaBounds = TimelineWindow.instance.timeAreaBounds;

            timeAreaBounds.set_xMin(Mathf.Max(TimelineWindow.instance.timeAreaBounds.get_xMin(), state.TimeToTimeAreaPixel(beginTime)));
            timeAreaBounds.set_xMax(state.TimeToTimeAreaPixel(endTime));
            Rect position = TimelineWindow.instance.get_position();

            using (new GUIViewportScope(TimelineWindow.instance.timeAreaBounds))
            {
                Color textColor = DirectorStyles.Instance.selectedStyle.get_focused().get_textColor();
                textColor.a = 0.12f;
                EditorGUI.DrawRect(timeAreaBounds, textColor);
                this.m_BeginSelectionTooltip.text = state.TimeAsString(beginTime, "F2");
                this.m_EndSelectionTooltip.text   = state.TimeAsString(endTime, "F2");
                Rect bounds = this.m_BeginSelectionTooltip.bounds;
                bounds.set_xMin(timeAreaBounds.get_xMin() - bounds.get_width() / 2f);
                bounds.set_y(timeAreaBounds.get_y());
                this.m_BeginSelectionTooltip.bounds = bounds;
                bounds = this.m_EndSelectionTooltip.bounds;
                bounds.set_xMin(timeAreaBounds.get_xMax() - bounds.get_width() / 2f);
                bounds.set_y(timeAreaBounds.get_y());
                this.m_EndSelectionTooltip.bounds = bounds;
                if (beginTime >= 0.0)
                {
                    this.m_BeginSelectionTooltip.Draw();
                }
                this.m_EndSelectionTooltip.Draw();
            }
            if (beginTime >= 0.0)
            {
                if (magnetEngine == null || !magnetEngine.IsSnappedAtTime((double)state.PixelToTime(timeAreaBounds.get_xMin())))
                {
                    Graphics.DrawDottedLine(new Vector3(timeAreaBounds.get_xMin(), timeAreaBounds.get_yMax(), 0f), new Vector3(timeAreaBounds.get_xMin(), timeAreaBounds.get_yMax() + position.get_height()), 4f, Color.get_black());
                }
                if (magnetEngine == null || !magnetEngine.IsSnappedAtTime((double)state.PixelToTime(timeAreaBounds.get_xMax())))
                {
                    Graphics.DrawDottedLine(new Vector3(timeAreaBounds.get_xMax(), timeAreaBounds.get_yMax(), 0f), new Vector3(timeAreaBounds.get_xMax(), timeAreaBounds.get_yMax() + position.get_height()), 4f, Color.get_black());
                }
            }
        }
コード例 #3
0
        public void DrawCurveEditor(Rect animEditorRect, TimelineWindow.TimelineState state, Vector2 activeRange, bool loop, bool selected)
        {
            this.UpdateCurveEditorIfNeeded(state);
            ZoomableArea arg_29_0 = this.m_CurveEditor;
            float        num      = this.CalculateTopMargin(animEditorRect.get_height());

            this.m_CurveEditor.set_bottommargin(num);
            arg_29_0.set_topmargin(num);
            float num2 = state.TimeToPixel((double)this.m_DataSource.start) - animEditorRect.get_xMin();

            this.m_CurveEditor.set_rightmargin(0f);
            this.m_CurveEditor.set_leftmargin(num2);
            this.m_CurveEditor.set_rect(new Rect(0f, 0f, animEditorRect.get_width(), animEditorRect.get_height()));
            this.m_CurveEditor.SetShownHRangeInsideMargins(0f, (state.PixelToTime(animEditorRect.get_xMax()) - this.m_DataSource.start) * this.m_DataSource.timeScale);
            if (this.m_LastFrameRate != state.frameRate)
            {
                this.m_CurveEditor.get_hTicks().SetTickModulosForFrameRate(state.frameRate);
                this.m_LastFrameRate = state.frameRate;
            }
            CurveWrapper[] animationCurves = this.m_CurveEditor.get_animationCurves();
            for (int i = 0; i < animationCurves.Length; i++)
            {
                CurveWrapper curveWrapper = animationCurves[i];
                curveWrapper.get_renderer().SetWrap(0, (!loop) ? 0 : 2);
            }
            this.m_CurveEditor.BeginViewGUI();
            Color color = GUI.get_color();

            GUI.set_color(Color.get_white());
            GUI.BeginGroup(animEditorRect);
            Graphics.DrawLine(new Vector2(num2, 0f), new Vector2(num2, animEditorRect.get_height()), new Color(1f, 1f, 1f, 0.5f));
            float num3 = activeRange.x - animEditorRect.get_x();
            float num4 = activeRange.y - activeRange.x;

            if (selected)
            {
                Rect rect = new Rect(num3, 0f, num4, animEditorRect.get_height());
                ClipCurveEditor.DrawOutline(rect, 2f);
            }
            EditorGUI.BeginChangeCheck();
            Event current = Event.get_current();

            if (current.get_type() == 8 || current.get_type() == 7 || selected)
            {
                this.m_CurveEditor.CurveGUI();
            }
            this.m_CurveEditor.EndViewGUI();
            if (EditorGUI.EndChangeCheck())
            {
                this.OnCurvesUpdated();
            }
            Color colorInlineCurveOutOfRangeOverlay = DirectorStyles.Instance.customSkin.colorInlineCurveOutOfRangeOverlay;
            Rect  rect2 = new Rect(num2, 0f, num3 - num2, animEditorRect.get_height());

            EditorGUI.DrawRect(rect2, colorInlineCurveOutOfRangeOverlay);
            Rect rect3 = new Rect(num3 + num4, 0f, animEditorRect.get_width() - num3 - num4, animEditorRect.get_height());

            EditorGUI.DrawRect(rect3, colorInlineCurveOutOfRangeOverlay);
            GUI.set_color(color);
            GUI.EndGroup();
            Rect rect4 = animEditorRect;

            rect4.set_width(ClipCurveEditor.s_GridLabelWidth);
            float num5 = num2 - ClipCurveEditor.s_GridLabelWidth;

            if (num5 > 0f)
            {
                rect4.set_x(animEditorRect.get_x() + num5);
            }
            GUI.BeginGroup(rect4);
            this.m_CurveEditor.GridGUI();
            GUI.EndGroup();
        }
コード例 #4
0
 public void CalculateLoopRects(Rect trackRect, TimelineWindow.TimelineState state, int currentClipHash)
 {
     if (this.clip.duration >= TimelineWindow.TimelineState.kTimeEpsilon)
     {
         if (this.clip.dirtyHash != currentClipHash)
         {
             float num = 0f;
             this.m_LoopRects.Clear();
             double[] loopTimes    = TimelineHelpers.GetLoopTimes(this.clip);
             double   loopDuration = TimelineHelpers.GetLoopDuration(this.clip);
             this.m_MinLoopIndex = 0;
             if (!this.supportsLooping)
             {
                 if (loopTimes.Length > 1)
                 {
                     double num2 = loopTimes[1];
                     float  num3 = (float)(this.clip.duration - num2);
                     this.m_LoopRects.Add(TimelineClipGUI.ProjectRectOnTimeline(new Rect((float)(num2 + this.clip.start), 0f, num3, 0f), trackRect, state));
                 }
             }
             else
             {
                 int num4 = Array.BinarySearch <double>(loopTimes, (double)state.PixelToTime(trackRect.get_xMin()));
                 int num5 = Array.BinarySearch <double>(loopTimes, (double)state.PixelToTime(trackRect.get_xMax()));
                 num4 = ((num4 < 0) ? Math.Max(1, ~num4 - 2) : num4);
                 num5 = ((num5 < 0) ? Math.Max(1, ~num5) : num5);
                 this.m_MinLoopIndex = num4;
                 int num6 = num5 - num4;
                 if ((float)num6 * 4f < trackRect.get_width())
                 {
                     for (int i = num4; i < num5; i++)
                     {
                         double num7 = loopTimes[i];
                         float  num8 = Mathf.Min((float)(this.clip.duration - num7), (float)loopDuration);
                         Rect   item = TimelineClipGUI.ProjectRectOnTimeline(new Rect((float)(num7 + this.clip.start), 0f, num8, 0f), trackRect, state);
                         if (item.get_xMin() > trackRect.get_xMax())
                         {
                             break;
                         }
                         if (item.get_xMax() >= trackRect.get_xMin())
                         {
                             this.m_LoopRects.Add(item);
                             num += item.get_width();
                         }
                         else
                         {
                             this.m_MinLoopIndex++;
                         }
                     }
                     if ((float)this.m_LoopRects.Count * 4f >= trackRect.get_width())
                     {
                         this.m_LoopRects.Clear();
                     }
                     if (num < 2f)
                     {
                         this.m_LoopRects.Clear();
                     }
                 }
             }
         }
     }
 }