Наследование: ZoomableArea
Пример #1
0
 public virtual void Initialize(TimeArea timeArea)
 {
     this.m_TimeArea = timeArea;
     if (this.m_Styles == null)
     {
         this.m_Styles = new RectangleTool.Styles();
     }
 }
Пример #2
0
        public void TimeRuler(Rect position, float frameRate, bool labels, bool useEntireHeight, float alpha)
        {
            Color color = GUI.color;

            GUI.BeginGroup(position);
            if (Event.current.type != EventType.Repaint)
            {
                GUI.EndGroup();
            }
            else
            {
                TimeArea.InitStyles();
                HandleUtility.ApplyWireMaterial();
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    GL.Begin(7);
                }
                else
                {
                    GL.Begin(1);
                }
                Color backgroundColor = GUI.backgroundColor;
                this.SetTickMarkerRanges();
                this.hTicks.SetTickStrengths(3f, 80f, true);
                Color textColor = TimeArea.styles.TimelineTick.normal.textColor;
                textColor.a = 0.75f * alpha;
                for (int level = 0; level < this.hTicks.tickLevels; ++level)
                {
                    float   b            = this.hTicks.GetStrengthOfLevel(level) * 0.9f;
                    float[] ticksAtLevel = this.hTicks.GetTicksAtLevel(level, true);
                    for (int index = 0; index < ticksAtLevel.Length; ++index)
                    {
                        if ((double)ticksAtLevel[index] >= (double)this.hRangeMin && (double)ticksAtLevel[index] <= (double)this.hRangeMax)
                        {
                            int   num1 = Mathf.RoundToInt(ticksAtLevel[index] * frameRate);
                            float num2 = !useEntireHeight ? (float)((double)position.height * (double)Mathf.Min(1f, b) * 0.699999988079071) : position.height;
                            TimeArea.DrawVerticalLineFast(this.FrameToPixel((float)num1, frameRate, position), (float)((double)position.height - (double)num2 + 0.5), position.height - 0.5f, new Color(1f, 1f, 1f, b / 0.5f) * textColor);
                        }
                    }
                }
                GL.End();
                if (labels)
                {
                    float[] ticksAtLevel = this.hTicks.GetTicksAtLevel(this.hTicks.GetLevelWithMinSeparation(40f), false);
                    for (int index = 0; index < ticksAtLevel.Length; ++index)
                    {
                        if ((double)ticksAtLevel[index] >= (double)this.hRangeMin && (double)ticksAtLevel[index] <= (double)this.hRangeMax)
                        {
                            int frame = Mathf.RoundToInt(ticksAtLevel[index] * frameRate);
                            GUI.Label(new Rect(Mathf.Floor(this.FrameToPixel((float)frame, frameRate, position)) + 3f, -3f, 40f, 20f), this.FormatFrame(frame, frameRate), TimeArea.styles.TimelineTick);
                        }
                    }
                }
                GUI.EndGroup();
                GUI.backgroundColor = backgroundColor;
                GUI.color           = color;
            }
        }
Пример #3
0
        public virtual void Initialize(TimeArea timeArea)
        {
            m_TimeArea = timeArea;

            if (m_Styles == null)
            {
                m_Styles = new Styles();
            }
        }
Пример #4
0
 public static void DrawVerticalLine(float x, float minY, float maxY, Color color)
 {
     HandleUtility.ApplyWireMaterial();
     if (Application.platform == RuntimePlatform.WindowsEditor)
     {
         GL.Begin(7);
     }
     else
     {
         GL.Begin(1);
     }
     TimeArea.DrawVerticalLineFast(x, minY, maxY, color);
     GL.End();
 }
Пример #5
0
 public void DrawMajorTicks(Rect position, float frameRate)
 {
     GUI.BeginGroup(position);
     if (Event.current.type != EventType.Repaint)
     {
         GUI.EndGroup();
     }
     else
     {
         TimeArea.InitStyles();
         HandleUtility.ApplyWireMaterial();
         this.SetTickMarkerRanges();
         this.hTicks.SetTickStrengths(3f, 80f, true);
         Color textColor = TimeArea.timeAreaStyles.timelineTick.normal.textColor;
         textColor.a = 0.1f;
         if (Application.platform == RuntimePlatform.WindowsEditor)
         {
             GL.Begin(7);
         }
         else
         {
             GL.Begin(1);
         }
         Rect shownArea = base.shownArea;
         for (int i = 0; i < this.hTicks.tickLevels; i++)
         {
             float num = this.hTicks.GetStrengthOfLevel(i) * 0.9f;
             if (num > 0.5f)
             {
                 float[] ticksAtLevel = this.hTicks.GetTicksAtLevel(i, true);
                 for (int j = 0; j < ticksAtLevel.Length; j++)
                 {
                     if (ticksAtLevel[j] >= 0f)
                     {
                         int   num2 = Mathf.RoundToInt(ticksAtLevel[j] * frameRate);
                         float x    = this.FrameToPixel((float)num2, frameRate, position, shownArea);
                         TimeArea.DrawVerticalLineFast(x, 0f, position.height, textColor);
                     }
                 }
             }
         }
         GL.End();
         GUI.EndGroup();
     }
 }
Пример #6
0
 public static void DrawPlayhead(float x, float yMin, float yMax, float thickness, float alpha)
 {
     if (Event.current.type == EventType.Repaint)
     {
         TimeArea.InitStyles();
         float num   = thickness * 0.5f;
         Color color = TimeArea.styles.playhead.normal.textColor.AlphaMultiplied(alpha);
         if (thickness > 1f)
         {
             Rect rect = Rect.MinMaxRect(x - num, yMin, x + num, yMax);
             EditorGUI.DrawRect(rect, color);
         }
         else
         {
             TimeArea.DrawVerticalLine(x, yMin, yMax, color);
         }
     }
 }
Пример #7
0
 public static void DrawVerticalLine(float x, float minY, float maxY, Color color)
 {
     if (Event.current.type == EventType.Repaint)
     {
         Color color2 = Handles.color;
         HandleUtility.ApplyWireMaterial();
         if (Application.platform == RuntimePlatform.WindowsEditor)
         {
             GL.Begin(7);
         }
         else
         {
             GL.Begin(1);
         }
         TimeArea.DrawVerticalLineFast(x, minY, maxY, color);
         GL.End();
         Handles.color = color2;
     }
 }
Пример #8
0
 private void Init()
 {
     if (this.id == -1)
     {
         this.id = GUIUtility.GetPermanentControlID();
     }
     if (this.m_TimeArea == null)
     {
         this.m_TimeArea = new TimeArea(false);
         this.m_TimeArea.hRangeLocked    = false;
         this.m_TimeArea.vRangeLocked    = true;
         this.m_TimeArea.hSlider         = false;
         this.m_TimeArea.vSlider         = false;
         this.m_TimeArea.margin          = 10f;
         this.m_TimeArea.scaleWithWindow = true;
         this.m_TimeArea.hTicks.SetTickModulosForFrameRate(30f);
     }
     if (this.styles == null)
     {
         this.styles = new Styles();
     }
 }
Пример #9
0
        public void DrawMajorTicks(Rect position, float frameRate)
        {
            Color color = Handles.color;

            GUI.BeginGroup(position);
            if (Event.current.type != EventType.Repaint)
            {
                GUI.EndGroup();
            }
            else
            {
                TimeArea.InitStyles();
                this.SetTickMarkerRanges();
                this.hTicks.SetTickStrengths(3f, 80f, true);
                Color textColor = TimeArea.styles.timelineTick.normal.textColor;
                textColor.a   = 0.1f;
                Handles.color = textColor;
                Rect shownArea = base.shownArea;
                for (int i = 0; i < this.hTicks.tickLevels; i++)
                {
                    float num = this.hTicks.GetStrengthOfLevel(i) * 0.9f;
                    if (num > 0.5f)
                    {
                        float[] ticksAtLevel = this.hTicks.GetTicksAtLevel(i, true);
                        for (int j = 0; j < ticksAtLevel.Length; j++)
                        {
                            if (ticksAtLevel[j] >= 0f)
                            {
                                int   num2 = Mathf.RoundToInt(ticksAtLevel[j] * frameRate);
                                float x    = this.FrameToPixel((float)num2, frameRate, position, shownArea);
                                Handles.DrawLine(new Vector3(x, 0f, 0f), new Vector3(x, position.height, 0f));
                            }
                        }
                    }
                }
                GUI.EndGroup();
                Handles.color = color;
            }
        }
Пример #10
0
        public void DrawMajorTicks(Rect position, float frameRate)
        {
            Color color = Handles.color;

            GUI.BeginGroup(position);
            if (Event.current.type != EventType.Repaint)
            {
                GUI.EndGroup();
            }
            else
            {
                TimeArea.InitStyles();
                this.SetTickMarkerRanges();
                this.hTicks.SetTickStrengths(3f, 80f, true);
                Color textColor = TimeArea.styles.TimelineTick.normal.textColor;
                textColor.a   = 0.1f;
                Handles.color = textColor;
                for (int level = 0; level < this.hTicks.tickLevels; ++level)
                {
                    if ((double)(this.hTicks.GetStrengthOfLevel(level) * 0.9f) > 0.5)
                    {
                        float[] ticksAtLevel = this.hTicks.GetTicksAtLevel(level, true);
                        for (int index = 0; index < ticksAtLevel.Length; ++index)
                        {
                            if ((double)ticksAtLevel[index] >= 0.0)
                            {
                                float pixel = this.FrameToPixel((float)Mathf.RoundToInt(ticksAtLevel[index] * frameRate), frameRate, position);
                                Handles.DrawLine(new Vector3(pixel, 0.0f, 0.0f), new Vector3(pixel, position.height, 0.0f));
                            }
                        }
                    }
                }
                GUI.EndGroup();
                Handles.color = color;
            }
        }
