Exemple #1
0
        public void OverlayOnGUI()
        {
            if (!hasSelection)
            {
                return;
            }

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            Color oldColor = GUI.color;

            RectangleToolFlags flags = m_CurveEditor.settings.rectangleToolFlags;

            if (flags == RectangleToolFlags.FullRectangleTool)
            {
                GUI.color = Color.white;

                m_HBar.OnGUI(m_Layout.hBarRect);
                m_HBarLeft.OnGUI(m_Layout.hBarLeftRect);
                m_HBarRight.OnGUI(m_Layout.hBarRightRect);

                m_VBar.OnGUI(m_Layout.vBarRect);
                m_VBarBottom.OnGUI(m_Layout.vBarBottomRect);
                m_VBarTop.OnGUI(m_Layout.vBarTopRect);
            }

            DrawLabels();

            GUI.color = oldColor;
        }
Exemple #2
0
        public void HandleEvents()
        {
            RectangleToolFlags flags = m_CurveEditor.settings.rectangleToolFlags;

            if (flags == RectangleToolFlags.NoRectangleTool)
            {
                return;
            }

            m_SelectionScaleTop.HandleEvents();
            m_SelectionScaleBottom.HandleEvents();

            if (rippleTime)
            {
                m_SelectionRippleLeft.HandleEvents();
                m_SelectionRippleRight.HandleEvents();
            }
            else
            {
                m_SelectionScaleLeft.HandleEvents();
                m_SelectionScaleRight.HandleEvents();
            }

            m_SelectionBox.HandleEvents();
        }
Exemple #3
0
        public void OnGUI()
        {
            if (!hasSelection)
            {
                return;
            }

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            RectangleToolFlags flags = m_CurveEditor.settings.rectangleToolFlags;

            if (flags == RectangleToolFlags.NoRectangleTool)
            {
                return;
            }

            Color oldColor = GUI.color;

            GUI.color = Color.white;

            m_Layout = CalculateLayout();

            if (flags == RectangleToolFlags.FullRectangleTool)
            {
                GUI.Label(m_Layout.selectionLeftRect, GUIContent.none, styles.rectangleToolHighlight);
                GUI.Label(m_Layout.selectionTopRect, GUIContent.none, styles.rectangleToolHighlight);
                GUI.Label(m_Layout.underlayLeftRect, GUIContent.none, styles.rectangleToolHighlight);
                GUI.Label(m_Layout.underlayTopRect, GUIContent.none, styles.rectangleToolHighlight);
            }

            m_SelectionBox.OnGUI(m_Layout.selectionRect);

            m_SelectionScaleTop.OnGUI(m_Layout.scaleTopRect);
            m_SelectionScaleBottom.OnGUI(m_Layout.scaleBottomRect);

            bool showRippleHandles = (rippleTime && dragMode == DragMode.None) || (m_RippleTime && dragMode != DragMode.None);

            if (showRippleHandles)
            {
                m_SelectionRippleLeft.OnGUI(m_Layout.scaleLeftRect);
                m_SelectionRippleRight.OnGUI(m_Layout.scaleRightRect);
            }
            else
            {
                m_SelectionScaleLeft.OnGUI(m_Layout.scaleLeftRect);
                m_SelectionScaleRight.OnGUI(m_Layout.scaleRightRect);
            }

            GUI.color = oldColor;
        }
Exemple #4
0
        public void HandleOverlayEvents()
        {
            RectangleToolFlags flags = m_CurveEditor.settings.rectangleToolFlags;

            if (flags == RectangleToolFlags.NoRectangleTool)
            {
                return;
            }

            if (flags == RectangleToolFlags.FullRectangleTool)
            {
                m_VBarBottom.HandleEvents();
                m_VBarTop.HandleEvents();
                m_VBar.HandleEvents();

                m_HBarLeft.HandleEvents();
                m_HBarRight.HandleEvents();
                m_HBar.HandleEvents();
            }
        }
