I’m trying to replace the RotarySlider look with an image that I can then rotate. I’ve created a new Look and Feel class and switched out the default class for this one. I’ve also overridden the drawRotarySlider method.
The code below doesn’t draw any knobs, unless I add:
The rotation needs a centre to rotate about. You have chosen 0, 0, which might not even be within the slider rectangle (note x and y).
I would recommend:
auto image = juce::ImageCache::getFromMemory (BinaryData::RotaryKnob_png, BinaryData::RotaryKnob_pngSize);
juce::Rectangle<float> rect (x, y, width, height);
auto transform = juce::AffineTransform::rotation (juce::jmap (sliderPos, rotaryStartAngle, rotaryEndAngle),
g.drawImageTransformed (image, transform, false);
a) the static function is called without an object and returns a rotation
b) the rotation needs the centre of the rectangle
c) thanks to the ImageCache, there is no need to store the image in a member variable
I plan to implement images in my controls but I don’t intend to make the image rotate, it would be static and the dial and lights would be superimposed, either as an image or as a drawing. The justification is that the rotation is not really appreciated, the shadows and highlights always remain static.
in fact I think it is not even a choice, it is mandatory depending on the type of knob. For a knob with text, geometric shapes, drawings or reliefs, a rotating image is necessary, but for a circular knob with reflections, highlights, shadows, a rotated image does not work.