Angled Sliders Issue
-
@trillbilly
value * 20000
Why not set the slider's range to match the attack knob's? -
@d-healey I tried, but then the knob wasn't functioning at all. It would only function/slide if I have the range set to 0-1.
-
Ah ok I see what's happening. When you move the slider you're not actually moving the slider, you're clicking on the panel and the panel is setting the slider's value. You need to call .changed() after the value is set.
-
@d-healey Ok, Ill try this. Am I calling ".changed()" to the panel or to the slider?
-
@trillbilly Find the bit of code where the knob's value is being set (it's in the panel's callback). Then following that you need to add .changed() to the knob.
-
@d-healey In the panels MouseCallback I see what I believe is the bit of code setting the knobs value.
knobs[sliderIndex].setValue(Math.range(xNorm * 1.3, 0.0, 3.0));
If I try adding "knobs.changed();" or "Attackknb.changed();" after this I get an error anytime the knob is changed that reads "Unknown function 'changed'".
I've tried this below each other bit of code within the panels MouseCallback as well with the same error message.
-
@trillbilly said in Angled Sliders Issue:
If I try adding "knobs.changed();"
knobs is the name of the array. You need to refer to the element, just like the line you see for setting the value.
Try
knobs[sliderIndex].changed();
-
@d-healey Correct you are. Much appreciated.
-
@d-healey Hi David, another question about this. So I have UI buttons that change the color of background, buttons and sliders. I duplicated the CSS sliders and grouped them according to color. Everything works as it should except the CSS sliders do not stay "Linked", even if I use the "Link To" option in the properties editor. Is there a way I can ensure all of these get linked and keep the same value (Attack links with other Attacks, Decay with other decays, etc)?
Is there an easier way instead of copying the sliders panel multiple times that I can just change the color of the sliders when a button is clicked since they are scripted?
-
@trillbilly said in Angled Sliders Issue:
Is there an easier way instead of copying the sliders panel multiple times that I can just change the color of the sliders when a button is clicked since they are scripted?
Yes, that's what CSS is great for. Just swap out the class for a different class that has different colours. I haven't used the CSS stuff in HISE yet, but this is how it works in web dev.
"Traditionally" in HISE you'd change the colour properties of the component, but I'm guessing this isn't needed when using CSS.
-
@d-healey Thanks. Im trying to understand how it would work. So something like when a button is clicked it changes from "laf" to "laf1"?
Here is the CSS and the LAF functions in my script. Am I correct with the above statement?
const var laf = Content.createLocalLookAndFeel(); // CSS for the win! laf.setInlineStyleSheet(" .scriptslider { background-color: var(--bgColour); margin: 27px 0px; transform: rotate(-20deg); border-radius: 100%; box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.0); } .scriptslider::before { content: ''; width: max(100vh, calc(100% * var(--value))); background: rgba(101,69,145, 1.0); margin: 0.5px; border-radius: 100%; } "); const var knobs = [Content.getComponent("Attackknb"), Content.getComponent("Decayknb"), Content.getComponent("Sustainknb"), Content.getComponent("Releaseknb")]; for(k in knobs) k.setLocalLookAndFeel(laf);
-
@trillbilly Are you familiar with CSS as used on websites?
-
@d-healey Not at all. This is my CSS introduction.
-
@trillbilly Might be worth exploring it a little bit, even just watching some YouTube videos.
With CSS you can dynamically assign classes to an element - a class is just an identifier, but one that can be assigned to multiple elements, so it doesn't uniquely identify one element.
Any elements with that class will take on the properties defined in the style sheet.
So if you change the class you change the styling. In your case you'll be better off using an external style sheet and defining different classes for your different styles. Then just swap out the class that's assigned to the components and they should take on the new styling - again I've not used it but this is what I'd expect based on the documentation and how CSS works on a website.
-
@d-healey Ok, thanks. I will have to dig deeper into this later on. I appreciate it.
-
Just swap out the class for a different class that has different colours.
You can also use the component's colour properties as CSS variable:
const var bs = [Content.addButton("Button1", 0, 0), Content.addButton("Button2", 0, 50)]; const var laf = Content.createLocalLookAndFeel(); laf.setInlineStyleSheet(" button { /** Note that you need to use the background-color property instead of the generic *background* property as it cannot deduce the type from the variable statement. */ background-color: var(--bgColour); } "); for(b in bs) b.setLocalLookAndFeel(laf); const var t = Engine.createTimerObject(); t.setTimerCallback(function() { for(b in bs) { b.set("bgColour", Colours.withHue(Colours.red, Math.random())); } }); t.startTimer(300);
-
@Christoph-Hart Awesome, thank you.
Just out of curiosity, trying to link the scripted knobs/sliders via the Property Editor does not work. Is this simply because they are scripted or something to do with the CSS implemented?