Exemple #5
0
        private void DrawLabels()
        {
            if (dragMode == DragMode.None)
            {
                return;
            }

            RectangleToolFlags flags = m_CurveEditor.settings.rectangleToolFlags;

            bool canScaleX = !Mathf.Approximately(selectionBounds.size.x, 0f);
            bool canScaleY = !Mathf.Approximately(selectionBounds.size.y, 0f);

            if (flags == RectangleToolFlags.FullRectangleTool)
            {
                // Horizontal labels
                if ((dragMode & DragMode.MoveScaleHorizontal) != 0)
                {
                    if (canScaleX)
                    {
                        GUIContent leftLabelContent  = new GUIContent(string.Format("{0}", m_CurveEditor.FormatTime(selectionBounds.min.x, m_CurveEditor.invSnap, m_CurveEditor.timeFormat)));
                        GUIContent rightLabelContent = new GUIContent(string.Format("{0}", m_CurveEditor.FormatTime(selectionBounds.max.x, m_CurveEditor.invSnap, m_CurveEditor.timeFormat)));

                        Vector2 leftLabelSize  = styles.dragLabel.CalcSize(leftLabelContent);
                        Vector2 rightLabelSize = styles.dragLabel.CalcSize(rightLabelContent);

                        EditorGUI.DoDropShadowLabel(new Rect(m_Layout.leftLabelAnchor.x - leftLabelSize.x, m_Layout.leftLabelAnchor.y, leftLabelSize.x, leftLabelSize.y), leftLabelContent, styles.dragLabel, 0.3f);
                        EditorGUI.DoDropShadowLabel(new Rect(m_Layout.rightLabelAnchor.x, m_Layout.rightLabelAnchor.y, rightLabelSize.x, rightLabelSize.y), rightLabelContent, styles.dragLabel, 0.3f);
                    }
                    else
                    {
                        GUIContent labelContent = new GUIContent(string.Format("{0}", m_CurveEditor.FormatTime(selectionBounds.center.x, m_CurveEditor.invSnap, m_CurveEditor.timeFormat)));
                        Vector2    labelSize    = styles.dragLabel.CalcSize(labelContent);

                        EditorGUI.DoDropShadowLabel(new Rect(m_Layout.leftLabelAnchor.x, m_Layout.leftLabelAnchor.y, labelSize.x, labelSize.y), labelContent, styles.dragLabel, 0.3f);
                    }
                }

                // Vertical labels
                if ((dragMode & DragMode.MoveScaleVertical) != 0)
                {
                    if (canScaleY)
                    {
                        GUIContent bottomLabelContent = new GUIContent(string.Format("{0}", m_CurveEditor.FormatValue(selectionBounds.min.y)));
                        GUIContent topLabelContent    = new GUIContent(string.Format("{0}", m_CurveEditor.FormatValue(selectionBounds.max.y)));

                        Vector2 bottomLabelSize = styles.dragLabel.CalcSize(bottomLabelContent);
                        Vector2 topLabelSize    = styles.dragLabel.CalcSize(topLabelContent);

                        EditorGUI.DoDropShadowLabel(new Rect(m_Layout.bottomLabelAnchor.x, m_Layout.bottomLabelAnchor.y, bottomLabelSize.x, bottomLabelSize.y), bottomLabelContent, styles.dragLabel, 0.3f);
                        EditorGUI.DoDropShadowLabel(new Rect(m_Layout.topLabelAnchor.x, m_Layout.topLabelAnchor.y - topLabelSize.y, topLabelSize.x, topLabelSize.y), topLabelContent, styles.dragLabel, 0.3f);
                    }
                    else
                    {
                        GUIContent labelContent = new GUIContent(string.Format("{0}", m_CurveEditor.FormatValue(selectionBounds.center.y)));
                        Vector2    labelSize    = styles.dragLabel.CalcSize(labelContent);

                        EditorGUI.DoDropShadowLabel(new Rect(m_Layout.topLabelAnchor.x, m_Layout.topLabelAnchor.y - labelSize.y, labelSize.x, labelSize.y), labelContent, styles.dragLabel, 0.3f);
                    }
                }
            }
            else if (flags == RectangleToolFlags.MiniRectangleTool)
            {
                if ((dragMode & DragMode.MoveBothAxis) != 0)
                {
                    Vector2 localPosition = (canScaleX || canScaleY) ? new Vector2(PixelToTime(Event.current.mousePosition.x, frameRate), PixelToValue(Event.current.mousePosition.y)) : (Vector2)selectionBounds.center;
                    Vector2 labelPosition = new Vector2(TimeToPixel(localPosition.x), ValueToPixel(localPosition.y));

                    GUIContent labelContent = new GUIContent(string.Format("{0}, {1}", m_CurveEditor.FormatTime(localPosition.x, m_CurveEditor.invSnap, m_CurveEditor.timeFormat), m_CurveEditor.FormatValue(localPosition.y)));
                    Vector2    labelSize    = styles.dragLabel.CalcSize(labelContent);

                    EditorGUI.DoDropShadowLabel(new Rect(labelPosition.x, labelPosition.y - labelSize.y, labelSize.x, labelSize.y), labelContent, styles.dragLabel, 0.3f);
                }
            }
        }