Skip to content

Commit

Permalink
changed out linear sliders
Browse files Browse the repository at this point in the history
  • Loading branch information
hsetlik committed Apr 13, 2021
1 parent 208176b commit ff9492e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
40 changes: 39 additions & 1 deletion Source/CustomLnF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,42 @@ void LnF1::drawRotarySlider(juce::Graphics &g, int x, int y, int width, int heig
thumb.closeSubPath();
thumb.applyTransform(juce::AffineTransform::rotation(rotaryStartAngle + angle, centerX, centerY));
g.strokePath(thumb, strokeType);
};
}

void LnF1::drawLinearSlider(juce::Graphics &g, int x, int y, int width, int height, float sliderPos, float minSliderPos
, float maxSliderPos, const juce::Slider::SliderStyle, juce::Slider &slider)
{
auto fPos = slider.getValue() / (slider.getMaximum() - slider.getMinimum() + 0.00001f);
auto fBounds = slider.getBounds().toFloat();
auto bkgndWidth = fBounds.getWidth() * 0.2f;
auto xOffsetBkgnd = (fBounds.getWidth() / 2.0f) - (bkgndWidth / 2.0f);
auto corner = bkgndWidth / 3.5f;
auto thumbWidth = fBounds.getWidth() * 0.45f;

auto thumbXOffset = (fBounds.getWidth() / 2.0f) - (thumbWidth / 2.0f);
auto thumbHeight = (fBounds.getHeight() - slider.getTextBoxHeight()) * 0.1f;
auto thumbY = (1.0f - fPos) * ((fBounds.getHeight() - slider.getTextBoxHeight()) - thumbHeight - 5);
thumbY += 5;

/*
printf("Slider Position: %f\n", sliderPos);
printf("Thumb is at: %f\n", thumbY);
*/
//draw the background
g.setColour(UXPalette::darkGray1);
g.fillRoundedRectangle(x + xOffsetBkgnd,
5,
bkgndWidth,
fBounds.getHeight() - (slider.getTextBoxHeight() * 1.2f) - 5,
corner);
//draw the thumb
g.setColour(UXPalette::highlight);
g.fillRoundedRectangle(x + thumbXOffset,
thumbY,
thumbWidth,
thumbHeight,
corner);



}
1 change: 1 addition & 0 deletions Source/CustomLnF.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class LnF1 : public juce::LookAndFeel_V4
}
void drawRotarySlider (juce::Graphics& g, int x, int y, int width, int height, float sliderPos,
const float rotaryStartAngle, const float rotaryEndAngle, juce::Slider& s) override;
void drawLinearSlider(juce::Graphics &g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const juce::Slider::SliderStyle, juce::Slider &) override;
};

class LnF2 : public juce::LookAndFeel_V4
Expand Down
2 changes: 1 addition & 1 deletion Source/OperatorComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ panLabel(&panSlider, "")
{
attachAll(pTree);
addAndMakeVisible(&levelSlider);
levelSlider.setLookAndFeel(&look1); //override the vertical bar draw method next
levelSlider.setLookAndFeel(&look1);
addAndMakeVisible(&ratioSlider);
ratioSlider.setLookAndFeel(&look1);
addAndMakeVisible(&modIndexSlider);
Expand Down

0 comments on commit ff9492e

Please sign in to comment.