1 class FilmStripKnob
: public Slider
4 FilmStripKnob(Image image
, const int numFrames
, const bool stripIsHorizontal
)
5 : Slider("Film Strip Slider"),
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;
19 void paint(Graphics
& g
)
21 int value
= (getValue() - getMinimum()) / (getMaximum() - getMinimum()) * (numFrames_
- 1);
23 g
.drawImage(filmStrip
, 8, 0, getWidth() - 16, getHeight() - valueTextHeight
* 2,
24 value
* frameWidth
, 0, frameWidth
, frameHeight
);
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
);
38 valueText
= juce::String(getValue(), 2); // << T("dB");
39 g
.drawText(valueText
, 0, getWidth() + 8 - 16, getWidth(), valueTextHeight
, juce::Justification::centred
, false);
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;
56 const bool isHorizontal_
;
57 int frameWidth
, frameHeight
;
59 juce::String valueText
;