コード例 #1
0
        public void Draw(double beginTime, double endTime, MagnetEngine magnetEngine)
        {
            TimelineWindow.TimelineState state = TimelineWindow.instance.state;
            Rect timeAreaBounds = TimelineWindow.instance.timeAreaBounds;

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

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

            min.y += 4f;
            min.x  = state.TimeToPixel(time);
            TimeAreaItem.Alignment alignment = this.alignment;
            if (alignment != TimeAreaItem.Alignment.Center)
            {
                if (alignment != TimeAreaItem.Alignment.Left)
                {
                    if (alignment == TimeAreaItem.Alignment.Right)
                    {
                        this.m_BoundingRect = new Rect(min.x, min.y, this.widgetWidth, this.widgetHeight);
                    }
                }
                else
                {
                    this.m_BoundingRect = new Rect(min.x - this.widgetWidth, min.y, this.widgetWidth, this.widgetHeight);
                }
            }
            else
            {
                this.m_BoundingRect = new Rect(min.x - this.widgetWidth / 2f, min.y, this.widgetWidth, this.widgetHeight);
            }
            if (Event.get_current().get_type() == 7)
            {
                if (this.m_BoundingRect.get_xMax() < state.timeAreaRect.get_xMin())
                {
                    return;
                }
                if (this.m_BoundingRect.get_xMin() > state.timeAreaRect.get_xMax())
                {
                    return;
                }
            }
            float   num = state.timeAreaRect.get_yMax() - DirectorStyles.kDurationGuiThickness;
            Vector3 p   = new Vector3(min.x, num, 0f);
            Vector3 p2  = new Vector3(min.x, num + Mathf.Min(rect.get_height(), state.windowHeight), 0f);

            if (this.drawLine)
            {
                if (this.dottedLine)
                {
                    Graphics.DrawDottedLine(p, p2, 5f, this.lineColor);
                }
                else
                {
                    Rect rect2 = Rect.MinMaxRect(p.x - 0.5f, p.y, p2.x + 0.5f, p2.y);
                    EditorGUI.DrawRect(rect2, this.lineColor);
                }
            }
            if (this.drawHead)
            {
                Color color = GUI.get_color();
                GUI.set_color(this.headColor);
                GUI.Box(this.bounds, this.m_HeaderContent, this.m_Style);
                GUI.set_color(color);
                if (this.canMoveHead)
                {
                    EditorGUIUtility.AddCursorRect(this.bounds, 8);
                }
            }
            if (this.showTooltip)
            {
                this.m_Tooltip.text = state.TimeAsString(time, "F2");
                Vector2 position = this.bounds.get_position();
                position.y  = state.timeAreaRect.get_y();
                position.y -= this.m_Tooltip.bounds.get_height();
                position.x -= Mathf.Abs(this.m_Tooltip.bounds.get_width() - this.bounds.get_width()) / 2f;
                Rect bounds = this.bounds;
                bounds.set_position(position);
                this.m_Tooltip.bounds = bounds;
                this.m_Tooltip.Draw();
            }
        }