#include "KnobLookAndFeel.h" namespace serum { void KnobLookAndFeel::drawRotarySlider (juce::Graphics& g, int x, int y, int width, int height, float sliderPos, float rotaryStartAngle, float rotaryEndAngle, juce::Slider& slider) { const auto dial = juce::Rectangle ((float) x, (float) y, (float) width, (float) height); if (dial.isEmpty()) return; const float radius = juce::jmin (dial.getWidth(), dial.getHeight()) * 0.5f - 2.0f; if (radius <= 1.0f) return; const float lineW = juce::jlimit (1.5f, 5.0f, radius * 0.22f); const float arcR = radius - lineW * 0.5f; const float centreX = dial.getCentreX(); const float centreY = dial.getCentreY(); const float toAngle = rotaryStartAngle + sliderPos * (rotaryEndAngle - rotaryStartAngle); const bool live = slider.isEnabled(); juce::Path track; track.addCentredArc (centreX, centreY, arcR, arcR, 0.0f, rotaryStartAngle, rotaryEndAngle, true); g.setColour (theme::outline); g.strokePath (track, juce::PathStrokeType (lineW, juce::PathStrokeType::curved, juce::PathStrokeType::rounded)); if (live) { juce::Path value; value.addCentredArc (centreX, centreY, arcR, arcR, 0.0f, rotaryStartAngle, toAngle, true); g.setColour (theme::accent.withAlpha (slider.isMouseOverOrDragging() ? 1.0f : 0.75f)); g.strokePath (value, juce::PathStrokeType (lineW, juce::PathStrokeType::curved, juce::PathStrokeType::rounded)); } const float pointer = radius * 0.62f; g.setColour (live ? theme::text : theme::textDim); g.drawLine (centreX + std::sin (toAngle) * pointer * 0.35f, centreY - std::cos (toAngle) * pointer * 0.35f, centreX + std::sin (toAngle) * pointer, centreY - std::cos (toAngle) * pointer, juce::jmax (1.5f, lineW * 0.5f)); } } // namespace serum