Beispiel #1
0
        /// <inheritdoc/>
        public override void Rebuild()
        {
            canvas.Clear();
            tickHandler.SetRange(rangeOffset, rangeOffset + GetRange(true), (uint)(drawableWidth + PADDING));

            float range = GetRange();

            int numTickLevels = (int)tickHandler.NumLevels;
            for (int i = numTickLevels - 1; i >= 0; i--)
            {
                bool drawText = i == 0;

                float[] ticks = tickHandler.GetTicks((uint)i);
                float strength = tickHandler.GetLevelStrength((uint)i);

                if (ticks.Length > 0)
                {
                    float valuePerTick = range/ticks.Length;
                    bool displayAsMinutes = TimeSpan.FromSeconds(valuePerTick).Minutes > 0;
                    for (int j = 0; j < ticks.Length; j++)
                        DrawTick(ticks[j], strength, drawText, displayAsMinutes);
                }
            }

            DrawFrameMarker();
        }
        /// <summary>
        /// Rebuilds the internal GUI elements. Should be called whenever timeline properties change.
        /// </summary>
        public void Rebuild()
        {
            canvas.Clear();

            int   heightOffset = height / 2;
            float pixelsPerHeight;

            if (rangeEnd != rangeStart)
            {
                pixelsPerHeight = height / (rangeEnd - rangeStart);
            }
            else
            {
                pixelsPerHeight = 0;
            }

            float yOffset = rangeStart + (rangeEnd - rangeStart) * 0.5f;

            int numTickLevels = tickHandler.NumLevels;

            for (int i = numTickLevels - 1; i >= 0; i--)
            {
                float[] ticks    = tickHandler.GetTicks(i);
                float   strength = tickHandler.GetLevelStrength(i);

                if (ticks.Length > 0)
                {
                    float valuePerTick = (rangeEnd - rangeStart) / ticks.Length;

                    for (int j = 0; j < ticks.Length; j++)
                    {
                        int yPos = (int)((ticks[j] - yOffset) * pixelsPerHeight);
                        yPos = heightOffset - yPos; // Offset and flip height (canvas Y goes down)

                        Vector2I start = new Vector2I(0, yPos);
                        Vector2I end   = new Vector2I((int)(width * strength), yPos);

                        Color color = COLOR_TRANSPARENT_LIGHT_GRAY;
                        color.a *= strength;

                        canvas.DrawLine(start, end, color);

                        // Draw text for the highest level ticks
                        if (i == 0)
                        {
                            DrawValue(yPos, ticks[j], ticks[j] <= 0.0f);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Rebuilds the internal GUI elements. Should be called whenever timeline properties change.
        /// </summary>
        public override void Rebuild()
        {
            canvas.Clear();

            if (curveInfos == null)
            {
                return;
            }

            if (drawMarkers)
            {
                tickHandler.SetRange(rangeOffset, rangeOffset + GetRange(true), drawableWidth + PADDING);

                // Draw vertical frame markers
                int numTickLevels = tickHandler.NumLevels;
                for (int i = numTickLevels - 1; i >= 0; i--)
                {
                    float[] ticks    = tickHandler.GetTicks(i);
                    float   strength = tickHandler.GetLevelStrength(i);

                    for (int j = 0; j < ticks.Length; j++)
                    {
                        Color color = COLOR_DARK_GRAY;
                        color.a *= strength;

                        DrawFrameMarker(ticks[j], color, false);
                    }
                }

                // Draw center line
                DrawCenterLine();
            }

            // Draw range
            int curvesToDraw = curveInfos.Length;

            if (drawRange && curveInfos.Length >= 2)
            {
                EdAnimationCurve[] curves = { curveInfos[0].curve, curveInfos[1].curve };

                DrawCurveRange(curves, new Color(1.0f, 0.0f, 0.0f, 0.3f));
                curvesToDraw = 2;
            }

            // Draw curves
            for (int i = 0; i < curvesToDraw; i++)
            {
                DrawCurve(curveInfos[i].curve, curveInfos[i].color);

                // Draw keyframes
                KeyFrame[] keyframes = curveInfos[i].curve.KeyFrames;

                for (int j = 0; j < keyframes.Length; j++)
                {
                    bool isSelected = IsSelected(i, j);

                    DrawKeyframe(keyframes[j].time, keyframes[j].value, isSelected);

                    if (isSelected)
                    {
                        DrawTangents(keyframes[j], curveInfos[i].curve.TangentModes[j]);
                    }
                }
            }

            // Draw selected frame marker
            if (drawMarkers && markedFrameIdx != -1)
            {
                DrawFrameMarker(GetTimeForFrame(markedFrameIdx), Color.BansheeOrange, true);
            }
        }
        /// <summary>
        /// Rebuilds the internal GUI elements. Should be called whenever timeline properties change.
        /// </summary>
        public override void Rebuild()
        {
            canvas.Clear();

            if (curveInfos == null)
            {
                return;
            }

            tickHandler.SetRange(rangeOffset, rangeOffset + GetRange(true), drawableWidth + PADDING);

            // Draw vertical frame markers
            int numTickLevels = tickHandler.NumLevels;

            for (int i = numTickLevels - 1; i >= 0; i--)
            {
                float[] ticks    = tickHandler.GetTicks(i);
                float   strength = tickHandler.GetLevelStrength(i);

                for (int j = 0; j < ticks.Length; j++)
                {
                    Color color = COLOR_DARK_GRAY;
                    color.a *= strength;

                    DrawFrameMarker(ticks[j], color, false);
                }
            }

            // Draw center line
            DrawCenterLine();

            // Draw curves
            int curveIdx = 0;

            foreach (var curveInfo in curveInfos)
            {
                DrawCurve(curveInfo.curve, curveInfo.color);

                // Draw keyframes
                KeyFrame[] keyframes = curveInfo.curve.KeyFrames;

                for (int i = 0; i < keyframes.Length; i++)
                {
                    bool isSelected = IsSelected(curveIdx, i);

                    DrawKeyframe(keyframes[i].time, keyframes[i].value, isSelected);

                    if (isSelected)
                    {
                        DrawTangents(keyframes[i], curveInfo.curve.TangentModes[i]);
                    }
                }

                curveIdx++;
            }

            // Draw selected frame marker
            if (markedFrameIdx != -1)
            {
                DrawFrameMarker(GetTimeForFrame(markedFrameIdx), Color.BansheeOrange, true);
            }
        }