Пример #11
0
        public override void Initialize(TimeArea timeArea)
        {
            base.Initialize(timeArea);
            m_DopeSheetEditor = timeArea as DopeSheetEditor;
            m_State           = m_DopeSheetEditor.state;

            if (m_SelectionBoxes == null)
            {
                m_SelectionBoxes = new AreaManipulator[2];

                for (int i = 0; i < 2; ++i)
                {
                    m_SelectionBoxes[i] = new AreaManipulator(styles.rectangleToolSelection, MouseCursor.MoveArrow);

                    m_SelectionBoxes[i].onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                    {
                        bool curveEditorOverride = evt.shift || EditorGUI.actionKey;
                        if (!curveEditorOverride && hasSelection && manipulator.rect.Contains(evt.mousePosition))
                        {
                            OnStartMove(new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0.0f), rippleTimeClutch);
                            return(true);
                        }

                        return(false);
                    };
                    m_SelectionBoxes[i].onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                    {
                        OnMove(new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0.0f));
                        return(true);
                    };
                    m_SelectionBoxes[i].onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                    {
                        OnEndMove();
                        return(true);
                    };
                }
            }

            if (m_SelectionScaleLeft == null)
            {
                m_SelectionScaleLeft = new AreaManipulator(styles.dopesheetScaleLeft, MouseCursor.ResizeHorizontal);

                m_SelectionScaleLeft.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Right, ToolCoord.Left, new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0f), rippleTimeClutch);
                        return(true);
                    }

                    return(false);
                };
                m_SelectionScaleLeft.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnScaleTime(PixelToTime(evt.mousePosition.x, frameRate));
                    return(true);
                };
                m_SelectionScaleLeft.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndScale();
                    return(true);
                };
            }

            if (m_SelectionScaleRight == null)
            {
                m_SelectionScaleRight = new AreaManipulator(styles.dopesheetScaleRight, MouseCursor.ResizeHorizontal);

                m_SelectionScaleRight.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Left, ToolCoord.Right, new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0f), rippleTimeClutch);
                        return(true);
                    }

                    return(false);
                };
                m_SelectionScaleRight.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnScaleTime(PixelToTime(evt.mousePosition.x, frameRate));
                    return(true);
                };
                m_SelectionScaleRight.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndScale();
                    return(true);
                };
            }
        }
Пример #12
0
 private void Init()
 {
   if (this.id == -1)
     this.id = GUIUtility.GetPermanentControlID();
   if (this.m_TimeArea == null)
   {
     this.m_TimeArea = new TimeArea(false);
     this.m_TimeArea.hRangeLocked = false;
     this.m_TimeArea.vRangeLocked = true;
     this.m_TimeArea.hSlider = false;
     this.m_TimeArea.vSlider = false;
     this.m_TimeArea.margin = 10f;
     this.m_TimeArea.scaleWithWindow = true;
     this.m_TimeArea.hTicks.SetTickModulosForFrameRate(30f);
   }
   if (this.styles != null)
     return;
   this.styles = new Timeline.Styles();
 }
Пример #13
0
 public virtual void Initialize(TimeArea timeArea)
 {
     this.m_TimeArea = timeArea;
     if (this.m_Styles == null)
     {
         this.m_Styles = new Styles();
     }
 }
Пример #14
0
        public void TimeRuler(Rect position, float frameRate)
        {
            Color color = GUI.color;

            GUI.BeginGroup(position);
            if (Event.current.type != EventType.Repaint)
            {
                GUI.EndGroup();
                return;
            }
            TimeArea.InitStyles();
            HandleUtility.ApplyWireMaterial();
            GL.Begin(1);
            Color backgroundColor = GUI.backgroundColor;

            this.SetTickMarkerRanges();
            this.hTicks.SetTickStrengths(3f, 80f, true);
            Color textColor = TimeArea.styles.TimelineTick.normal.textColor;

            textColor.a = 0.75f;
            for (int i = 0; i < this.hTicks.tickLevels; i++)
            {
                float   num          = this.hTicks.GetStrengthOfLevel(i) * 0.9f;
                float[] ticksAtLevel = this.hTicks.GetTicksAtLevel(i, true);
                for (int j = 0; j < ticksAtLevel.Length; j++)
                {
                    if (ticksAtLevel[j] >= base.hRangeMin && ticksAtLevel[j] <= base.hRangeMax)
                    {
                        int   num2 = Mathf.RoundToInt(ticksAtLevel[j] * frameRate);
                        float num3 = position.height * Mathf.Min(1f, num) * 0.7f;
                        float num4 = this.FrameToPixel((float)num2, frameRate, position);
                        GL.Color(new Color(1f, 1f, 1f, num / 0.5f) * textColor);
                        GL.Vertex(new Vector3(num4, position.height - num3 + 0.5f, 0f));
                        GL.Vertex(new Vector3(num4, position.height - 0.5f, 0f));
                        if (num > 0.5f)
                        {
                            GL.Color(new Color(1f, 1f, 1f, num / 0.5f - 1f) * textColor);
                            GL.Vertex(new Vector3(num4 + 1f, position.height - num3 + 0.5f, 0f));
                            GL.Vertex(new Vector3(num4 + 1f, position.height - 0.5f, 0f));
                        }
                    }
                }
            }
            GL.End();
            int levelWithMinSeparation = this.hTicks.GetLevelWithMinSeparation(40f);

            float[] ticksAtLevel2 = this.hTicks.GetTicksAtLevel(levelWithMinSeparation, false);
            for (int k = 0; k < ticksAtLevel2.Length; k++)
            {
                if (ticksAtLevel2[k] >= base.hRangeMin && ticksAtLevel2[k] <= base.hRangeMax)
                {
                    int    num5 = Mathf.RoundToInt(ticksAtLevel2[k] * frameRate);
                    float  num6 = Mathf.Floor(this.FrameToPixel((float)num5, frameRate, base.rect));
                    string text = this.FormatFrame(num5, frameRate);
                    GUI.Label(new Rect(num6 + 3f, -3f, 40f, 20f), text, TimeArea.styles.TimelineTick);
                }
            }
            GUI.EndGroup();
            GUI.backgroundColor = backgroundColor;
            GUI.color           = color;
        }
Пример #15
0
        public void TimeRuler(Rect position, float frameRate, bool labels, bool useEntireHeight, float alpha, TimeArea.TimeFormat timeFormat)
        {
            Color color = GUI.color;

            GUI.BeginGroup(position);
            TimeArea.InitStyles();
            HandleUtility.ApplyWireMaterial();
            Color backgroundColor = GUI.backgroundColor;

            this.SetTickMarkerRanges();
            this.hTicks.SetTickStrengths(3f, 80f, true);
            Color textColor = TimeArea.styles.timelineTick.normal.textColor;

            textColor.a = 0.75f * alpha;
            if (Event.current.type == EventType.Repaint)
            {
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    GL.Begin(7);
                }
                else
                {
                    GL.Begin(1);
                }
                Rect shownArea = base.shownArea;
                for (int i = 0; i < this.hTicks.tickLevels; i++)
                {
                    float   num          = this.hTicks.GetStrengthOfLevel(i) * 0.9f;
                    float[] ticksAtLevel = this.hTicks.GetTicksAtLevel(i, true);
                    for (int j = 0; j < ticksAtLevel.Length; j++)
                    {
                        if (ticksAtLevel[j] >= base.hRangeMin && ticksAtLevel[j] <= base.hRangeMax)
                        {
                            int   num2 = Mathf.RoundToInt(ticksAtLevel[j] * frameRate);
                            float num3 = (!useEntireHeight) ? (position.height * Mathf.Min(1f, num) * 0.7f) : position.height;
                            float x    = this.FrameToPixel((float)num2, frameRate, position, shownArea);
                            TimeArea.DrawVerticalLineFast(x, position.height - num3 + 0.5f, position.height - 0.5f, new Color(1f, 1f, 1f, num / 0.5f) * textColor);
                        }
                    }
                }
                GL.End();
            }
            if (labels)
            {
                int     levelWithMinSeparation = this.hTicks.GetLevelWithMinSeparation(40f);
                float[] ticksAtLevel2          = this.hTicks.GetTicksAtLevel(levelWithMinSeparation, false);
                for (int k = 0; k < ticksAtLevel2.Length; k++)
                {
                    if (ticksAtLevel2[k] >= base.hRangeMin && ticksAtLevel2[k] <= base.hRangeMax)
                    {
                        int    num4 = Mathf.RoundToInt(ticksAtLevel2[k] * frameRate);
                        float  num5 = Mathf.Floor(this.FrameToPixel((float)num4, frameRate, position));
                        string text = this.FormatTime(ticksAtLevel2[k], frameRate, timeFormat);
                        GUI.Label(new Rect(num5 + 3f, -3f, 40f, 20f), text, TimeArea.styles.timelineTick);
                    }
                }
            }
            GUI.EndGroup();
            GUI.backgroundColor = backgroundColor;
            GUI.color           = color;
        }
 public override void Initialize(TimeArea timeArea)
 {
     base.Initialize(timeArea);
     this.m_CurveEditor = timeArea as CurveEditor;
     if (this.m_HBarLeft == null)
     {
         this.m_HBarLeft = new AreaManipulator(base.styles.rectangleToolHBarLeft, MouseCursor.ResizeHorizontal);
         this.m_HBarLeft.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_HBarLeft.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Right, RectangleTool.ToolCoord.Left, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), DragMode.ScaleHorizontal, base.rippleTimeClutch);
                 return true;
             }
             return false;
         });
         this.m_HBarLeft.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_HBarLeft.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return true;
         });
         this.m_HBarLeft.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_HBarLeft.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return true;
         });
     }
     if (this.m_HBarRight == null)
     {
         this.m_HBarRight = new AreaManipulator(base.styles.rectangleToolHBarRight, MouseCursor.ResizeHorizontal);
         this.m_HBarRight.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_HBarRight.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Left, RectangleTool.ToolCoord.Right, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), DragMode.ScaleHorizontal, base.rippleTimeClutch);
                 return true;
             }
             return false;
         });
         this.m_HBarRight.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_HBarRight.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return true;
         });
         this.m_HBarRight.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_HBarRight.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return true;
         });
     }
     if (this.m_HBar == null)
     {
         this.m_HBar = new AreaManipulator(base.styles.rectangleToolHBar, MouseCursor.MoveArrow);
         this.m_HBar.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_HBar.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), DragMode.MoveHorizontal, base.rippleTimeClutch);
                 return true;
             }
             return false;
         });
         this.m_HBar.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_HBar.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f));
             return true;
         });
         this.m_HBar.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_HBar.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndMove();
             return true;
         });
     }
     if (this.m_VBarBottom == null)
     {
         this.m_VBarBottom = new AreaManipulator(base.styles.rectangleToolVBarBottom, MouseCursor.ResizeVertical);
         this.m_VBarBottom.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_VBarBottom.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Top, RectangleTool.ToolCoord.Bottom, new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), DragMode.ScaleVertical, false);
                 return true;
             }
             return false;
         });
         this.m_VBarBottom.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_VBarBottom.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleValue(base.PixelToValue(evt.mousePosition.y));
             return true;
         });
         this.m_VBarBottom.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_VBarBottom.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return true;
         });
     }
     if (this.m_VBarTop == null)
     {
         this.m_VBarTop = new AreaManipulator(base.styles.rectangleToolVBarTop, MouseCursor.ResizeVertical);
         this.m_VBarTop.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_VBarTop.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Bottom, RectangleTool.ToolCoord.Top, new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), DragMode.ScaleVertical, false);
                 return true;
             }
             return false;
         });
         this.m_VBarTop.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_VBarTop.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleValue(base.PixelToValue(evt.mousePosition.y));
             return true;
         });
         this.m_VBarTop.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_VBarTop.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return true;
         });
     }
     if (this.m_VBar == null)
     {
         this.m_VBar = new AreaManipulator(base.styles.rectangleToolVBar, MouseCursor.MoveArrow);
         this.m_VBar.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_VBar.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartMove(new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), DragMode.MoveVertical, false);
                 return true;
             }
             return false;
         });
         this.m_VBar.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_VBar.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnMove(new Vector2(0f, base.PixelToValue(evt.mousePosition.y)));
             return true;
         });
         this.m_VBar.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_VBar.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndMove();
             return true;
         });
     }
     if (this.m_SelectionBox == null)
     {
         this.m_SelectionBox = new AreaManipulator(base.styles.rectangleToolSelection, MouseCursor.MoveArrow);
         this.m_SelectionBox.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionBox.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             bool flag = evt.shift || EditorGUI.actionKey;
             if ((!(Mathf.Approximately(this.selectionBounds.size.x, 0f) && Mathf.Approximately(this.selectionBounds.size.y, 0f)) && !flag) && (this.hasSelection && manipulator.rect.Contains(evt.mousePosition)))
             {
                 this.OnStartMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), base.PixelToValue(evt.mousePosition.y)), !base.rippleTimeClutch ? DragMode.MoveBothAxis : DragMode.MoveHorizontal, base.rippleTimeClutch);
                 return true;
             }
             return false;
         });
         this.m_SelectionBox.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionBox.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), base.PixelToValue(evt.mousePosition.y)));
             return true;
         });
         this.m_SelectionBox.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionBox.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndMove();
             return true;
         });
     }
     if (this.m_SelectionScaleLeft == null)
     {
         this.m_SelectionScaleLeft = new AreaManipulator(base.styles.rectangleToolScaleLeft, MouseCursor.ResizeHorizontal);
         this.m_SelectionScaleLeft.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Right, RectangleTool.ToolCoord.Left, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), DragMode.ScaleHorizontal, base.rippleTimeClutch);
                 return true;
             }
             return false;
         });
         this.m_SelectionScaleLeft.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return true;
         });
         this.m_SelectionScaleLeft.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return true;
         });
     }
     if (this.m_SelectionScaleRight == null)
     {
         this.m_SelectionScaleRight = new AreaManipulator(base.styles.rectangleToolScaleRight, MouseCursor.ResizeHorizontal);
         this.m_SelectionScaleRight.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Left, RectangleTool.ToolCoord.Right, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), DragMode.ScaleHorizontal, base.rippleTimeClutch);
                 return true;
             }
             return false;
         });
         this.m_SelectionScaleRight.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return true;
         });
         this.m_SelectionScaleRight.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return true;
         });
     }
     if (this.m_SelectionScaleBottom == null)
     {
         this.m_SelectionScaleBottom = new AreaManipulator(base.styles.rectangleToolScaleBottom, MouseCursor.ResizeVertical);
         this.m_SelectionScaleBottom.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleBottom.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Top, RectangleTool.ToolCoord.Bottom, new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), DragMode.ScaleVertical, false);
                 return true;
             }
             return false;
         });
         this.m_SelectionScaleBottom.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleBottom.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleValue(base.PixelToValue(evt.mousePosition.y));
             return true;
         });
         this.m_SelectionScaleBottom.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleBottom.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return true;
         });
     }
     if (this.m_SelectionScaleTop == null)
     {
         this.m_SelectionScaleTop = new AreaManipulator(base.styles.rectangleToolScaleTop, MouseCursor.ResizeVertical);
         this.m_SelectionScaleTop.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleTop.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Bottom, RectangleTool.ToolCoord.Top, new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), DragMode.ScaleVertical, false);
                 return true;
             }
             return false;
         });
         this.m_SelectionScaleTop.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleTop.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleValue(base.PixelToValue(evt.mousePosition.y));
             return true;
         });
         this.m_SelectionScaleTop.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleTop.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return true;
         });
     }
 }
