| 50 | } |
| 51 | |
| 52 | void FreqTextLabel::paint(juce::Graphics& g) |
| 53 | { |
| 54 | // The paint() method is for drawing only. All setup is done elsewhere. |
| 55 | |
| 56 | // 1. Calculate the current alpha based on the animation step. |
| 57 | float alpha = juce::jmin(1.0f, currentStep / static_cast<float>(maxStep)); |
| 58 | setAlpha(alpha); |
| 59 | |
| 60 | // 2. Draw the rounded background rectangle. |
| 61 | float cornerSize = 10.0f * mScale; |
| 62 | juce::Rectangle<float> rect = getLocalBounds().toFloat(); |
| 63 | g.setColour(COLOUR1.withAlpha(0.5f)); |
| 64 | g.fillRoundedRectangle(rect, cornerSize); |
| 65 | g.setColour(COLOUR1); |
| 66 | |
| 67 | // 3. Update the label's text, but only if the user is not currently editing it. |
| 68 | if (! freqLabel.isBeingEdited()) |
| 69 | { |
| 70 | juce::String freqText = static_cast<juce::String>(mFrequency) + " Hz"; |
| 71 | freqLabel.setText(freqText, juce::dontSendNotification); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | void FreqTextLabel::resized() |
| 76 | { |