Krotos Modules 3
Loading...
Searching...
No Matches
BipolarSliderLAF.cpp
Go to the documentation of this file.
1#include "BipolarSliderLAF.h"
2
3namespace krotos
4{
5 void BipolarSliderLAF::drawLinearSlider(Graphics& g, int x, int y, int width, int height, float sliderPos,
6 float /*minSliderPos*/, float /*maxSliderPos*/,
7 const Slider::SliderStyle /*style*/, Slider& /*slider*/)
8 {
9 // juce::LookAndFeel_V4::drawLinearSlider which draws outwards.
10 const Colour trackBackgroundColour(0x1AFFFFFF); // white, 0.1 opacity
11 const Colour trackColour(0x66FFFFFF); // white, 0.4 opacity
12 const Colour thumbColour(0xFFFFFFFF); // white
13 const Colour centreMarkerColour(0xFF000000); // black
14
15 // paint background track
16 const int trackHeight(6);
17 const float trackY = ((float)y + (float)height * 0.5f);
18 Point<float> startPoint((float)x, trackY);
19 Point<float> endPoint((float)(width + x), trackY);
20 Path backgroundTrack;
21 backgroundTrack.startNewSubPath(startPoint);
22 backgroundTrack.lineTo(endPoint);
23 g.setColour(trackBackgroundColour);
24 g.strokePath(backgroundTrack, {trackHeight, PathStrokeType::curved, PathStrokeType::rounded});
25
26 // paint track
27 Point<float> maxPoint, negativeMaxPoint;
28 maxPoint = {sliderPos, trackY};
29 Path valueTrack;
30 valueTrack.startNewSubPath(maxPoint);
31 g.setColour(trackColour);
32 valueTrack.lineTo(width + (x * 2.0f) - sliderPos, trackY);
33 g.strokePath(valueTrack, {trackHeight, PathStrokeType::curved, PathStrokeType::rounded});
34
35 // paint centre marker
36 const float middleMarkerWidth(2.0);
37 const float middleX((float)x + (float)width * 0.5f);
38 g.setColour(centreMarkerColour);
39 const float lineHeight((float)trackHeight * 2.0f);
40 g.fillRect(/*x*/ middleX - (middleMarkerWidth * 0.5f) + 0.5f, /*y*/ 6.0f, middleMarkerWidth, lineHeight);
41 // nb: adding 0.5f to the X to put it between pixels, resulting in a crispier line
42
43 // paint white circle thumb
44 const int thumbWidth(8);
45 g.setColour(thumbColour);
46 g.fillEllipse(
47 Rectangle<float>(static_cast<float>(thumbWidth), static_cast<float>(thumbWidth)).withCentre(maxPoint));
48 }
49} // namespace krotos
void drawLinearSlider(Graphics &, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle, Slider &) override
Definition BipolarSliderLAF.cpp:5
Definition AirAbsorptionFilter.cpp:2