Пример #17
0
        public void DoTimeControl(Rect rect)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            var evt = Event.current;
            int id  = EditorGUIUtility.GetControlID(kScrubberIDHash, FocusType.Keyboard);

            // Play/Pause Button + Scrubber
            Rect timelineRect = rect;

            timelineRect.height = kScrubberHeight;
            // Only Scrubber
            Rect scrubberRect = timelineRect;

            scrubberRect.xMin += kPlayButtonWidth;

            // Handle Input
            switch (evt.GetTypeForControl(id))
            {
            case EventType.MouseDown:
                if (rect.Contains(evt.mousePosition))
                {
                    EditorGUIUtility.keyboardControl = id;
                }
                if (scrubberRect.Contains(evt.mousePosition))
                {
                    EditorGUIUtility.SetWantsMouseJumping(1);
                    EditorGUIUtility.hotControl = id;
                    m_MouseDrag       = evt.mousePosition.x - scrubberRect.xMin;
                    nextCurrentTime   = (m_MouseDrag * (stopTime - startTime) / scrubberRect.width + startTime);
                    m_WrapForwardDrag = false;
                    evt.Use();
                }
                break;

            case EventType.MouseDrag:
                if (EditorGUIUtility.hotControl == id)
                {
                    m_MouseDrag += evt.delta.x * playbackSpeed;
                    // We want to not wrap if we immediately drag to the beginning, but we do want to wrap if we drag past the end.
                    if (loop && ((m_MouseDrag < 0.0f && m_WrapForwardDrag) || (m_MouseDrag > scrubberRect.width)))
                    {
                        // scrubing out of range was generating a big deltaTime in wrong time direction
                        // this new code prevent this and it is compliant with new and more robust v5.0 root motion looping of animation clip
                        if (m_MouseDrag > scrubberRect.width)
                        {
                            currentTime -= (stopTime - startTime);
                        }
                        else if (m_MouseDrag < 0)
                        {
                            currentTime += (stopTime - startTime);
                        }

                        m_WrapForwardDrag = true;
                        m_MouseDrag       = Mathf.Repeat(m_MouseDrag, scrubberRect.width);
                    }
                    nextCurrentTime = (Mathf.Clamp(m_MouseDrag, 0.0f, scrubberRect.width) * (stopTime - startTime) / scrubberRect.width + startTime);
                    evt.Use();
                }
                break;

            case EventType.MouseUp:
                if (EditorGUIUtility.hotControl == id)
                {
                    EditorGUIUtility.SetWantsMouseJumping(0);
                    EditorGUIUtility.hotControl = 0;
                    evt.Use();
                }
                break;

            case EventType.KeyDown:
                if (EditorGUIUtility.keyboardControl == id)
                {
                    // TODO: loop?
                    if (evt.keyCode == KeyCode.LeftArrow)
                    {
                        if (currentTime - startTime > kStepTime)
                        {
                            deltaTime = -kStepTime;
                        }
                        evt.Use();
                    }
                    if (evt.keyCode == KeyCode.RightArrow)
                    {
                        if (stopTime - currentTime > kStepTime)
                        {
                            deltaTime = kStepTime;
                        }
                        evt.Use();
                    }
                }
                break;
            }

            // background
            GUI.Box(timelineRect, GUIContent.none, s_Styles.timeScrubber);

            // Play/Pause Button
            playing = GUI.Toggle(timelineRect, playing, playing ? s_Styles.pauseIcon : s_Styles.playIcon, s_Styles.playButton);

            // Current time indicator
            float normalizedPosition = Mathf.Lerp(scrubberRect.x, scrubberRect.xMax, normalizedTime);

            TimeArea.DrawPlayhead(normalizedPosition, scrubberRect.yMin, scrubberRect.yMax, 2f, (EditorGUIUtility.keyboardControl == id) ? 1f : 0.5f);
        }
Пример #18
0
        public void DoTimeControl(Rect rect)
        {
            if (TimeControl.s_Styles == null)
            {
                TimeControl.s_Styles = new TimeControl.Styles();
            }
            Event current   = Event.current;
            int   controlID = GUIUtility.GetControlID(TimeControl.kScrubberIDHash, FocusType.Keyboard);
            Rect  rect2     = rect;

            rect2.height = 21f;
            Rect rect3 = rect2;

            rect3.xMin += 33f;
            switch (current.GetTypeForControl(controlID))
            {
            case EventType.MouseDown:
                if (rect.Contains(current.mousePosition))
                {
                    GUIUtility.keyboardControl = controlID;
                }
                if (rect3.Contains(current.mousePosition))
                {
                    EditorGUIUtility.SetWantsMouseJumping(1);
                    GUIUtility.hotControl  = controlID;
                    this.m_MouseDrag       = current.mousePosition.x - rect3.xMin;
                    this.nextCurrentTime   = this.m_MouseDrag * (this.stopTime - this.startTime) / rect3.width + this.startTime;
                    this.m_WrapForwardDrag = false;
                    current.Use();
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == controlID)
                {
                    EditorGUIUtility.SetWantsMouseJumping(0);
                    GUIUtility.hotControl = 0;
                    current.Use();
                }
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == controlID)
                {
                    this.m_MouseDrag += current.delta.x * this.playbackSpeed;
                    if (this.loop && ((this.m_MouseDrag < 0f && this.m_WrapForwardDrag) || this.m_MouseDrag > rect3.width))
                    {
                        if (this.m_MouseDrag > rect3.width)
                        {
                            this.currentTime -= this.stopTime - this.startTime;
                        }
                        else if (this.m_MouseDrag < 0f)
                        {
                            this.currentTime += this.stopTime - this.startTime;
                        }
                        this.m_WrapForwardDrag = true;
                        this.m_MouseDrag       = Mathf.Repeat(this.m_MouseDrag, rect3.width);
                    }
                    this.nextCurrentTime = Mathf.Clamp(this.m_MouseDrag, 0f, rect3.width) * (this.stopTime - this.startTime) / rect3.width + this.startTime;
                    current.Use();
                }
                break;

            case EventType.KeyDown:
                if (GUIUtility.keyboardControl == controlID)
                {
                    if (current.keyCode == KeyCode.LeftArrow)
                    {
                        if (this.currentTime - this.startTime > 0.01f)
                        {
                            this.deltaTime = -0.01f;
                        }
                        current.Use();
                    }
                    if (current.keyCode == KeyCode.RightArrow)
                    {
                        if (this.stopTime - this.currentTime > 0.01f)
                        {
                            this.deltaTime = 0.01f;
                        }
                        current.Use();
                    }
                }
                break;
            }
            GUI.Box(rect2, GUIContent.none, TimeControl.s_Styles.timeScrubber);
            this.playing = GUI.Toggle(rect2, this.playing, (!this.playing) ? TimeControl.s_Styles.playIcon : TimeControl.s_Styles.pauseIcon, TimeControl.s_Styles.playButton);
            float x = Mathf.Lerp(rect3.x, rect3.xMax, this.normalizedTime);

            TimeArea.DrawPlayhead(x, rect3.yMin, rect3.yMax, 2f, (GUIUtility.keyboardControl != controlID) ? 0.5f : 1f);
        }
 public override void Initialize(TimeArea timeArea)
 {
     base.Initialize(timeArea);
     this.m_DopeSheetEditor = timeArea as DopeSheetEditor;
     this.m_State           = this.m_DopeSheetEditor.state;
     if (this.m_SelectionBoxes == null)
     {
         this.m_SelectionBoxes = new AreaManipulator[2];
         for (int i = 0; i < 2; i++)
         {
             this.m_SelectionBoxes[i] = new AreaManipulator(base.styles.rectangleToolSelection, MouseCursor.MoveArrow);
             AreaManipulator manipulator1 = this.m_SelectionBoxes[i];
             manipulator1.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(manipulator1.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
                 if ((!(evt.shift || EditorGUI.actionKey) && this.hasSelection) && manipulator.rect.Contains(evt.mousePosition))
                 {
                     this.OnStartMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                     return(true);
                 }
                 return(false);
             });
             AreaManipulator manipulator2 = this.m_SelectionBoxes[i];
             manipulator2.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(manipulator2.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
                 this.OnMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f));
                 return(true);
             });
             AreaManipulator manipulator3 = this.m_SelectionBoxes[i];
             manipulator3.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(manipulator3.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
                 this.OnEndMove();
                 return(true);
             });
         }
     }
     if (this.m_SelectionScaleLeft == null)
     {
         this.m_SelectionScaleLeft             = new AreaManipulator(base.styles.dopesheetScaleLeft, MouseCursor.ResizeHorizontal);
         this.m_SelectionScaleLeft.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Right, RectangleTool.ToolCoord.Left, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                 return(true);
             }
             return(false);
         });
         this.m_SelectionScaleLeft.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         });
         this.m_SelectionScaleLeft.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return(true);
         });
     }
     if (this.m_SelectionScaleRight == null)
     {
         this.m_SelectionScaleRight             = new AreaManipulator(base.styles.dopesheetScaleRight, MouseCursor.ResizeHorizontal);
         this.m_SelectionScaleRight.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Left, RectangleTool.ToolCoord.Right, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                 return(true);
             }
             return(false);
         });
         this.m_SelectionScaleRight.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         });
         this.m_SelectionScaleRight.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return(true);
         });
     }
 }
