public override bool CanSelect(Event evt)
        {
            ClipBlends clipBlends = GetClipBlends();
            Vector2    mousePos   = evt.mousePosition - rect.position;

            return(m_ClipCenterSection.Contains(mousePos) || IsPointLocatedInClipBlend(mousePos, clipBlends));
        }
        public static void DrawBorder(Rect centerRect, ClipBorder border, ClipBlends blends, TimelineClip prevClip = null)
        {
            var thickness = border.thickness;
            var color     = border.color;

            // Draw top selected lines.
            EditorGUI.DrawRect(new Rect(centerRect.xMin, centerRect.yMin, centerRect.width, thickness), color);

            // Draw bottom selected lines.
            EditorGUI.DrawRect(new Rect(centerRect.xMin, centerRect.yMax - thickness, centerRect.width, thickness), color);

            // Draw Left Selected Lines
            if (blends.inKind == BlendKind.None)
            {
                EditorGUI.DrawRect(new Rect(centerRect.xMin, centerRect.yMin, thickness, centerRect.height), color);
            }
            else
            {
                var mixInRect = blends.inRect;

                if (blends.inKind == BlendKind.Ease)
                {
                    EditorGUI.DrawRect(new Rect(mixInRect.xMin, mixInRect.yMax - thickness, mixInRect.width, thickness), color);

                    EditorGUI.DrawRect(new Rect(mixInRect.xMin, mixInRect.yMin, thickness, mixInRect.height), color);

                    Graphics.DrawLineAA(2.0f * thickness, new Vector3(mixInRect.xMin, mixInRect.yMax - 1f, 0), new Vector3(mixInRect.xMax, mixInRect.yMin + 1f, 0), color);
                }
                else if (blends.inKind == BlendKind.Mix)
                {
                    EditorGUI.DrawRect(new Rect(mixInRect.xMin, mixInRect.yMin, mixInRect.width, thickness), color);

                    // If there's another clip in the left, draw the blend.
                    if (prevClip != null && SelectionManager.Contains(prevClip))
                    {
                        EditorGUI.DrawRect(new Rect(mixInRect.xMin, mixInRect.yMax - thickness, mixInRect.width, thickness), color); //  Bottom
                    }
                    Graphics.DrawLineAA(2.0f * thickness, new Vector3(mixInRect.xMin, mixInRect.yMin + 1f, 0), new Vector3(mixInRect.xMax, mixInRect.yMax - 1f, 0), color);
                }
            }

            // Draw Right Selected Lines
            if (blends.outKind == BlendKind.None)
            {
                EditorGUI.DrawRect(new Rect(centerRect.xMax - thickness, centerRect.yMin, thickness, centerRect.height), color);
            }
            else
            {
                var mixOutRect = blends.outRect;
                EditorGUI.DrawRect(new Rect(mixOutRect.xMin, mixOutRect.yMax - thickness, mixOutRect.width, thickness), color);

                if (blends.outKind == BlendKind.Ease)
                {
                    EditorGUI.DrawRect(new Rect(mixOutRect.xMax - thickness, mixOutRect.yMin, thickness, mixOutRect.height), color);
                }

                Graphics.DrawLineAA(2.0f * thickness, new Vector3(mixOutRect.xMin, mixOutRect.yMin + 1f, 0), new Vector3(mixOutRect.xMax, mixOutRect.yMax - 1f, 0), color);
            }
        }
