MCPcopy Create free account
hub / github.com/DamRsn/NeuralNote / drawRotarySlider

Method drawRotarySlider

NeuralNote/Source/Components/NeuralNoteLNF.cpp:23–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23void NeuralNoteLNF::drawRotarySlider(Graphics& g,
24 int x,
25 int y,
26 int width,
27 int height,
28 float sliderPosProportional,
29 float rotaryStartAngle,
30 float rotaryEndAngle,
31 Slider& slider)
32{
33 auto bounds = Rectangle<int>(x, y, width, height).toFloat();
34
35 auto out_radius = jmin(bounds.getWidth(), bounds.getHeight()) / 2.0f;
36 auto toAngle = rotaryStartAngle + sliderPosProportional * (rotaryEndAngle - rotaryStartAngle);
37 auto lineW = 8.0f;
38 jmin(8.0f, out_radius * 0.5f);
39 auto arcRadius = out_radius - lineW * 0.5f;
40
41 Path backgroundArc;
42 backgroundArc.addCentredArc(
43 bounds.getCentreX(), bounds.getCentreY(), arcRadius, arcRadius, 0.0f, rotaryStartAngle, rotaryEndAngle, true);
44
45 g.setColour(KNOB_GREY);
46 g.strokePath(backgroundArc, PathStrokeType(lineW, PathStrokeType::curved, PathStrokeType::rounded));
47
48 Path valueArc;
49 valueArc.addCentredArc(
50 bounds.getCentreX(), bounds.getCentreY(), arcRadius, arcRadius, 0.0f, rotaryStartAngle, toAngle, true);
51
52 g.setColour(BLACK);
53 g.strokePath(valueArc, PathStrokeType(lineW, PathStrokeType::curved, PathStrokeType::rounded));
54
55 auto thumbWidth = 5.0f;
56 Point<float> thumbPoint(bounds.getCentreX() + 10 * std::cos(toAngle - MathConstants<float>::halfPi),
57 bounds.getCentreY() + 10 * std::sin(toAngle - MathConstants<float>::halfPi));
58
59 g.setColour(BLACK);
60 g.fillEllipse(Rectangle<float>(thumbWidth, thumbWidth).withCentre(thumbPoint));
61
62 g.drawEllipse(bounds.getCentreX() - 16, bounds.getCentreY() - 16, 32, 32, 0.5f);
63}
64
65void NeuralNoteLNF::drawTooltip(Graphics& g, const String& text, int width, int height)
66{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected