Пример #1
0
        public static void Draw(WindowState state, double time)
        {
            var bounds = state.timeAreaRect;

            bounds.xMin = Mathf.Max(bounds.xMin, state.TimeToTimeAreaPixel(time));

            using (new GUIViewportScope(state.timeAreaRect))
            {
                s_Tooltip.text = TimeReferenceUtility.ToTimeString(time);

                var tooltipBounds = s_Tooltip.bounds;
                tooltipBounds.xMin = bounds.xMin - (tooltipBounds.width / 2.0f);
                tooltipBounds.y    = bounds.y;
                s_Tooltip.bounds   = tooltipBounds;

                if (time >= 0)
                {
                    s_Tooltip.Draw();
                }
            }

            if (time >= 0)
            {
                Graphics.DrawLineAtTime(state, time, Color.black, true);
            }
        }
        // Draws the box to enter the time field
        void TimeCodeGUI()
        {
            EditorGUI.BeginChangeCheck();

            var currentTime = state.editSequence.asset != null?TimeReferenceUtility.ToTimeString(state.editSequence.time, "F1") : "0";

            var r              = EditorGUILayout.GetControlRect(false, EditorGUI.kSingleLineHeight, EditorStyles.toolbarTextField, GUILayout.MinWidth(WindowConstants.minTimeCodeWidth));
            var id             = GUIUtility.GetControlID("RenameFieldTextField".GetHashCode(), FocusType.Passive, r);
            var newCurrentTime = EditorGUI.DelayedTextFieldInternal(r, id, GUIContent.none, currentTime, null, EditorStyles.toolbarTextField);

            if (EditorGUI.EndChangeCheck())
            {
                state.editSequence.time = TimeReferenceUtility.FromTimeString(newCurrentTime);
            }
        }
Пример #3
0
        public void Draw(Rect rect, WindowState state, double time)
        {
            var clipRect = new Rect(0.0f, 0.0f, TimelineWindow.instance.position.width, TimelineWindow.instance.position.height);

            clipRect.xMin += state.sequencerHeaderWidth;

            using (new GUIViewportScope(clipRect))
            {
                Vector2 windowCoordinate = rect.min;
                windowCoordinate.y += 4.0f;

                windowCoordinate.x = state.TimeToPixel(time);

                m_BoundingRect = new Rect((windowCoordinate.x - widgetWidth / 2.0f), windowCoordinate.y, widgetWidth, widgetHeight);

                // Do not paint if the time cursor goes outside the timeline bounds...
                if (Event.current.type == EventType.Repaint)
                {
                    if (m_BoundingRect.xMax < state.timeAreaRect.xMin)
                    {
                        return;
                    }
                    if (m_BoundingRect.xMin > state.timeAreaRect.xMax)
                    {
                        return;
                    }
                }

                var top    = new Vector3(windowCoordinate.x, rect.y - DirectorStyles.kDurationGuiThickness);
                var bottom = new Vector3(windowCoordinate.x, rect.yMax);

                if (drawLine)
                {
                    Rect lineRect = Rect.MinMaxRect(top.x - 0.5f, top.y, bottom.x + 0.5f, bottom.y);
                    EditorGUI.DrawRect(lineRect, lineColor);
                }

                if (drawHead)
                {
                    Color c = GUI.color;
                    GUI.color = headColor;
                    GUI.Box(bounds, m_HeaderContent, m_Style);
                    GUI.color = c;

                    if (canMoveHead)
                    {
                        EditorGUIUtility.AddCursorRect(bounds, MouseCursor.MoveArrow);
                    }
                }

                if (showTooltip)
                {
                    m_Tooltip.text = TimeReferenceUtility.ToTimeString(time);

                    Vector2 position = bounds.position;
                    position.y  = state.timeAreaRect.y;
                    position.y -= m_Tooltip.bounds.height;
                    position.x -= Mathf.Abs(m_Tooltip.bounds.width - bounds.width) / 2.0f;

                    Rect tooltipBounds = bounds;
                    tooltipBounds.position = position;
                    m_Tooltip.bounds       = tooltipBounds;

                    m_Tooltip.Draw();
                }
            }
        }