Pulsing text in label?


#1

I’m making some details on my plugin.
I need to let a label text pulse… is there a way to do so?
Maybe with timer…


#2

something like this:

void AudioProcessorEditor::timerCallback()
{
    if (selecting)
    {
        int time = getTimerInterval();
        if (time > 500)
         {
            lcdText.setVisible(false);
        }
    }
}

but with the elapsed time instead of getInterval…


#3

Yep, you could certainly do it with a Timer. Also, take a look at the ComponentAnimator class and its fadeOut() and fadeIn() methods.

Ed


#4

Ok, but how to use timer?
I cannot get the elapsed time…
And where I have to place the animator?


#5

You can measure the time “now” each time the timer callback goes off (using, for example, Time::getMillisecondCounterHiRes()). Store this time in your object as lastTime — or seomthing like that. In your timer callback you can simply do now - lastTime to get the time elapsed since the last callback.


#6

Elapsed time since what event? The timerCallback() method will be called regularly at the interval that you supplied as the argument to the startTimer() method so the elapsed time since the last timerCallback() call will always be (roughly) the same.

You can get the global ComponentAnimator object using Desktop::getAnimator() and call the animate methods on this.

Ed


#7

From where and where do I store the lastTime value?


#8

I know that the interval is fixed… I need to know when the callback finish…
So I can make visible the first time and not visible the second…


#9

Try this instead:

lcdText.setVisible (! lcdText.isVisible());

Ed


#10

RESOLVED:

void AudioProcessorEditor::timerCallback()
{
    if (selecting)
    {
        if (lcdText.getTextValue() != "")
        {
            lcdText.setText("", dontSendNotification);
        }
        else
        {
            lcdText.setText(preset.presetNames[selProgram], dontSendNotification);
        }
    }
}

#11

I thought you we’re concerned about the slight deviation of the time interval so I was showing how you could compensate for this if the accuracy of the animation was important.


#12

Thanks anyway, but is only a little detail…