Пример #20
0
 public static void SyncTimeArea(TimeArea from, TimeArea to)
 {
     to.SetDrawRectHack(from.drawRect);
     to.m_Scale = new Vector2(from.m_Scale.x, to.m_Scale.y);
     to.m_Translation = new Vector2(from.m_Translation.x, to.m_Translation.y);
     to.EnforceScaleAndRange();
 }
Пример #21
0
 public EventManipulationHandler(TimeArea timeArea)
 {
     this.m_Timeline = timeArea;
 }
Пример #22
0
        public override void Initialize(TimeArea timeArea)
        {
            base.Initialize(timeArea);
            m_CurveEditor = timeArea as CurveEditor;

            if (m_HBarLeft == null)
            {
                m_HBarLeft = new AreaManipulator(styles.rectangleToolHBarLeft, MouseCursor.ResizeHorizontal);

                m_HBarLeft.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Right, ToolCoord.Left, new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0f), DragMode.ScaleHorizontal, rippleTimeClutch);
                        return(true);
                    }

                    return(false);
                };
                m_HBarLeft.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnScaleTime(PixelToTime(evt.mousePosition.x, frameRate));
                    return(true);
                };
                m_HBarLeft.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndScale();
                    return(true);
                };
            }

            if (m_HBarRight == null)
            {
                m_HBarRight = new AreaManipulator(styles.rectangleToolHBarRight, MouseCursor.ResizeHorizontal);

                m_HBarRight.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Left, ToolCoord.Right, new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0f), DragMode.ScaleHorizontal, rippleTimeClutch);
                        return(true);
                    }

                    return(false);
                };
                m_HBarRight.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnScaleTime(PixelToTime(evt.mousePosition.x, frameRate));
                    return(true);
                };
                m_HBarRight.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndScale();
                    return(true);
                };
            }

            if (m_HBar == null)
            {
                m_HBar = new AreaManipulator(styles.rectangleToolHBar, MouseCursor.MoveArrow);

                m_HBar.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartMove(new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0f), DragMode.MoveHorizontal, rippleTimeClutch);
                        return(true);
                    }

                    return(false);
                };
                m_HBar.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnMove(new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0f));
                    return(true);
                };
                m_HBar.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndMove();
                    return(true);
                };
            }

            if (m_VBarBottom == null)
            {
                m_VBarBottom = new AreaManipulator(styles.rectangleToolVBarBottom, MouseCursor.ResizeVertical);

                m_VBarBottom.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Top, ToolCoord.Bottom, new Vector2(0f, PixelToValue(evt.mousePosition.y)), DragMode.ScaleVertical, false);
                        return(true);
                    }

                    return(false);
                };
                m_VBarBottom.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnScaleValue(PixelToValue(evt.mousePosition.y));
                    return(true);
                };
                m_VBarBottom.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndScale();
                    return(true);
                };
            }

            if (m_VBarTop == null)
            {
                m_VBarTop = new AreaManipulator(styles.rectangleToolVBarTop, MouseCursor.ResizeVertical);

                m_VBarTop.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Bottom, ToolCoord.Top, new Vector2(0f, PixelToValue(evt.mousePosition.y)), DragMode.ScaleVertical, false);
                        return(true);
                    }

                    return(false);
                };
                m_VBarTop.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnScaleValue(PixelToValue(evt.mousePosition.y));
                    return(true);
                };
                m_VBarTop.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndScale();
                    return(true);
                };
            }

            if (m_VBar == null)
            {
                m_VBar = new AreaManipulator(styles.rectangleToolVBar, MouseCursor.MoveArrow);

                m_VBar.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartMove(new Vector2(0f, PixelToValue(evt.mousePosition.y)), DragMode.MoveVertical, false);
                        return(true);
                    }

                    return(false);
                };
                m_VBar.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnMove(new Vector2(0f, PixelToValue(evt.mousePosition.y)));
                    return(true);
                };
                m_VBar.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndMove();
                    return(true);
                };
            }

            if (m_SelectionBox == null)
            {
                m_SelectionBox = new AreaManipulator(styles.rectangleToolSelection, MouseCursor.MoveArrow);

                m_SelectionBox.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    bool curveEditorOverride = evt.shift || EditorGUI.actionKey;
                    if (!curveEditorOverride && hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartMove(new Vector2(PixelToTime(evt.mousePosition.x, frameRate), PixelToValue(evt.mousePosition.y)), rippleTimeClutch ? DragMode.MoveHorizontal : DragMode.MoveBothAxis, rippleTimeClutch);
                        return(true);
                    }

                    return(false);
                };
                m_SelectionBox.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    // Only drag along x OR y when shift is held down
                    if (evt.shift && m_DragMode == DragMode.MoveBothAxis)
                    {
                        float deltaX = evt.mousePosition.x - TimeToPixel(m_Previous.x);
                        float deltaY = evt.mousePosition.y - ValueToPixel(m_Previous.y);
                        m_DragMode = Mathf.Abs(deltaX) > Mathf.Abs(deltaY) ? DragMode.MoveHorizontal : DragMode.MoveVertical;
                    }

                    float posX = ((m_DragMode & DragMode.MoveHorizontal) != 0) ? PixelToTime(evt.mousePosition.x, frameRate) : m_Previous.x;
                    float posY = ((m_DragMode & DragMode.MoveVertical) != 0) ? PixelToValue(evt.mousePosition.y) : m_Previous.y;

                    OnMove(new Vector2(posX, posY));
                    return(true);
                };
                m_SelectionBox.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndMove();
                    return(true);
                };
            }

            if (m_SelectionScaleLeft == null)
            {
                m_SelectionScaleLeft = new AreaManipulator(styles.rectangleToolScaleLeft, MouseCursor.ResizeHorizontal);

                m_SelectionScaleLeft.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Right, ToolCoord.Left, new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0f), DragMode.ScaleHorizontal, rippleTimeClutch);
                        return(true);
                    }

                    return(false);
                };
                m_SelectionScaleLeft.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnScaleTime(PixelToTime(evt.mousePosition.x, frameRate));
                    return(true);
                };
                m_SelectionScaleLeft.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndScale();
                    return(true);
                };
            }

            if (m_SelectionScaleRight == null)
            {
                m_SelectionScaleRight = new AreaManipulator(styles.rectangleToolScaleRight, MouseCursor.ResizeHorizontal);

                m_SelectionScaleRight.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Left, ToolCoord.Right, new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0f), DragMode.ScaleHorizontal, rippleTimeClutch);
                        return(true);
                    }

                    return(false);
                };
                m_SelectionScaleRight.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnScaleTime(PixelToTime(evt.mousePosition.x, frameRate));
                    return(true);
                };
                m_SelectionScaleRight.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndScale();
                    return(true);
                };
            }

            if (m_SelectionScaleBottom == null)
            {
                m_SelectionScaleBottom = new AreaManipulator(styles.rectangleToolScaleBottom, MouseCursor.ResizeVertical);

                m_SelectionScaleBottom.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Top, ToolCoord.Bottom, new Vector2(0f, PixelToValue(evt.mousePosition.y)), DragMode.ScaleVertical, false);
                        return(true);
                    }

                    return(false);
                };
                m_SelectionScaleBottom.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnScaleValue(PixelToValue(evt.mousePosition.y));
                    return(true);
                };
                m_SelectionScaleBottom.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndScale();
                    return(true);
                };
            }

            if (m_SelectionScaleTop == null)
            {
                m_SelectionScaleTop = new AreaManipulator(styles.rectangleToolScaleTop, MouseCursor.ResizeVertical);

                m_SelectionScaleTop.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Bottom, ToolCoord.Top, new Vector2(0f, PixelToValue(evt.mousePosition.y)), DragMode.ScaleVertical, false);
                        return(true);
                    }

                    return(false);
                };
                m_SelectionScaleTop.onDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnScaleValue(PixelToValue(evt.mousePosition.y));
                    return(true);
                };
                m_SelectionScaleTop.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) =>
                {
                    OnEndScale();
                    return(true);
                };
            }
        }
		private void OnEnable()
		{
			if (AnimationClipEditor.styles == null)
			{
				AnimationClipEditor.styles = new AnimationClipEditor.Styles();
			}
			this.m_Clip = (this.target as AnimationClip);
			if (this.m_TimeArea == null)
			{
				this.m_TimeArea = new TimeArea(true);
				this.m_TimeArea.hRangeLocked = false;
				this.m_TimeArea.vRangeLocked = true;
				this.m_TimeArea.hSlider = true;
				this.m_TimeArea.vSlider = false;
				this.m_TimeArea.hRangeMin = this.m_Clip.startTime;
				this.m_TimeArea.hRangeMax = this.m_Clip.stopTime;
				this.m_TimeArea.margin = 10f;
				this.m_TimeArea.scaleWithWindow = true;
				this.m_TimeArea.SetShownHRangeInsideMargins(this.m_Clip.startTime, this.m_Clip.stopTime);
				this.m_TimeArea.hTicks.SetTickModulosForFrameRate(this.m_Clip.frameRate);
				this.m_TimeArea.ignoreScrollWheelUntilClicked = true;
			}
			this.m_TimeArea.OnEnable();
			if (this.m_EventTimeArea == null)
			{
				this.m_EventTimeArea = new TimeArea(true);
				this.m_EventTimeArea.hRangeLocked = true;
				this.m_EventTimeArea.vRangeLocked = true;
				this.m_EventTimeArea.hSlider = false;
				this.m_EventTimeArea.vSlider = false;
				this.m_EventTimeArea.hRangeMin = 0f;
				this.m_EventTimeArea.hRangeMax = AnimationClipEditor.s_EventTimelineMax;
				this.m_EventTimeArea.margin = 10f;
				this.m_EventTimeArea.scaleWithWindow = true;
				this.m_EventTimeArea.SetShownHRangeInsideMargins(0f, AnimationClipEditor.s_EventTimelineMax);
				this.m_EventTimeArea.hTicks.SetTickModulosForFrameRate(60f);
				this.m_EventTimeArea.ignoreScrollWheelUntilClicked = true;
			}
			this.m_EventTimeArea.OnEnable();
			if (this.m_EventManipulationHandler == null)
			{
				this.m_EventManipulationHandler = new EventManipulationHandler(this.m_EventTimeArea);
			}
		}
