Skip to content

Commit

Permalink
Move rotary slider meter drawing function
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseDiazRohena committed Jan 6, 2024
1 parent 6e5c50b commit 391c388
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions libs/tote_bag/juce_gui/lookandfeel/LookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ LookAndFeel::LookAndFeel()
juce::Colours::transparentWhite);
}

void LookAndFeel::drawDrawableKnob (juce::Graphics& g,
const float radius,
const float drawableWidth,
juce::Drawable& sliderImage,
const float toAngle,
const juce::Rectangle<float> bounds)
{
const auto rw = radius * 2.0f;
const auto realW = rw / drawableWidth;

const auto halfDrawableWidth = drawableWidth / 2.0f;

sliderImage.setTransform (
juce::AffineTransform::rotation (toAngle, halfDrawableWidth, halfDrawableWidth)
.scaled (realW, realW, halfDrawableWidth, halfDrawableWidth));

const auto cX = bounds.getCentreX() - halfDrawableWidth;
const auto cY = bounds.getCentreY() - halfDrawableWidth;
sliderImage.drawAt (g, cX, cY, 1.0f);
}

void LookAndFeel::drawSliderMeter (juce::Graphics& g,
const juce::Rectangle<float> bounds,
const float lineWidth,
Expand Down Expand Up @@ -97,27 +118,6 @@ void LookAndFeel::drawSliderMeter (juce::Graphics& g,
}
}

void LookAndFeel::drawDrawableKnob (juce::Graphics& g,
const float radius,
const float drawableWidth,
juce::Drawable& sliderImage,
const float toAngle,
const juce::Rectangle<float> bounds)
{
const auto rw = radius * 2.0f;
const auto realW = rw / drawableWidth;

const auto halfDrawableWidth = drawableWidth / 2.0f;

sliderImage.setTransform (
juce::AffineTransform::rotation (toAngle, halfDrawableWidth, halfDrawableWidth)
.scaled (realW, realW, halfDrawableWidth, halfDrawableWidth));

const auto cX = bounds.getCentreX() - halfDrawableWidth;
const auto cY = bounds.getCentreY() - halfDrawableWidth;
sliderImage.drawAt (g, cX, cY, 1.0f);
}

void LookAndFeel::drawRotarySliderBase (juce::Graphics& g,
const float radius,
const float toAngle,
Expand Down

0 comments on commit 391c388

Please sign in to comment.