Vertical + horizontal slider script
-
Hello, for those who want to save time, here's a simple script for a horizontal slider in Look and Feel, as I didn't find one in the forum. It's up to you to customize this script and assign your own colors.
//horizontal slider laf.registerFunction("drawLinearSlider", function(g, obj) { var a = obj.area; g.setColour(Colours.blue); g.fillRoundedRectangle([0, 10, a[2], 12], 6); var x = obj.valueNormalized * a[2]; g.setColour(Colours.red); g.fillRoundedRectangle([0, 10, x , 12], 6); g.setColour(Colours.green); g.fillRoundedRectangle([x - 6 , 0, 12, 30], 6); });
//vertical slider laf.registerFunction("drawLinearSlider", function(g, obj) { var a = obj.area; g.setColour(Colours.blue); g.fillRoundedRectangle([9, 0, 12, a[3]], 6); var x = obj.valueNormalized * a[3]; g.setColour(Colours.red); g.fillRoundedRectangle([9, 0, 12 , x], 6); g.setColour(Colours.green); g.fillRoundedRectangle([0 , x - 6, 30, 12], 6); });
-
Hey that looks nice and clean.
I have two suggestions.
Use local look and feel, so each laf object has a different name.
lafVerticalSlider
,lafHorizontalSlider
, etc.Instead of hardcoding the colours use the colour properties of the components (they are available in
obj
). -
@d-healey Thank you, I am taking notes!