Пример #24
0
        public bool DoTimeline(Rect timeRect)
        {
            bool result = false;

            this.Init();
            this.m_Rect = timeRect;
            float num  = this.m_TimeArea.PixelToTime(timeRect.xMin, timeRect);
            float num2 = this.m_TimeArea.PixelToTime(timeRect.xMax, timeRect);

            if (!Mathf.Approximately(num, this.StartTime))
            {
                this.StartTime = num;
                GUI.changed    = true;
            }
            if (!Mathf.Approximately(num2, this.StopTime))
            {
                this.StopTime = num2;
                GUI.changed   = true;
            }
            this.Time = Mathf.Max(this.Time, 0f);
            if (Event.current.type == EventType.Repaint)
            {
                this.m_TimeArea.rect = timeRect;
            }
            this.m_TimeArea.BeginViewGUI();
            this.m_TimeArea.EndViewGUI();
            GUI.BeginGroup(timeRect);
            Event current   = Event.current;
            Rect  rect      = new Rect(0f, 0f, timeRect.width, timeRect.height);
            Rect  position  = new Rect(0f, 0f, timeRect.width, 18f);
            Rect  position2 = new Rect(0f, 18f, timeRect.width, 132f);
            float num3      = this.m_TimeArea.TimeToPixel(this.SrcStartTime, rect);
            float num4      = this.m_TimeArea.TimeToPixel(this.SrcStopTime, rect);
            float num5      = this.m_TimeArea.TimeToPixel(this.DstStartTime, rect) + this.m_DstDragOffset;
            float num6      = this.m_TimeArea.TimeToPixel(this.DstStopTime, rect) + this.m_DstDragOffset;
            float num7      = this.m_TimeArea.TimeToPixel(this.TransitionStartTime, rect) + this.m_LeftThumbOffset;
            float num8      = this.m_TimeArea.TimeToPixel(this.TransitionStopTime, rect) + this.m_RightThumbOffset;
            float num9      = this.m_TimeArea.TimeToPixel(this.Time, rect);
            Rect  rect2     = new Rect(num3, 85f, num4 - num3, 32f);
            Rect  rect3     = new Rect(num5, 117f, num6 - num5, 32f);
            Rect  position3 = new Rect(num7, 0f, num8 - num7, 18f);
            Rect  position4 = new Rect(num7, 18f, num8 - num7, rect.height - 18f);
            Rect  position5 = new Rect(num7 - 9f, 5f, 9f, 15f);
            Rect  position6 = new Rect(num8, 5f, 9f, 15f);
            Rect  position7 = new Rect(num9 - 7f, 4f, 15f, 15f);

            if (current.type == EventType.KeyDown)
            {
                if (GUIUtility.keyboardControl == this.id && this.m_DragState == Timeline.DragStates.Destination)
                {
                    this.m_DstDragOffset = 0f;
                }
                if (this.m_DragState == Timeline.DragStates.LeftSelection)
                {
                    this.m_LeftThumbOffset = 0f;
                }
                if (this.m_DragState == Timeline.DragStates.RightSelection)
                {
                    this.m_RightThumbOffset = 0f;
                }
                if (this.m_DragState == Timeline.DragStates.FullSelection)
                {
                    this.m_LeftThumbOffset  = 0f;
                    this.m_RightThumbOffset = 0f;
                }
            }
            if (current.type == EventType.MouseDown)
            {
                if (rect.Contains(current.mousePosition))
                {
                    GUIUtility.hotControl      = this.id;
                    GUIUtility.keyboardControl = this.id;
                    if (position7.Contains(current.mousePosition))
                    {
                        this.m_DragState = Timeline.DragStates.Playhead;
                    }
                    else if (rect2.Contains(current.mousePosition))
                    {
                        this.m_DragState = Timeline.DragStates.Source;
                    }
                    else if (rect3.Contains(current.mousePosition))
                    {
                        this.m_DragState = Timeline.DragStates.Destination;
                    }
                    else if (position5.Contains(current.mousePosition))
                    {
                        this.m_DragState = Timeline.DragStates.LeftSelection;
                    }
                    else if (position6.Contains(current.mousePosition))
                    {
                        this.m_DragState = Timeline.DragStates.RightSelection;
                    }
                    else if (position3.Contains(current.mousePosition))
                    {
                        this.m_DragState = Timeline.DragStates.FullSelection;
                    }
                    else if (position.Contains(current.mousePosition))
                    {
                        this.m_DragState = Timeline.DragStates.TimeArea;
                    }
                    else if (position2.Contains(current.mousePosition))
                    {
                        this.m_DragState = Timeline.DragStates.TimeArea;
                    }
                    else
                    {
                        this.m_DragState = Timeline.DragStates.None;
                    }
                    current.Use();
                }
            }
            if (current.type == EventType.MouseDrag)
            {
                if (GUIUtility.hotControl == this.id)
                {
                    switch (this.m_DragState)
                    {
                    case Timeline.DragStates.LeftSelection:
                        if ((current.delta.x > 0f && current.mousePosition.x > num3) || (current.delta.x < 0f && current.mousePosition.x < num8))
                        {
                            this.m_LeftThumbOffset += current.delta.x;
                        }
                        this.EnforceConstraints();
                        break;

                    case Timeline.DragStates.RightSelection:
                        if ((current.delta.x > 0f && current.mousePosition.x > num7) || current.delta.x < 0f)
                        {
                            this.m_RightThumbOffset += current.delta.x;
                        }
                        this.EnforceConstraints();
                        break;

                    case Timeline.DragStates.FullSelection:
                        this.m_RightThumbOffset += current.delta.x;
                        this.m_LeftThumbOffset  += current.delta.x;
                        this.EnforceConstraints();
                        break;

                    case Timeline.DragStates.Destination:
                        this.m_DstDragOffset += current.delta.x;
                        this.EnforceConstraints();
                        break;

                    case Timeline.DragStates.Source:
                    {
                        TimeArea expr_4A9_cp_0 = this.m_TimeArea;
                        expr_4A9_cp_0.m_Translation.x = expr_4A9_cp_0.m_Translation.x + current.delta.x;
                        break;
                    }

                    case Timeline.DragStates.Playhead:
                        if ((current.delta.x > 0f && current.mousePosition.x > num3) || (current.delta.x < 0f && current.mousePosition.x <= this.m_TimeArea.TimeToPixel(this.SampleStopTime, rect)))
                        {
                            this.Time = this.m_TimeArea.PixelToTime(num9 + current.delta.x, rect);
                        }
                        break;

                    case Timeline.DragStates.TimeArea:
                    {
                        TimeArea expr_4D4_cp_0 = this.m_TimeArea;
                        expr_4D4_cp_0.m_Translation.x = expr_4D4_cp_0.m_Translation.x + current.delta.x;
                        break;
                    }
                    }
                    current.Use();
                    GUI.changed = true;
                }
            }
            if (Event.current.GetTypeForControl(this.id) == EventType.MouseUp)
            {
                this.SrcStartTime        = this.m_TimeArea.PixelToTime(num3, rect);
                this.SrcStopTime         = this.m_TimeArea.PixelToTime(num4, rect);
                this.DstStartTime        = this.m_TimeArea.PixelToTime(num5, rect);
                this.DstStopTime         = this.m_TimeArea.PixelToTime(num6, rect);
                this.TransitionStartTime = this.m_TimeArea.PixelToTime(num7, rect);
                this.TransitionStopTime  = this.m_TimeArea.PixelToTime(num8, rect);
                GUI.changed             = true;
                this.m_DragState        = Timeline.DragStates.None;
                result                  = this.WasDraggingData();
                this.m_LeftThumbOffset  = 0f;
                this.m_RightThumbOffset = 0f;
                this.m_DstDragOffset    = 0f;
                GUIUtility.hotControl   = 0;
                current.Use();
            }
            GUI.Box(position, GUIContent.none, this.styles.header);
            GUI.Box(position2, GUIContent.none, this.styles.background);
            this.m_TimeArea.DrawMajorTicks(position2, 30f);
            GUIContent content   = EditorGUIUtility.TempContent(this.SrcName);
            int        num10     = (!this.srcLoop) ? 1 : (1 + (int)((num8 - rect2.xMin) / (rect2.xMax - rect2.xMin)));
            Rect       position8 = rect2;

            if (rect2.width < 10f)
            {
                position8 = new Rect(rect2.x, rect2.y, (rect2.xMax - rect2.xMin) * (float)num10, rect2.height);
                num10     = 1;
            }
            for (int i = 0; i < num10; i++)
            {
                GUI.BeginGroup(position8, GUIContent.none, this.styles.leftBlock);
                float num11 = num7 - position8.xMin;
                float num12 = num8 - num7;
                float num13 = position8.xMax - position8.xMin - (num11 + num12);
                if (num11 > 0f)
                {
                    GUI.Box(new Rect(0f, 0f, num11, rect2.height), GUIContent.none, this.styles.onLeft);
                }
                if (num12 > 0f)
                {
                    GUI.Box(new Rect(num11, 0f, num12, rect2.height), GUIContent.none, this.styles.onOff);
                }
                if (num13 > 0f)
                {
                    GUI.Box(new Rect(num11 + num12, 0f, num13, rect2.height), GUIContent.none, this.styles.offRight);
                }
                float b     = 1f;
                float x     = this.styles.block.CalcSize(content).x;
                float num14 = Mathf.Max(0f, num11) - 20f;
                float num15 = num14 + 15f;
                if (num14 < x && num15 > 0f && this.m_DragState == Timeline.DragStates.LeftSelection)
                {
                    b = 0f;
                }
                GUI.EndGroup();
                float a = this.styles.leftBlock.normal.textColor.a;
                if (!Mathf.Approximately(a, b) && Event.current.type == EventType.Repaint)
                {
                    a = Mathf.Lerp(a, b, 0.1f);
                    this.styles.leftBlock.normal.textColor = new Color(this.styles.leftBlock.normal.textColor.r, this.styles.leftBlock.normal.textColor.g, this.styles.leftBlock.normal.textColor.b, a);
                    HandleUtility.Repaint();
                }
                GUI.Box(position8, content, this.styles.leftBlock);
                position8 = new Rect(position8.xMax, 85f, position8.xMax - position8.xMin, 32f);
            }
            GUIContent content2 = EditorGUIUtility.TempContent(this.DstName);
            int        num16    = (!this.dstLoop) ? 1 : (1 + (int)((num8 - rect3.xMin) / (rect3.xMax - rect3.xMin)));

            position8 = rect3;
            if (rect3.width < 10f)
            {
                position8 = new Rect(rect3.x, rect3.y, (rect3.xMax - rect3.xMin) * (float)num16, rect3.height);
                num16     = 1;
            }
            for (int j = 0; j < num16; j++)
            {
                GUI.BeginGroup(position8, GUIContent.none, this.styles.rightBlock);
                float num17 = num7 - position8.xMin;
                float num18 = num8 - num7;
                float num19 = position8.xMax - position8.xMin - (num17 + num18);
                if (num17 > 0f)
                {
                    GUI.Box(new Rect(0f, 0f, num17, rect3.height), GUIContent.none, this.styles.offLeft);
                }
                if (num18 > 0f)
                {
                    GUI.Box(new Rect(num17, 0f, num18, rect3.height), GUIContent.none, this.styles.offOn);
                }
                if (num19 > 0f)
                {
                    GUI.Box(new Rect(num17 + num18, 0f, num19, rect3.height), GUIContent.none, this.styles.onRight);
                }
                float b2    = 1f;
                float x2    = this.styles.block.CalcSize(content2).x;
                float num20 = Mathf.Max(0f, num17) - 20f;
                float num21 = num20 + 15f;
                if (num20 < x2 && num21 > 0f && (this.m_DragState == Timeline.DragStates.LeftSelection || this.m_DragState == Timeline.DragStates.Destination))
                {
                    b2 = 0f;
                }
                GUI.EndGroup();
                float a2 = this.styles.rightBlock.normal.textColor.a;
                if (!Mathf.Approximately(a2, b2) && Event.current.type == EventType.Repaint)
                {
                    a2 = Mathf.Lerp(a2, b2, 0.1f);
                    this.styles.rightBlock.normal.textColor = new Color(this.styles.rightBlock.normal.textColor.r, this.styles.rightBlock.normal.textColor.g, this.styles.rightBlock.normal.textColor.b, a2);
                    HandleUtility.Repaint();
                }
                GUI.Box(position8, content2, this.styles.rightBlock);
                position8 = new Rect(position8.xMax, position8.yMin, position8.xMax - position8.xMin, 32f);
            }
            GUI.Box(position4, GUIContent.none, this.styles.select);
            GUI.Box(position3, GUIContent.none, this.styles.selectHead);
            this.m_TimeArea.TimeRuler(position, 30f);
            GUI.Box(position5, GUIContent.none, (!this.m_HasExitTime) ? this.styles.handLeftPrev : this.styles.handLeft);
            GUI.Box(position6, GUIContent.none, this.styles.handRight);
            GUI.Box(position7, GUIContent.none, this.styles.playhead);
            Color color = Handles.color;

            Handles.color = Color.white;
            Handles.DrawLine(new Vector3(num9, 19f, 0f), new Vector3(num9, rect.height, 0f));
            Handles.color = color;
            bool flag  = this.SrcStopTime - this.SrcStartTime < 0.0333333351f;
            bool flag2 = this.DstStopTime - this.DstStartTime < 0.0333333351f;

            if (this.m_DragState == Timeline.DragStates.Destination && !flag2)
            {
                Rect   position9 = new Rect(num7 - 50f, rect3.y, 45f, rect3.height);
                string t         = string.Format("{0:0%}", (num7 - num5) / (num6 - num5));
                GUI.Box(position9, EditorGUIUtility.TempContent(t), this.styles.timeBlockRight);
            }
            if (this.m_DragState == Timeline.DragStates.LeftSelection)
            {
                if (!flag)
                {
                    Rect   position10 = new Rect(num7 - 50f, rect2.y, 45f, rect2.height);
                    string t2         = string.Format("{0:0%}", (num7 - num3) / (num4 - num3));
                    GUI.Box(position10, EditorGUIUtility.TempContent(t2), this.styles.timeBlockRight);
                }
                if (!flag2)
                {
                    Rect   position11 = new Rect(num7 - 50f, rect3.y, 45f, rect3.height);
                    string t3         = string.Format("{0:0%}", (num7 - num5) / (num6 - num5));
                    GUI.Box(position11, EditorGUIUtility.TempContent(t3), this.styles.timeBlockRight);
                }
            }
            if (this.m_DragState == Timeline.DragStates.RightSelection)
            {
                if (!flag)
                {
                    Rect   position12 = new Rect(num8 + 5f, rect2.y, 45f, rect2.height);
                    string t4         = string.Format("{0:0%}", (num8 - num3) / (num4 - num3));
                    GUI.Box(position12, EditorGUIUtility.TempContent(t4), this.styles.timeBlockLeft);
                }
                if (!flag2)
                {
                    Rect   position13 = new Rect(num8 + 5f, rect3.y, 45f, rect3.height);
                    string t5         = string.Format("{0:0%}", (num8 - num5) / (num6 - num5));
                    GUI.Box(position13, EditorGUIUtility.TempContent(t5), this.styles.timeBlockLeft);
                }
            }
            this.DoPivotCurves();
            GUI.EndGroup();
            return(result);
        }
 public EventManipulationHandler(TimeArea timeArea)
 {
   this.m_Timeline = timeArea;
 }
 public override void Initialize(TimeArea timeArea)
 {
     base.Initialize(timeArea);
     this.m_DopeSheetEditor = timeArea as DopeSheetEditor;
     this.m_State = this.m_DopeSheetEditor.state;
     if (this.m_SelectionBoxes == null)
     {
         this.m_SelectionBoxes = new AreaManipulator[2];
         for (int i = 0; i < 2; i++)
         {
             this.m_SelectionBoxes[i] = new AreaManipulator(base.styles.rectangleToolSelection, MouseCursor.MoveArrow);
             AreaManipulator manipulator1 = this.m_SelectionBoxes[i];
             manipulator1.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(manipulator1.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
                 if ((!(evt.shift || EditorGUI.actionKey) && this.hasSelection) && manipulator.rect.Contains(evt.mousePosition))
                 {
                     this.OnStartMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                     return true;
                 }
                 return false;
             });
             AreaManipulator manipulator2 = this.m_SelectionBoxes[i];
             manipulator2.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(manipulator2.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
                 this.OnMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f));
                 return true;
             });
             AreaManipulator manipulator3 = this.m_SelectionBoxes[i];
             manipulator3.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(manipulator3.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
                 this.OnEndMove();
                 return true;
             });
         }
     }
     if (this.m_SelectionScaleLeft == null)
     {
         this.m_SelectionScaleLeft = new AreaManipulator(base.styles.dopesheetScaleLeft, MouseCursor.ResizeHorizontal);
         this.m_SelectionScaleLeft.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Right, RectangleTool.ToolCoord.Left, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                 return true;
             }
             return false;
         });
         this.m_SelectionScaleLeft.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return true;
         });
         this.m_SelectionScaleLeft.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return true;
         });
     }
     if (this.m_SelectionScaleRight == null)
     {
         this.m_SelectionScaleRight = new AreaManipulator(base.styles.dopesheetScaleRight, MouseCursor.ResizeHorizontal);
         this.m_SelectionScaleRight.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onStartDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Left, RectangleTool.ToolCoord.Right, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                 return true;
             }
             return false;
         });
         this.m_SelectionScaleRight.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return true;
         });
         this.m_SelectionScaleRight.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onEndDrag, delegate (AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return true;
         });
     }
 }
 public override void Initialize(TimeArea timeArea)
 {
     base.Initialize(timeArea);
     this.m_DopeSheetEditor = (timeArea as DopeSheetEditor);
     this.m_State           = this.m_DopeSheetEditor.state;
     if (this.m_SelectionBoxes == null)
     {
         this.m_SelectionBoxes = new AreaManipulator[2];
         for (int i = 0; i < 2; i++)
         {
             this.m_SelectionBoxes[i] = new AreaManipulator(base.styles.rectangleToolSelection, MouseCursor.MoveArrow);
             AreaManipulator expr_66 = this.m_SelectionBoxes[i];
             expr_66.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_66.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
             {
                 bool result;
                 if (!evt.shift && !EditorGUI.actionKey && this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
                 {
                     this.OnStartMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                     result = true;
                 }
                 else
                 {
                     result = false;
                 }
                 return(result);
             }));
             AreaManipulator expr_8F = this.m_SelectionBoxes[i];
             expr_8F.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_8F.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
             {
                 this.OnMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f));
                 return(true);
             }));
             AreaManipulator expr_B8 = this.m_SelectionBoxes[i];
             expr_B8.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_B8.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
             {
                 this.OnEndMove();
                 return(true);
             }));
         }
     }
     if (this.m_SelectionScaleLeft == null)
     {
         this.m_SelectionScaleLeft = new AreaManipulator(base.styles.dopesheetScaleLeft, MouseCursor.ResizeHorizontal);
         AreaManipulator expr_10F = this.m_SelectionScaleLeft;
         expr_10F.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_10F.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Right, RectangleTool.ToolCoord.Left, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_136 = this.m_SelectionScaleLeft;
         expr_136.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_136.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         }));
         AreaManipulator expr_15D = this.m_SelectionScaleLeft;
         expr_15D.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_15D.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndScale();
             return(true);
         }));
     }
     if (this.m_SelectionScaleRight == null)
     {
         this.m_SelectionScaleRight = new AreaManipulator(base.styles.dopesheetScaleRight, MouseCursor.ResizeHorizontal);
         AreaManipulator expr_1A8 = this.m_SelectionScaleRight;
         expr_1A8.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_1A8.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Left, RectangleTool.ToolCoord.Right, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_1CF = this.m_SelectionScaleRight;
         expr_1CF.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_1CF.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         }));
         AreaManipulator expr_1F6 = this.m_SelectionScaleRight;
         expr_1F6.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_1F6.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndScale();
             return(true);
         }));
     }
 }
