From 6909cfac11cc36e59ea1ad337791cf045f275a76 Mon Sep 17 00:00:00 2001 From: Jose Diaz Rohena Date: Fri, 5 Jan 2024 17:55:58 +0100 Subject: [PATCH] Formatting cleanups in drawRotarySliderBase --- .../juce_gui/lookandfeel/LookAndFeel.cpp | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/libs/tote_bag/juce_gui/lookandfeel/LookAndFeel.cpp b/libs/tote_bag/juce_gui/lookandfeel/LookAndFeel.cpp index d4795b6b..e37ec8e7 100644 --- a/libs/tote_bag/juce_gui/lookandfeel/LookAndFeel.cpp +++ b/libs/tote_bag/juce_gui/lookandfeel/LookAndFeel.cpp @@ -125,23 +125,21 @@ void LookAndFeel::drawRotarySliderBase (juce::Graphics& g, { const auto centreX = bounds.getCentreX(); const auto centreY = bounds.getCentreY(); + const auto rx = centreX - radius; + const auto ry = centreY - radius; + const auto rw = radius * 2.0f; - auto rx = centreX - radius; - auto ry = centreY - radius; - auto rw = radius * 2.0f; - - // Fill main knob area - auto fillColour = findColour (juce::Slider::backgroundColourId); - g.setColour (fillColour); + g.setColour (findColour (juce::Slider::backgroundColourId)); g.fillEllipse (rx, ry, rw, rw); - // Pointer juce::Path p; - auto pointerLength = radius * 0.33f; - auto pointerThickness = pointerLength * .2f; + const auto pointerLength = radius * 0.33f; + const auto pointerThickness = pointerLength * .2f; + const auto pointerX = -pointerThickness * 0.5f; const auto pointerY = juce::roundToInt (juce::jmax ((rw * .05f), 1.0f)) - radius; - auto cornerSize = pointerThickness * .35f; - p.addRoundedRectangle (-pointerThickness * 0.5f, + const auto cornerSize = pointerThickness * .35f; + + p.addRoundedRectangle (pointerX, pointerY, pointerThickness, pointerLength, @@ -151,12 +149,12 @@ void LookAndFeel::drawRotarySliderBase (juce::Graphics& g, true, true, true); + p.applyTransform ( juce::AffineTransform::rotation (toAngle).translated (bounds.getCentreX(), bounds.getCentreY())); - auto pointerColour = findColour (juce::Slider::thumbColourId); - g.setColour (pointerColour); + g.setColour (findColour (juce::Slider::thumbColourId)); g.fillPath (p); }