コード例 #1
0
        /// <summary>
        /// Sets the physical size onto which to draw the value display.
        /// </summary>
        /// <param name="width">Width in pixels.</param>
        /// <param name="height">Height in pixels.</param>
        public void SetSize(int width, int height)
        {
            this.width  = width;
            this.height = height;

            canvas.SetWidth(width);
            canvas.SetHeight(height);

            tickHandler.SetRange(rangeStart, rangeEnd, height);
        }
コード例 #2
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();
        }
コード例 #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);
            }
        }
コード例 #4
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;
            }

            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);
            }
        }