Пример #28
0
 public override void Initialize(TimeArea timeArea)
 {
     base.Initialize(timeArea);
     this.m_CurveEditor = (timeArea as CurveEditor);
     if (this.m_HBarLeft == null)
     {
         this.m_HBarLeft = new AreaManipulator(base.styles.rectangleToolHBarLeft, MouseCursor.ResizeHorizontal);
         AreaManipulator expr_3D = this.m_HBarLeft;
         expr_3D.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_3D.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Right, RectangleTool.ToolCoord.Left, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), CurveEditorRectangleTool.DragMode.ScaleHorizontal, base.rippleTimeClutch);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_64 = this.m_HBarLeft;
         expr_64.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_64.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         }));
         AreaManipulator expr_8B = this.m_HBarLeft;
         expr_8B.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_8B.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndScale();
             return(true);
         }));
     }
     if (this.m_HBarRight == null)
     {
         this.m_HBarRight = new AreaManipulator(base.styles.rectangleToolHBarRight, MouseCursor.ResizeHorizontal);
         AreaManipulator expr_D6 = this.m_HBarRight;
         expr_D6.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_D6.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Left, RectangleTool.ToolCoord.Right, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), CurveEditorRectangleTool.DragMode.ScaleHorizontal, base.rippleTimeClutch);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_FD = this.m_HBarRight;
         expr_FD.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_FD.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         }));
         AreaManipulator expr_124 = this.m_HBarRight;
         expr_124.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_124.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndScale();
             return(true);
         }));
     }
     if (this.m_HBar == null)
     {
         this.m_HBar = new AreaManipulator(base.styles.rectangleToolHBar, MouseCursor.MoveArrow);
         AreaManipulator expr_16F = this.m_HBar;
         expr_16F.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_16F.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), CurveEditorRectangleTool.DragMode.MoveHorizontal, base.rippleTimeClutch);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_196 = this.m_HBar;
         expr_196.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_196.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f));
             return(true);
         }));
         AreaManipulator expr_1BD = this.m_HBar;
         expr_1BD.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_1BD.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndMove();
             return(true);
         }));
     }
     if (this.m_VBarBottom == null)
     {
         this.m_VBarBottom = new AreaManipulator(base.styles.rectangleToolVBarBottom, MouseCursor.ResizeVertical);
         AreaManipulator expr_208 = this.m_VBarBottom;
         expr_208.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_208.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Top, RectangleTool.ToolCoord.Bottom, new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), CurveEditorRectangleTool.DragMode.ScaleVertical, false);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_22F = this.m_VBarBottom;
         expr_22F.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_22F.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnScaleValue(base.PixelToValue(evt.mousePosition.y));
             return(true);
         }));
         AreaManipulator expr_256 = this.m_VBarBottom;
         expr_256.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_256.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndScale();
             return(true);
         }));
     }
     if (this.m_VBarTop == null)
     {
         this.m_VBarTop = new AreaManipulator(base.styles.rectangleToolVBarTop, MouseCursor.ResizeVertical);
         AreaManipulator expr_2A1 = this.m_VBarTop;
         expr_2A1.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_2A1.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Bottom, RectangleTool.ToolCoord.Top, new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), CurveEditorRectangleTool.DragMode.ScaleVertical, false);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_2C8 = this.m_VBarTop;
         expr_2C8.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_2C8.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnScaleValue(base.PixelToValue(evt.mousePosition.y));
             return(true);
         }));
         AreaManipulator expr_2EF = this.m_VBarTop;
         expr_2EF.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_2EF.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndScale();
             return(true);
         }));
     }
     if (this.m_VBar == null)
     {
         this.m_VBar = new AreaManipulator(base.styles.rectangleToolVBar, MouseCursor.MoveArrow);
         AreaManipulator expr_33A = this.m_VBar;
         expr_33A.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_33A.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartMove(new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), CurveEditorRectangleTool.DragMode.MoveVertical, false);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_361 = this.m_VBar;
         expr_361.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_361.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnMove(new Vector2(0f, base.PixelToValue(evt.mousePosition.y)));
             return(true);
         }));
         AreaManipulator expr_388 = this.m_VBar;
         expr_388.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_388.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndMove();
             return(true);
         }));
     }
     if (this.m_SelectionBox == null)
     {
         this.m_SelectionBox = new AreaManipulator(base.styles.rectangleToolSelection, MouseCursor.MoveArrow);
         AreaManipulator expr_3D3 = this.m_SelectionBox;
         expr_3D3.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_3D3.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool flag = evt.shift || EditorGUI.actionKey;
             bool result;
             if ((!Mathf.Approximately(this.selectionBounds.size.x, 0f) || !Mathf.Approximately(this.selectionBounds.size.y, 0f)) && !flag && this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), base.PixelToValue(evt.mousePosition.y)), (!base.rippleTimeClutch) ? CurveEditorRectangleTool.DragMode.MoveBothAxis : CurveEditorRectangleTool.DragMode.MoveHorizontal, base.rippleTimeClutch);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_3FA = this.m_SelectionBox;
         expr_3FA.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_3FA.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), base.PixelToValue(evt.mousePosition.y)));
             return(true);
         }));
         AreaManipulator expr_421 = this.m_SelectionBox;
         expr_421.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_421.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndMove();
             return(true);
         }));
     }
     if (this.m_SelectionScaleLeft == null)
     {
         this.m_SelectionScaleLeft = new AreaManipulator(base.styles.rectangleToolScaleLeft, MouseCursor.ResizeHorizontal);
         AreaManipulator expr_46C = this.m_SelectionScaleLeft;
         expr_46C.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_46C.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Right, RectangleTool.ToolCoord.Left, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), CurveEditorRectangleTool.DragMode.ScaleHorizontal, base.rippleTimeClutch);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_493 = this.m_SelectionScaleLeft;
         expr_493.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_493.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         }));
         AreaManipulator expr_4BA = this.m_SelectionScaleLeft;
         expr_4BA.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_4BA.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndScale();
             return(true);
         }));
     }
     if (this.m_SelectionScaleRight == null)
     {
         this.m_SelectionScaleRight = new AreaManipulator(base.styles.rectangleToolScaleRight, MouseCursor.ResizeHorizontal);
         AreaManipulator expr_505 = this.m_SelectionScaleRight;
         expr_505.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_505.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Left, RectangleTool.ToolCoord.Right, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), CurveEditorRectangleTool.DragMode.ScaleHorizontal, base.rippleTimeClutch);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_52C = this.m_SelectionScaleRight;
         expr_52C.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_52C.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         }));
         AreaManipulator expr_553 = this.m_SelectionScaleRight;
         expr_553.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_553.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndScale();
             return(true);
         }));
     }
     if (this.m_SelectionScaleBottom == null)
     {
         this.m_SelectionScaleBottom = new AreaManipulator(base.styles.rectangleToolScaleBottom, MouseCursor.ResizeVertical);
         AreaManipulator expr_59E = this.m_SelectionScaleBottom;
         expr_59E.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_59E.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Top, RectangleTool.ToolCoord.Bottom, new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), CurveEditorRectangleTool.DragMode.ScaleVertical, false);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_5C5 = this.m_SelectionScaleBottom;
         expr_5C5.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_5C5.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnScaleValue(base.PixelToValue(evt.mousePosition.y));
             return(true);
         }));
         AreaManipulator expr_5EC = this.m_SelectionScaleBottom;
         expr_5EC.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_5EC.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndScale();
             return(true);
         }));
     }
     if (this.m_SelectionScaleTop == null)
     {
         this.m_SelectionScaleTop = new AreaManipulator(base.styles.rectangleToolScaleTop, MouseCursor.ResizeVertical);
         AreaManipulator expr_637 = this.m_SelectionScaleTop;
         expr_637.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_637.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Bottom, RectangleTool.ToolCoord.Top, new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), CurveEditorRectangleTool.DragMode.ScaleVertical, false);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_65E = this.m_SelectionScaleTop;
         expr_65E.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_65E.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnScaleValue(base.PixelToValue(evt.mousePosition.y));
             return(true);
         }));
         AreaManipulator expr_685 = this.m_SelectionScaleTop;
         expr_685.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_685.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndScale();
             return(true);
         }));
     }
 }
