How to make a slider label have rounded corners

I actually posted a link called LookAndFeel_V2, if you’d clicked it it would have brought you to the source in github, here inlined for your convenience:

…click it… :wink:

@daniel How do you do the inline github link out of interest?

Just click on a line number in github, copy that URL onto a separate line. The rest happens automatically…

1 Like

This is what i have now. but the border is still black (i want white) and i want the text to show in white but i think im doing it wrong aha.

class CustomLAF : public juce::LookAndFeel_V4
{
public:
	void drawLabel(Graphics& g, Label& label)override {
    		g.drawRoundedRectangle(0, 0, 75, 30, 10, 3);
    		g.setColour(label.findColour(Label::backgroundColourId));
    		g.fillRoundedRectangle(label.getLocalBounds().toFloat(), 5);
    		g.drawFittedText(label.getText(),0,0,75,30,
    			Justification::Flags(),1,0.f);

		g.setColour(label.findColour(Label::outlineColourId));
		if (!label.isBeingEdited())
		{
			auto alpha = label.isEnabled() ? 1.0f : 0.5f;
			const Font font(getLabelFont(label));

			g.setColour(label.findColour(Label::textColourId).withMultipliedAlpha(alpha));
			g.setFont(font);
		}
	} 

};

a) don’t use fixed numbers in the LnF, since the component could be of a different size. Use the numbers label.getLocalBounds() returns instead.
b) call the drawRoundedRectangle() last, since all painting paints over the previous call
c) to set the colours, there is a ColourId -> Colour map in the lookAndFeel, hence you can call e.g. otherLookAndFeel.setColour (Label::outlineColourId, Colours::white); and it will be used in all Labels you set the lookAndFeel to

HTH