20 float rotaryStartAngle,
float rotaryEndAngle, juce::Slider& slider)
24 float radius((
float)juce::jmin(width / 2, height / 2));
26 const float centreX(x + width * 0.5f);
27 const float centreY(y + height * 0.5f);
28 const float rx(centreX - radius);
29 const float ry(centreY - radius);
30 const float rw(radius * 2.0f);
31 const float angle(rotaryStartAngle + sliderPos * (rotaryEndAngle - rotaryStartAngle));
32 const bool isMouseOver(slider.isMouseOverOrDragging() && slider.isEnabled());
33 juce::DropShadow shadow(juce::DropShadow(juce::Colours::black.withAlpha(0.22f), 2,
34 juce::Point<int>(3, 3)));
35 auto fillColour = findColour(Slider::ColourIds::rotarySliderFillColourId);
36 auto backgroundColour = findColour(Slider::ColourIds::backgroundColourId);
37 auto disabledFillColour = fillColour.darker();
38 auto disabledBackgroundColour = backgroundColour.darker();
42 const float thickness = 0.75f;
46 g.fillPath(p, juce::AffineTransform::rotation(angle).translated(centreX, centreY));
49 slider.isEnabled() ? g.setColour(backgroundColour) : g.setColour(disabledBackgroundColour);
52 juce::Path outlineArc;
53 outlineArc.addPieSegment(rx, ry, rw, rw, rotaryStartAngle, rotaryEndAngle, thickness);
54 outlineArc.closeSubPath();
55 g.fillPath(outlineArc);
58 slider.isEnabled() ? g.setColour(fillColour) : g.setColour(disabledFillColour);
60 filledArc.addPieSegment(rx, ry, rw, rw, rotaryStartAngle, angle, thickness);
61 g.fillPath(filledArc);
62 shadow.drawForPath(g, outlineArc);
66 if (slider.isEnabled())
68 g.setColour(fillColour.withAlpha(isMouseOver ? 1.0f : 0.7f));
72 g.setColour(disabledBackgroundColour);
76 p.addEllipse(-0.4f * rw, -0.4f * rw, rw * 0.8f, rw * 0.8f);
77 juce::PathStrokeType(rw * 0.1f).createStrokedPath(p, p);
79 p.addLineSegment(juce::Line<float>(0.0f, 0.0f, 0.0f, -radius), rw * 0.2f);
81 g.fillPath(p, juce::AffineTransform::rotation(angle).translated(centreX, centreY));
89 float sliderPos,
float ,
float ,
92 slider.setPopupDisplayEnabled(
false,
false,
nullptr);
95 float mouseOverAlpha =
113 auto scaledArcCenter = scaledSquare.getCentre();
119 juce::Path outlineArc;
122 outlineArc.closeSubPath();
123 g.setColour(trackColourOuter);
124 g.fillPath(outlineArc);
129 trackArc.closeSubPath();
130 g.setColour(trackColourInner);
131 g.fillPath(trackArc);
133 if (slider.isMouseOverOrDragging())
137 auto thumbEnd = scaledThumbEnd.rotatedAboutOrigin(positionRadians) + scaledArcCenter;
138 auto thumbStart = scaledThumbStart.rotatedAboutOrigin(positionRadians) + scaledArcCenter;
139 thumb.addLineSegment(juce::Line<float>(thumbStart, thumbEnd),
layout.
thumbWidth);
140 g.setColour(thumbColour);
145 Font font(scaledTextRectangle.getHeight(), Font::FontStyleFlags::plain);
148 g.setColour(textColour);
149 g.drawFittedText(value, scaledTextRectangle.toNearestInt(), Justification::centred,
layout.
maxTextLines);
158 setColour(TextButton::ColourIds::textColourOffId, Colour(0xff81AFFF));
159 setColour(TextButton::ColourIds::textColourOnId, Colour(0xff81AFFF));
163 bool shouldDrawButtonAsHighlighted,
164 bool shouldDrawButtonAsDown)
166 Font::FontStyleFlags flag = Font::FontStyleFlags::plain;
168 if (shouldDrawButtonAsDown)
169 flag = Font::FontStyleFlags::bold;
171 Font font(getTextButtonFont(button, button.getHeight()));
172 font.setStyleFlags(flag);
176 g.setColour(Colour(0xff81AFFF));
178 const int yIndent = jmin(4, button.proportionOfHeight(0.3f));
179 const int cornerSize = jmin(button.getHeight(), button.getWidth()) / 2;
181 const int fontHeight = roundToInt(font.getHeight() * 0.6f);
182 const int leftIndent = jmin(fontHeight, 2 + cornerSize / (button.isConnectedOnLeft() ? 4 : 2));
183 const int rightIndent = jmin(fontHeight, 2 + cornerSize / (button.isConnectedOnRight() ? 4 : 2));
184 const int textWidth = button.getWidth() - leftIndent - rightIndent;
187 g.drawFittedText(button.getButtonText(), leftIndent, yIndent, textWidth, button.getHeight() - yIndent * 2,
188 Justification::centred, 2);
The default colours and visuals to be used in Krotos plugins.
struct krotos::Krotos_LookAndFeel::Layout layout
ColourScheme getKrotosDefaultColourScheme()
Definition Krotos_LookAndFeel.h:153
void drawRotarySlider(Graphics &g, int x, int y, int width, int height, float sliderPos, float rotaryStartAngle, float rotaryEndAngle, juce::Slider &slider) override
Definition Krotos_LookAndFeel.cpp:88
Krotos_LookAndFeel()
Definition Krotos_LookAndFeel.cpp:14
Definition AirAbsorptionFilter.cpp:2
const juce::Rectangle< float > enclosingSquareTrack
Definition Krotos_LookAndFeel.h:127
const float endRadians
Definition Krotos_LookAndFeel.h:113
const float thumbWidth
Definition Krotos_LookAndFeel.h:120
const juce::Point< float > thumbStart
Definition Krotos_LookAndFeel.h:134
const juce::Rectangle< float > enclosingSquare
Definition Krotos_LookAndFeel.h:126
const float enabledAlphaEnabled
Definition Krotos_LookAndFeel.h:145
const int maxTextLines
Definition Krotos_LookAndFeel.h:121
const Colour textColour
Definition Krotos_LookAndFeel.h:140
const float sliderValueMax
Definition Krotos_LookAndFeel.h:119
const juce::Rectangle< float > textRectangle
Definition Krotos_LookAndFeel.h:129
const Colour trackColourOuter
Definition Krotos_LookAndFeel.h:138
const float enabledAlphaDisabled
Definition Krotos_LookAndFeel.h:146
const juce::Rectangle< float > enclosingRectangle
Definition Krotos_LookAndFeel.h:128
const Colour trackColourInner
Definition Krotos_LookAndFeel.h:137
const float KerningFactor
Definition Krotos_LookAndFeel.h:123
const Colour thumbColour
Definition Krotos_LookAndFeel.h:139
const float trackArcInnerProportion
Definition Krotos_LookAndFeel.h:117
const float mouseOverAlphaDefault
Definition Krotos_LookAndFeel.h:148
const float sliderValueMin
Definition Krotos_LookAndFeel.h:118
const juce::Point< float > thumbEnd
Definition Krotos_LookAndFeel.h:133
const float outlineArcInnerProportion
Definition Krotos_LookAndFeel.h:116
const float startRadians
Definition Krotos_LookAndFeel.h:112
const int numDecimalPlaces
Definition Krotos_LookAndFeel.h:122
const float mouseOverAlphaOver
Definition Krotos_LookAndFeel.h:149
static const Identifier AlertHeightID
Definition Krotos_LookAndFeel.h:24
static const Identifier AlertWidthID
Definition Krotos_LookAndFeel.h:23
static const Identifier RoundedCornerID
Specify which corners to round on a component.
Definition Krotos_LookAndFeel.h:38
static const Identifier IconPositionID
Where to place the icon. This determines how the text is offset.
Definition Krotos_LookAndFeel.h:58
static const Identifier UseCustomIcon
Hide the default dropdown arrow icon, leaving an empty spot to draw a custom icon.
Definition Krotos_LookAndFeel.h:54
static const Identifier DisableHover
Disable Mouse Hover affecting drawing over buttons, etc.
Definition Krotos_LookAndFeel.h:33
static const Identifier FontSize
The size of the font in the ComboBox label.
Definition Krotos_LookAndFeel.h:68