Add TAL-Reverb-II plugin to test
[juce-lv2.git] / tal-reverb-2-juce / src / FilmStripKnob.h
blob05632065cc4022ca72795ac9252cc106de5aabe9
1 class FilmStripKnob : public Slider
3 public:
4 FilmStripKnob(Image image, const int numFrames, const bool stripIsHorizontal)
5 : Slider("Film Strip Slider"),
6 filmStrip(image),
7 numFrames_(numFrames),
8 isHorizontal_(stripIsHorizontal)
10 setTextBoxStyle(NoTextBox, 0, 0, 0);
11 setSliderStyle(RotaryVerticalDrag);
12 frameHeight = filmStrip.getHeight() / numFrames_;
13 frameWidth = filmStrip.getWidth();
14 setRange(0.0f, 1.0f, 0.001f);
15 customValueText = false;
16 valueTextHeight = 10;
19 void paint(Graphics& g)
21 int value = (getValue() - getMinimum()) / (getMaximum() - getMinimum()) * (numFrames_ - 1);
22 if(isHorizontal_) {
23 g.drawImage(filmStrip, 8, 0, getWidth() - 16, getHeight() - valueTextHeight * 2,
24 value * frameWidth, 0, frameWidth, frameHeight);
25 } else {
26 g.drawImage(filmStrip, 8, 0, getWidth() - 16, getHeight() - valueTextHeight * 2,
27 0, value * frameHeight, frameWidth, frameHeight);
30 g.setColour(Colour((const juce::uint8)10, (const juce::uint8)10, (const juce::uint8)10));
31 g.fillRoundedRectangle(0, getWidth() + 6 - 16, getWidth(), valueTextHeight + 4, 6.0f);
33 g.setColour(Colour((const juce::uint8)200, (const juce::uint8)200, (const juce::uint8)200));
35 g.setFont(12.0f, Font::plain);
36 if (!customValueText)
38 valueText = juce::String(getValue(), 2); // << T("dB");
39 g.drawText(valueText, 0, getWidth() + 8 - 16, getWidth(), valueTextHeight, juce::Justification::centred, false);
41 else
43 g.drawText(valueText, 0, getWidth() + 8 - 16, getWidth(), valueTextHeight, juce::Justification::centred, false);
47 void setTextValue(juce::String valueText)
49 this->valueText = valueText;
50 customValueText = true;
53 private:
54 Image filmStrip;
55 const int numFrames_;
56 const bool isHorizontal_;
57 int frameWidth, frameHeight;
59 juce::String valueText;
60 bool customValueText;
61 int valueTextHeight;