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

            float range = GetRange();

            int numTickLevels = tickHandler.NumLevels;

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

                float[] ticks    = tickHandler.GetTicks(i);
                float   strength = tickHandler.GetLevelStrength(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();
        }
Exemple #2
0
        /// <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)
                {
                    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);
                        }
                    }
                }
            }
        }