Esempio n. 1
0
void MeterBarAverage::create(
    int crestFactor, frut::widget::Orientation orientation, bool discreteMeter,
    bool showCombinedMeters, int mainSegmentHeight,
    const Array<Colour> &segmentColours)

{
    frut::widget::MeterBar::create();

    crestFactor *= 10;
    int trueLowerThreshold;
    int numberOfBars;

    if (showCombinedMeters)
    {
        trueLowerThreshold = -90;
        numberOfBars = 21;
    }
    else
    {
        trueLowerThreshold = -160;
        numberOfBars = 8;
    }

    int lowerThreshold = trueLowerThreshold + crestFactor;

    for (int n = 0; n < numberOfBars; ++n)
    {
        int thresholdDifference;

        if (trueLowerThreshold > -260)
        {
            thresholdDifference = 10;
        }
        else if (trueLowerThreshold > -300)
        {
            thresholdDifference = 40;
        }
        else
        {
            thresholdDifference = 100;
        }

        trueLowerThreshold -= thresholdDifference;
        lowerThreshold = trueLowerThreshold + crestFactor;

        int colourId;

        if (trueLowerThreshold >= -170)
        {
            colourId = colourSelector::overload;
        }
        else if (trueLowerThreshold >= -180)
        {
            colourId = colourSelector::warning;
        }
        else if (trueLowerThreshold >= -220)
        {
            colourId = colourSelector::fine;
        }
        else
        {
            colourId = colourSelector::signal;
        }

        int segmentHeight = mainSegmentHeight;

        if (showCombinedMeters)
        {
            segmentHeight += 2;
        }

        bool hasHighestLevel = (n == 0) ? true : false;

        if (discreteMeter)
        {
            // meter segment outlines overlap
            int spacingBefore = -1;
            segmentHeight += 1;

            addDiscreteSegment(
                lowerThreshold * 0.1f,
                thresholdDifference * 0.1f,
                hasHighestLevel,
                segmentHeight,
                spacingBefore,
                segmentColours[colourId],
                segmentColours[colourId].withMultipliedBrightness(0.7f));
        }
        else
        {
            // meter segment outlines must not overlap
            int spacingBefore = 0;

            addContinuousSegment(
                lowerThreshold * 0.1f,
                thresholdDifference * 0.1f,
                (thresholdDifference * 0.1f) / segmentHeight,
                hasHighestLevel,
                segmentHeight,
                spacingBefore,
                segmentColours[colourId],
                Colours::white);
        }
    }

    // set orientation here to save some processing power
    setOrientation(orientation);
}
void MeterBarGainReduction::create(frut::widgets::Orientation orientation,
                                   bool discreteMeter,
                                   int mainSegmentHeight,
                                   const Array<Colour> &segmentColours)

{
    frut::widgets::MeterBar::create();

    setUpwardExpansion(false);

    int trueLowerThreshold = 0;
    int levelRange = 10;
    int numberOfBars = 24;

    for (int n = 0; n < numberOfBars; ++n)
    {
        int colourId;

        if (n % 6 == 5)
        {
            colourId = colourSelector::notify;
        }
        else
        {
            colourId = colourSelector::normal;
        }

        bool hasHighestLevel = (n == (numberOfBars - 1)) ? true : false;

        if (discreteMeter)
        {
            // meter segment outlines overlap
            int spacingBefore = -1;
            int segmentHeight = mainSegmentHeight + 1;

            addDiscreteSegment(
                trueLowerThreshold * 0.1f,
                levelRange * 0.1f,
                0.0f,
                1.0f,
                hasHighestLevel,
                segmentHeight,
                spacingBefore,
                segmentColours[colourId],
                segmentColours[colourId].withMultipliedBrightness(0.7f));
        }
        else
        {
            // meter segment outlines must not overlap
            int spacingBefore = 0;
            int segmentHeight = mainSegmentHeight;

            addContinuousSegment(
                trueLowerThreshold * 0.1f,
                levelRange * 0.1f,
                (levelRange * 0.1f) / segmentHeight,
                hasHighestLevel,
                segmentHeight,
                spacingBefore,
                segmentColours[colourId],
                segmentColours[colourId].withMultipliedBrightness(0.7f));
        }

        trueLowerThreshold += levelRange;
    }

    // set orientation here to save some processing power
    setOrientation(orientation);
}