Hi guys,
this is a modification to a FilmStripKnob class posted in another thread, but that works with skewed sliders.
class FilmStripKnob : public Slider
{
public:
FilmStripKnob(Image image, const int numFrames, const bool stripIsHorizontal)
: Slider(),
numFrames_(numFrames),
isHorizontal_(stripIsHorizontal),
filmStrip(image)
{
setTextBoxStyle(NoTextBox, 0, 0, 0);
if (isHorizontal_) {
frameHeight = filmStrip.getHeight();
frameWidth = filmStrip.getWidth() / numFrames_;
}
else {
frameHeight = filmStrip.getHeight() / numFrames_;
frameWidth = filmStrip.getWidth();
}
}
void paint(Graphics& g)
{
const float sliderPos = (float) valueToProportionOfLength(getValue());
int value = sliderPos * (numFrames_ - 1);
if (isHorizontal_) {
g.drawImage(filmStrip, 0, 0, getWidth(), getHeight(),
value * frameWidth, 0, frameWidth, frameHeight);
}
else {
g.drawImage(filmStrip, 0, 0, getWidth(), getHeight(),
0, value * frameHeight, frameWidth, frameHeight);
}
if (isMouseOverOrDragging())
{
}
}
int getFrameWidth() const { return frameWidth; }
int getFrameHeight() const { return frameHeight; }
private:
const int numFrames_;
const bool isHorizontal_;
Image filmStrip;
int frameWidth, frameHeight;
};

