Experiment with a colour gradient fill in the performance meter

This commit is contained in:
xenakios 2018-02-16 01:55:33 +02:00
parent 9ceb7201f7
commit 974f55dcad
2 changed files with 14 additions and 3 deletions

View File

@ -1032,15 +1032,24 @@ double MySlider::valueToProportionOfLength(double x)
PerfMeterComponent::PerfMeterComponent(PaulstretchpluginAudioProcessor * p) PerfMeterComponent::PerfMeterComponent(PaulstretchpluginAudioProcessor * p)
: m_proc(p) : m_proc(p)
{} {
m_gradient.isRadial = false;
m_gradient.addColour(0.0, Colours::red);
m_gradient.addColour(0.25, Colours::yellow);
m_gradient.addColour(1.0, Colours::green);
}
void PerfMeterComponent::paint(Graphics & g) void PerfMeterComponent::paint(Graphics & g)
{ {
g.fillAll(Colours::grey); m_gradient.point1 = {0.0f,0.0f};
m_gradient.point2 = {(float)getWidth(),0.0f};
g.fillAll(Colours::grey);
double amt = m_proc->getPreBufferingPercent(); double amt = m_proc->getPreBufferingPercent();
g.setColour(Colours::green); g.setColour(Colours::green);
int w = amt * getWidth(); int w = amt * getWidth();
g.fillRect(0, 0, w, getHeight()); g.setGradientFill(m_gradient);
g.fillRect(0, 0, w, getHeight());
g.setColour(Colours::white); g.setColour(Colours::white);
g.drawRect(0, 0, getWidth(), getHeight()); g.drawRect(0, 0, getWidth(), getHeight());
g.setFont(10.0f); g.setFont(10.0f);

View File

@ -110,6 +110,8 @@ public:
void paint(Graphics& g) override; void paint(Graphics& g) override;
void mouseDown(const MouseEvent& ev) override; void mouseDown(const MouseEvent& ev) override;
PaulstretchpluginAudioProcessor* m_proc = nullptr; PaulstretchpluginAudioProcessor* m_proc = nullptr;
private:
ColourGradient m_gradient;
}; };
class MyThumbCache : public AudioThumbnailCache class MyThumbCache : public AudioThumbnailCache