Пример #29
0
        public TimeArea.TimeRulerDragMode BrowseRuler(Rect position, int id, ref float time, float frameRate, bool pickAnywhere, GUIStyle thumbStyle)
        {
            Event current   = Event.current;
            Rect  position1 = position;

            if ((double)time != -1.0)
            {
                position1.x     = Mathf.Round(this.TimeToPixel(time, position)) - (float)thumbStyle.overflow.left;
                position1.width = thumbStyle.fixedWidth + (float)thumbStyle.overflow.horizontal;
            }
            switch (current.GetTypeForControl(id))
            {
            case EventType.MouseDown:
                if (position1.Contains(current.mousePosition))
                {
                    GUIUtility.hotControl = id;
                    TimeArea.s_PickOffset = current.mousePosition.x - this.TimeToPixel(time, position);
                    current.Use();
                    return(TimeArea.TimeRulerDragMode.Start);
                }
                if (pickAnywhere && position.Contains(current.mousePosition))
                {
                    GUIUtility.hotControl = id;
                    float wholeFps = TimeArea.SnapTimeToWholeFPS(this.PixelToTime(current.mousePosition.x, position), frameRate);
                    TimeArea.s_OriginalTime = time;
                    if ((double)wholeFps != (double)time)
                    {
                        GUI.changed = true;
                    }
                    time = wholeFps;
                    TimeArea.s_PickOffset = 0.0f;
                    current.Use();
                    return(TimeArea.TimeRulerDragMode.Start);
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == id)
                {
                    GUIUtility.hotControl = 0;
                    current.Use();
                    return(TimeArea.TimeRulerDragMode.End);
                }
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == id)
                {
                    float wholeFps = TimeArea.SnapTimeToWholeFPS(this.PixelToTime(current.mousePosition.x - TimeArea.s_PickOffset, position), frameRate);
                    if ((double)wholeFps != (double)time)
                    {
                        GUI.changed = true;
                    }
                    time = wholeFps;
                    current.Use();
                    return(TimeArea.TimeRulerDragMode.Dragging);
                }
                break;

            case EventType.KeyDown:
                if (GUIUtility.hotControl == id && current.keyCode == KeyCode.Escape)
                {
                    if ((double)time != (double)TimeArea.s_OriginalTime)
                    {
                        GUI.changed = true;
                    }
                    time = TimeArea.s_OriginalTime;
                    GUIUtility.hotControl = 0;
                    current.Use();
                    return(TimeArea.TimeRulerDragMode.Cancel);
                }
                break;

            case EventType.Repaint:
                if ((double)time != -1.0)
                {
                    bool flag = position.Contains(current.mousePosition);
                    position1.x += (float)thumbStyle.overflow.left;
                    thumbStyle.Draw(position1, id == GUIUtility.hotControl, flag || id == GUIUtility.hotControl, false, false);
                    break;
                }
                break;
            }
            return(TimeArea.TimeRulerDragMode.None);
        }