Exemple #3
0
        static void DrawClipBlendSelectionBorder(Rect clipRect, ClipBorder border, ClipBlends blends)
        {
            var color     = border.color;
            var thickness = border.thickness;

            if (blends.inKind == BlendKind.Mix)
            {
                DrawBlendLine(blends.inRect, BlendAngle.Descending, thickness, color);
                var xBottom1 = blends.inRect.xMin;
                var xBottom2 = blends.inRect.xMax;
                EditorGUI.DrawRect(new Rect(xBottom1, clipRect.max.y - thickness, xBottom2 - xBottom1, thickness), color);
            }
        }
        static bool IsPointLocatedInClipBlend(Vector2 pt, ClipBlends blends)
        {
            if (blends.inRect.Contains(pt))
            {
                return(Sign(pt, blends.inRect.min, blends.inRect.max) < 0);
            }

            if (blends.outRect.Contains(pt))
            {
                return(Sign(pt, blends.outRect.min, blends.outRect.max) >= 0);
            }

            return(false);
        }
        public override bool CanSelect()
        {
            ClipBlends clipBlends = GetClipBlends();

            //clips that do not overlap are always selectable
            if (clipBlends.inKind != BlendKind.Mix && clipBlends.outKind != BlendKind.Mix)
            {
                return(true);
            }

            Vector2 mousePos = Event.current.mousePosition - rect.position;

            return(m_ClipCenterSection.Contains(mousePos) || IsPointLocatedInClipBlend(mousePos, clipBlends));
        }
        static void DrawClipBlends(ClipBlends blends, Color inColor, Color outColor, Color backgroundColor)
        {
            switch (blends.inKind)
            {
            case BlendKind.Ease:
                //     2
                //   / |
                //  /  |
                // 0---1
                EditorGUI.DrawRect(blends.inRect, backgroundColor);
                s_BlendVertices[0] = new Vector3(blends.inRect.xMin, blends.inRect.yMax);
                s_BlendVertices[1] = new Vector3(blends.inRect.xMax, blends.inRect.yMax);
                s_BlendVertices[2] = new Vector3(blends.inRect.xMax, blends.inRect.yMin);
                Graphics.DrawPolygonAA(inColor, s_BlendVertices);
                break;

            case BlendKind.Mix:
                // 0---2
                //  \  |
                //   \ |
                //     1
                s_BlendVertices[0] = new Vector3(blends.inRect.xMin, blends.inRect.yMin);
                s_BlendVertices[1] = new Vector3(blends.inRect.xMax, blends.inRect.yMax);
                s_BlendVertices[2] = new Vector3(blends.inRect.xMax, blends.inRect.yMin);
                Graphics.DrawPolygonAA(inColor, s_BlendVertices);
                break;
            }

            if (blends.outKind != BlendKind.None)
            {
                if (blends.outKind == BlendKind.Ease)
                {
                    EditorGUI.DrawRect(blends.outRect, backgroundColor);
                }
                // 0
                // | \
                // |  \
                // 1---2
                s_BlendVertices[0] = new Vector3(blends.outRect.xMin, blends.outRect.yMin);
                s_BlendVertices[1] = new Vector3(blends.outRect.xMin, blends.outRect.yMax);
                s_BlendVertices[2] = new Vector3(blends.outRect.xMax, blends.outRect.yMax);
                Graphics.DrawPolygonAA(outColor, s_BlendVertices);
            }
        }
        public static void DrawClipSelectionBorder(Rect clipRect, ClipBorder border, ClipBlends blends)
        {
            var thickness = border.thickness;
            var color     = border.color;
            var min       = clipRect.min;
            var max       = clipRect.max;

            //Left line
            if (blends.inKind == BlendKind.None)
            {
                EditorGUI.DrawRect(new Rect(min.x, min.y, thickness, max.y - min.y), color);
            }
            else
            {
                DrawBlendLine(blends.inRect, blends.inKind == BlendKind.Mix ? BlendAngle.Descending : BlendAngle.Ascending, thickness, color);
            }

            //Right line
            if (blends.outKind == BlendKind.None)
            {
                EditorGUI.DrawRect(new Rect(max.x - thickness, min.y, thickness, max.y - min.y), color);
            }
            else
            {
                DrawBlendLine(blends.outRect, BlendAngle.Descending, thickness, color);
            }

            //Top line
            var xTop1 = blends.inKind == BlendKind.Mix ? blends.inRect.xMin : min.x;
            var xTop2 = max.x;

            EditorGUI.DrawRect(new Rect(xTop1, min.y, xTop2 - xTop1, thickness), color);

            //Bottom line
            var xBottom1 = blends.inKind == BlendKind.Ease ? blends.inRect.xMin : min.x;
            var xBottom2 = blends.outKind == BlendKind.None ? max.x : blends.outRect.xMax;

            EditorGUI.DrawRect(new Rect(xBottom1, max.y - thickness, xBottom2 - xBottom1, thickness), color);
        }
