Rotary Slider multiple formats?


#1

So here´s the deal, I´m doing my own Rotary Slider code to display a rendered knob image, ok, but what if I want different images for different situations? EG: regular max to min knob, knob for fine-pitch or panning so its -1 to 1, things like that. :wink:

I´m wondering on just using the customID to store the info on what type of image to use, but I wonder if this is silly or not. :oops:

Any ideas on this?

Best Regards, WilliamK


#2

Never mind, I see that I can create my own custom knob image slider. :oops: Sorry guys, coded nearly non-stop for days and days, brain tired, overload. :wink: Ok, here´s the updated code, below the link to the author original post, (martinrobinson) I just updated to work on the latest Juce files.

[code]// -------------------------------------------------------------------------------------------------------------------------------
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)
{
		int value = (getValue() - getMinimum()) / (getMaximum() - getMinimum()) * (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:
Image filmStrip;
const int numFrames_;
const bool isHorizontal_;
int frameWidth, frameHeight;
};[/code]

http://www.rawmaterialsoftware.com/viewtopic.php?p=21998#p21998