Пример #30
0
 public override void Initialize(TimeArea timeArea)
 {
     base.Initialize(timeArea);
     this.m_CurveEditor = timeArea as CurveEditor;
     if (this.m_HBarLeft == null)
     {
         this.m_HBarLeft             = new AreaManipulator(base.styles.rectangleToolHBarLeft, MouseCursor.ResizeHorizontal);
         this.m_HBarLeft.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_HBarLeft.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Right, RectangleTool.ToolCoord.Left, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), DragMode.ScaleHorizontal, base.rippleTimeClutch);
                 return(true);
             }
             return(false);
         });
         this.m_HBarLeft.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_HBarLeft.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         });
         this.m_HBarLeft.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_HBarLeft.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return(true);
         });
     }
     if (this.m_HBarRight == null)
     {
         this.m_HBarRight             = new AreaManipulator(base.styles.rectangleToolHBarRight, MouseCursor.ResizeHorizontal);
         this.m_HBarRight.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_HBarRight.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Left, RectangleTool.ToolCoord.Right, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), DragMode.ScaleHorizontal, base.rippleTimeClutch);
                 return(true);
             }
             return(false);
         });
         this.m_HBarRight.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_HBarRight.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         });
         this.m_HBarRight.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_HBarRight.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return(true);
         });
     }
     if (this.m_HBar == null)
     {
         this.m_HBar             = new AreaManipulator(base.styles.rectangleToolHBar, MouseCursor.MoveArrow);
         this.m_HBar.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_HBar.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), DragMode.MoveHorizontal, base.rippleTimeClutch);
                 return(true);
             }
             return(false);
         });
         this.m_HBar.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_HBar.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f));
             return(true);
         });
         this.m_HBar.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_HBar.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndMove();
             return(true);
         });
     }
     if (this.m_VBarBottom == null)
     {
         this.m_VBarBottom             = new AreaManipulator(base.styles.rectangleToolVBarBottom, MouseCursor.ResizeVertical);
         this.m_VBarBottom.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_VBarBottom.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Top, RectangleTool.ToolCoord.Bottom, new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), DragMode.ScaleVertical, false);
                 return(true);
             }
             return(false);
         });
         this.m_VBarBottom.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_VBarBottom.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleValue(base.PixelToValue(evt.mousePosition.y));
             return(true);
         });
         this.m_VBarBottom.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_VBarBottom.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return(true);
         });
     }
     if (this.m_VBarTop == null)
     {
         this.m_VBarTop             = new AreaManipulator(base.styles.rectangleToolVBarTop, MouseCursor.ResizeVertical);
         this.m_VBarTop.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_VBarTop.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Bottom, RectangleTool.ToolCoord.Top, new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), DragMode.ScaleVertical, false);
                 return(true);
             }
             return(false);
         });
         this.m_VBarTop.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_VBarTop.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleValue(base.PixelToValue(evt.mousePosition.y));
             return(true);
         });
         this.m_VBarTop.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_VBarTop.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return(true);
         });
     }
     if (this.m_VBar == null)
     {
         this.m_VBar             = new AreaManipulator(base.styles.rectangleToolVBar, MouseCursor.MoveArrow);
         this.m_VBar.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_VBar.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartMove(new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), DragMode.MoveVertical, false);
                 return(true);
             }
             return(false);
         });
         this.m_VBar.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_VBar.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnMove(new Vector2(0f, base.PixelToValue(evt.mousePosition.y)));
             return(true);
         });
         this.m_VBar.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_VBar.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndMove();
             return(true);
         });
     }
     if (this.m_SelectionBox == null)
     {
         this.m_SelectionBox             = new AreaManipulator(base.styles.rectangleToolSelection, MouseCursor.MoveArrow);
         this.m_SelectionBox.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionBox.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             bool flag = evt.shift || EditorGUI.actionKey;
             if ((!(Mathf.Approximately(this.selectionBounds.size.x, 0f) && Mathf.Approximately(this.selectionBounds.size.y, 0f)) && !flag) && (this.hasSelection && manipulator.rect.Contains(evt.mousePosition)))
             {
                 this.OnStartMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), base.PixelToValue(evt.mousePosition.y)), !base.rippleTimeClutch ? DragMode.MoveBothAxis : DragMode.MoveHorizontal, base.rippleTimeClutch);
                 return(true);
             }
             return(false);
         });
         this.m_SelectionBox.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionBox.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), base.PixelToValue(evt.mousePosition.y)));
             return(true);
         });
         this.m_SelectionBox.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionBox.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndMove();
             return(true);
         });
     }
     if (this.m_SelectionScaleLeft == null)
     {
         this.m_SelectionScaleLeft             = new AreaManipulator(base.styles.rectangleToolScaleLeft, MouseCursor.ResizeHorizontal);
         this.m_SelectionScaleLeft.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Right, RectangleTool.ToolCoord.Left, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), DragMode.ScaleHorizontal, base.rippleTimeClutch);
                 return(true);
             }
             return(false);
         });
         this.m_SelectionScaleLeft.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         });
         this.m_SelectionScaleLeft.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return(true);
         });
     }
     if (this.m_SelectionScaleRight == null)
     {
         this.m_SelectionScaleRight             = new AreaManipulator(base.styles.rectangleToolScaleRight, MouseCursor.ResizeHorizontal);
         this.m_SelectionScaleRight.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Left, RectangleTool.ToolCoord.Right, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), DragMode.ScaleHorizontal, base.rippleTimeClutch);
                 return(true);
             }
             return(false);
         });
         this.m_SelectionScaleRight.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         });
         this.m_SelectionScaleRight.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return(true);
         });
     }
     if (this.m_SelectionScaleBottom == null)
     {
         this.m_SelectionScaleBottom             = new AreaManipulator(base.styles.rectangleToolScaleBottom, MouseCursor.ResizeVertical);
         this.m_SelectionScaleBottom.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleBottom.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Top, RectangleTool.ToolCoord.Bottom, new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), DragMode.ScaleVertical, false);
                 return(true);
             }
             return(false);
         });
         this.m_SelectionScaleBottom.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleBottom.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleValue(base.PixelToValue(evt.mousePosition.y));
             return(true);
         });
         this.m_SelectionScaleBottom.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleBottom.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return(true);
         });
     }
     if (this.m_SelectionScaleTop == null)
     {
         this.m_SelectionScaleTop             = new AreaManipulator(base.styles.rectangleToolScaleTop, MouseCursor.ResizeVertical);
         this.m_SelectionScaleTop.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleTop.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Bottom, RectangleTool.ToolCoord.Top, new Vector2(0f, base.PixelToValue(evt.mousePosition.y)), DragMode.ScaleVertical, false);
                 return(true);
             }
             return(false);
         });
         this.m_SelectionScaleTop.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleTop.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleValue(base.PixelToValue(evt.mousePosition.y));
             return(true);
         });
         this.m_SelectionScaleTop.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleTop.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return(true);
         });
     }
 }
        private void DoSliceScrubber(Rect controlRect, Texture2DArray t)
        {
            int id = GUIUtility.GetControlID(kScrubberHash, FocusType.Keyboard);

            Rect prevFrameRect = controlRect;

            prevFrameRect.width = kSliceStepWidth;

            Rect nextFrameRect = prevFrameRect;

            nextFrameRect.x += nextFrameRect.width;

            var scrubberRect = controlRect;

            scrubberRect.xMin = nextFrameRect.xMax;

            var evt = Event.current;

            switch (evt.GetTypeForControl(id))
            {
            case EventType.MouseDown:
            {
                if (scrubberRect.Contains(evt.mousePosition))
                {
                    GUIUtility.keyboardControl = id;
                    GUIUtility.hotControl      = id;
                    m_MouseDrag = evt.mousePosition.x - scrubberRect.xMin;
                    m_Slice     = (int)(m_MouseDrag * t.depth / scrubberRect.width);
                    evt.Use();
                }
                break;
            }

            case EventType.MouseDrag:
            {
                if (GUIUtility.hotControl == id)
                {
                    m_MouseDrag += evt.delta.x;
                    m_Slice      = (int)(Mathf.Clamp(m_MouseDrag, 0.0f, scrubberRect.width) * t.depth /
                                         scrubberRect.width);
                    evt.Use();
                }
                break;
            }

            case EventType.MouseUp:
            {
                if (GUIUtility.hotControl == id)
                {
                    GUIUtility.hotControl = 0;
                    evt.Use();
                }
                break;
            }

            case EventType.KeyDown:
            {
                if (GUIUtility.keyboardControl == id)
                {
                    if (evt.keyCode == KeyCode.LeftArrow)
                    {
                        if (m_Slice > 0)
                        {
                            --m_Slice;
                        }
                        evt.Use();
                    }
                    if (evt.keyCode == KeyCode.RightArrow)
                    {
                        if (m_Slice < t.depth - 1)
                        {
                            ++m_Slice;
                        }
                        evt.Use();
                    }
                }
                break;
            }

            case EventType.Repaint:
            {
                Styles.sliceScrubber.Draw(controlRect, GUIContent.none, id);

                float normalizedPosition = Mathf.Lerp(scrubberRect.x, scrubberRect.xMax, m_Slice / (float)(t.depth - 1));
                TimeArea.DrawPlayhead(normalizedPosition, scrubberRect.yMin, scrubberRect.yMax, 2f,
                                      (GUIUtility.keyboardControl == id) ? 1f : 0.5f);
                break;
            }
            }

            using (new EditorGUI.DisabledGroupScope(m_Slice <= 0))
            {
                if (GUI.Button(prevFrameRect, Styles.prevSliceIcon, Styles.stepSlice))
                {
                    m_Slice--;
                }
            }

            using (new EditorGUI.DisabledGroupScope(m_Slice >= t.depth - 1))
            {
                if (GUI.Button(nextFrameRect, Styles.nextSliceIcon, Styles.stepSlice))
                {
                    m_Slice++;
                }
            }
        }