Exemple #8
0
        static void DrawClipBorder(ClipDrawData drawData, ClipBlends blends)
        {
            var clipGUI = drawData.uiClip;

            ClipBorder border = null;

            var animTrack = drawData.clip.parentTrack as AnimationTrack;

            if (drawData.state.recording && animTrack == null && drawData.clip.parentTrack.IsRecordingToClip(drawData.clip))
            {
                border = ClipBorder.kRecording;
            }
            else if (drawData.selected)
            {
                border = ClipBorder.kSelection;
            }

            if (border != null)
            {
                DrawBorder(clipGUI.clipCenterSection, border, blends, drawData.previousClip);
            }
        }
        static void DrawClipDefaultBorder(Rect clipRect, ClipBorder border, ClipBlends blends)
        {
            var color     = border.color;
            var thickness = border.thickness;

            // Draw vertical lines at the edges of the clip
            EditorGUI.DrawRect(new Rect(clipRect.xMin, clipRect.y, thickness, clipRect.height), color); //left
            //only draw the right one when no out mix blend
            if (blends.outKind != BlendKind.Mix)
            {
                EditorGUI.DrawRect(new Rect(clipRect.xMax - thickness, clipRect.y, thickness, clipRect.height), color); //right
            }
            //draw a vertical line for the previous clip
            if (blends.inKind == BlendKind.Mix)
            {
                EditorGUI.DrawRect(new Rect(blends.inRect.xMin, blends.inRect.y, thickness, blends.inRect.height), color); //left
            }
            //Draw blend line
            if (blends.inKind == BlendKind.Mix)
            {
                DrawBlendLine(blends.inRect, BlendAngle.Descending, thickness, color);
            }
        }
        public static void DrawSimpleClip(TimelineClip clip, Rect targetRect, ClipBorder border, Color overlay, ClipDrawOptions drawOptions, ClipBlends blends)
        {
            GUI.BeginClip(targetRect);

            var clipRect = new Rect(0.0f, 0.0f, targetRect.width, targetRect.height);

            var orgColor = GUI.color;

            GUI.color = overlay;

            DrawClipBackground(clipRect, ClipBlends.kNone, false);
            GUI.color = orgColor;

            if (clipRect.width <= k_MinClipWidth)
            {
                clipRect.width = k_MinClipWidth;
            }

            DrawClipEdges(clipRect, drawOptions.highlightColor * overlay, s_InlineLightColor * overlay, s_InlineShadowColor * overlay,
                          blends.inKind != BlendKind.Mix, blends.outKind != BlendKind.Mix);

            DrawClipTimescale(clipRect, clip.timeScale);

            if (targetRect.width >= k_ClipInOutMinWidth)
            {
                DrawClipInOut(clipRect, clip);
            }

            var textRect = clipRect;

            textRect.xMin += k_ClipLabelPadding;
            textRect.xMax -= k_ClipLabelPadding;

            if (textRect.width > k_ClipLabelMinWidth)
            {
                DrawClipLabel(clip.displayName, textRect, Color.white, drawOptions.errorText);
            }

            if (border != null)
            {
                DrawBorder(clipRect, border, ClipBlends.kNone);
            }

            GUI.EndClip();
        }
        static void DrawClipBackground(Rect clipCenterSection, ClipBlends blends, bool selected)
        {
            var clipStyle = selected ? DirectorStyles.Instance.timelineClipSelected : DirectorStyles.Instance.timelineClip;

            var texture   = clipStyle.normal.background;
            var lineColor = DirectorStyles.Instance.customSkin.colorClipBlendLines;

            // Center body
            GUI.Label(clipCenterSection, GUIContent.none, clipStyle);

            // Blend/Mix In
            if (blends.inKind != BlendKind.None)
            {
                var mixInRect = blends.inRect;

                if (blends.inKind == BlendKind.Ease)
                {
                    ClipRenderer.RenderTexture(mixInRect, texture, DirectorStyles.Instance.blendMixIn.normal.background, Color.black);

                    if (!selected)
                    {
                        Graphics.DrawLineAA(2.5f, new Vector3(mixInRect.xMin, mixInRect.yMax - 1f, 0), new Vector3(mixInRect.xMax, mixInRect.yMin + 1f, 0), lineColor);
                    }
                }
                else
                {
                    var blendInColor = selected ? Color.black : DirectorStyles.Instance.customSkin.colorClipBlendYin;
                    ClipRenderer.RenderTexture(mixInRect, texture, DirectorStyles.Instance.blendEaseIn.normal.background, blendInColor);

                    if (!selected)
                    {
                        Graphics.DrawLineAA(2.0f, new Vector3(mixInRect.xMin, mixInRect.yMin + 1f, 0), new Vector3(mixInRect.xMax, mixInRect.yMax - 1f, 0), lineColor);
                    }
                }

                Graphics.DrawLineAA(2.0f, mixInRect.max, new Vector2(mixInRect.xMax, mixInRect.yMin), lineColor);
            }

            // Blend/Mix Out
            if (blends.outKind != BlendKind.None)
            {
                var mixOutRect = blends.outRect;

                if (blends.outKind == BlendKind.Ease)
                {
                    ClipRenderer.RenderTexture(mixOutRect, texture, DirectorStyles.Instance.blendMixOut.normal.background, Color.black);

                    if (!selected)
                    {
                        Graphics.DrawLineAA(2.5f, new Vector3(mixOutRect.xMin, mixOutRect.yMin + 1f, 0), new Vector3(mixOutRect.xMax, mixOutRect.yMax - 1f, 0), lineColor);
                    }
                }
                else
                {
                    var blendOutColor = selected ? Color.black : DirectorStyles.Instance.customSkin.colorClipBlendYang;
                    ClipRenderer.RenderTexture(mixOutRect, texture, DirectorStyles.Instance.blendEaseOut.normal.background, blendOutColor);

                    if (!selected)
                    {
                        Graphics.DrawLineAA(2.0f, new Vector3(mixOutRect.xMin, mixOutRect.yMin + 1f, 0), new Vector3(mixOutRect.xMax, mixOutRect.yMax - 1f, 0), lineColor);
                    }
                }

                Graphics.DrawLineAA(2.0f, mixOutRect.min, new Vector2(mixOutRect.xMin, mixOutRect.yMax), lineColor);
            }
        }
Exemple #12
0
        public static void DrawDefaultClip(ClipDrawData drawData, ClipDrawing drawing, ClipBlends blends)
        {
            DrawClipBackground(drawData.clipCenterSection, blends, drawData.selected);

            if (drawData.targetRect.width > k_MinClipWidth)
            {
                var customBodyRect = drawData.clippedRect;
                customBodyRect.yMin += k_ClipInlineWidth;
                customBodyRect.yMax -= k_ClipSwatchLineThickness;

                // TODO: Remove this when clip editors land
                if (drawData.trackDrawer != null)
                {
                    drawData.trackDrawer.DrawCustomClipBody(drawData, customBodyRect);
                }
            }
            else
            {
                drawData.targetRect.width        = k_MinClipWidth;
                drawData.clipCenterSection.width = k_MinClipWidth;
            }

            DrawClipEdges(drawData.targetRect, drawing.highlightColor, s_InlineLightColor, s_InlineShadowColor,
                          drawData.uiClip.blendInKind != BlendKind.Mix,
                          drawData.uiClip.blendOutKind != BlendKind.Mix);

            DrawClipTimescale(drawData.targetRect, drawData.clip.timeScale);

            if (drawData.targetRect.width >= k_ClipInOutMinWidth)
            {
                DrawClipInOut(drawData.targetRect, drawData.clip);
            }

            var labelRect = drawData.clipCenterSection;

            if (drawData.targetRect.width >= k_ClipLoopsMinWidth)
            {
                bool selected = drawData.selected || drawData.inlineCurvesSelected;

                if (selected)
                {
                    if (drawData.uiClip.loopRects != null && drawData.uiClip.loopRects.Any())
                    {
                        DrawLoops(drawData);

                        var l = drawData.uiClip.loopRects[0];
                        labelRect.xMax = Math.Min(labelRect.xMax, l.x - drawData.unclippedRect.x);
                    }
                }
            }

            labelRect.xMin += k_ClipLabelPadding;
            labelRect.xMax -= k_ClipLabelPadding;

            if (labelRect.width > k_ClipLabelMinWidth)
            {
                DrawClipLabel(drawData, labelRect, Color.white, drawing.errorText);
            }

            DrawClipBorder(drawData, blends);
        }