panel value privacy?
-
@d-healey I guess I'm not storing it, how would one approach a return statement? :)
-
Ok added
return widget;
As well as messing with
this.changed();
in the mouse callback and still not working, do I need to add some control callback or something like a regular UI element?
-
I avoid factory functions 99% of the time. How many buttons/panels are you adding?
-
39 lol
i'm making a "randomize all" button but need to allow end users to select individual elements to be ignored, so one for each gui element
everything else works, just can't get the value in a different callback, I could try this.data.val or something, but I'd still need to reference the value in oninit which also probably wouldn't work
-
here's the whole code if anyone wants to dig through (prepare to vomit)
//Randomize Everything //Create function to design buttons. //Persistence panel: //list of buttons to create const var randomizationButtons = ["Button_RandomizeArpNotes", "Button_RandomizeArpVelocity", "Button_RandomizeArpLength", "Button_RandomizeArpSteps", "Button_RandomizeArpSpeed", "Button_RandomizeArpOctaves", "Button_RandomizeArpSwing", "Button_RandomizeADSRAttack", "Button_RandomizeADSRDecay", "Button_RandomizeADSRSustain", "Button_RandomizeADSRRelease", "Button_RandomizeFXFilterFreq", "Button_RandomizeFXFilterQ", "Button_RandomizeFXAmpLow", "Button_RandomizeFXAmpMid", "Button_RandomizeFXAmpHigh", "Button_RandomizeFXAmpDrive", "Button_RandomizeFXAmpOutput", "Button_RandomizeFXAmpCabinet", "Button_RandomizeFXDriveWaveShaperGain", "Button_RandomizeFXDriveTubeDriveGain", "Button_RandomizeFXWidenerWidth", "Button_RandomizeFXStutterRate", "Button_RandomizeFXStutterAmount", "Button_RandomizeFXPhaserRateA", "Button_RandomizeFXPhaserRateB", "Button_RandomizeFXPhaserFeedback", "Button_RandomizeFXPhaserMix", "Button_RandomizeFXDegradeBitDepth", "Button_RandomizeFXSampleHold", "Button_RandomizeFXReverbSize", "Button_RandomizeFXReverbDamping", "Button_RandomizeFXReverbWidth", "Button_RandomizeFXReverbMix", "Button_RandomizeFXDelayTimeL", "Button_RandomizeFXDelayTimeR", "Button_RandomizeFXDelayFeedbackL", "Button_RandomizeFXDelayFeedbackR", "Button_RandomizeFXDelayMix", ]; const var randomizationControls = ["SliderPack_ArpNotes", "SliderPack_ArpVelocity", "SliderPack_ArpLength", "Slider_ArpSteps", "Slider_ArpSpeed", "Slider_ArpOctave", "Slider_ArpSwing", "Slider_Attack", "Slider_Decay", "Slider_Sustain", "Slider_Release", "Slider_FilterFreq", "Slider_FilterQ", "Slider_AmpEQLow", "Slider_AmpEQMid", "Slider_AmpEQHigh", "Slider_AmpGain", "Slider_AmpOutput", "ComboBox_AmpCabSelect", "Slider_DriveWaveshaperGain", "Slider_DriveTubeGain", "Slider_WidthAmount", "Slider_StutterLFORate", "Slider_StutterLFOAmount", "Slider_PhaserRateA", "Slider_PhaserRateB", "Slider_PhaserFeedback", "Slider_PhaserMix", "Slider_DegradeBitDepth", "Slider_DegradeSampleHold", "Slider_ReverbSize", "Slider_ReverbDamping", "Slider_ReverbWidth", "Slider_ReverbMix", "Slider_DelayTimeLeftFree", "Slider_DelayTimeRightFree", "Slider_DelayFeedbackLeft", "Slider_DelayFeedbackRight", "Slider_DelayMix", ]; //our starting point for Y position var randomButtonYOffset = 226; const var path = Content.createPath(); var randomizeButtonWidth = 10; var randomizeButtonHeight = 10; inline function randomizeButtonPaintRoutineDefault() { this.setPaintRoutine(function(g) { if (this.getValue() == 0) { g.setColour(Colours.lightgrey); g.fillRoundedRectangle([0, 0, this.getWidth(), this.getHeight()], 2.0); g.setColour(Colours.black); g.setFont("Arial Bold", 6); g.drawAlignedText("R", [0, 0, this.getWidth(), this.getHeight()], "centred"); } else { g.setColour(Colours.lightblue); g.fillRoundedRectangle([0, 0, this.getWidth(), this.getHeight()], 2.0); g.setColour(Colours.black); g.setFont("Arial Bold", 6); g.drawAlignedText("R", [0, 0, this.getWidth(), this.getHeight()], "centred"); } }); } inline function randomizeButtonPaintRoutineHover() { this.setPaintRoutine(function(g) { g.setColour(Colours.lightgrey); g.fillRoundedRectangle([1, 1, this.getWidth()-2, this.getHeight()-2], 2.0); g.setColour(Colours.black); g.setFont("Arial Bold", 5); g.drawAlignedText("R", [0, 0, this.getWidth(), this.getHeight()], "centred"); }); } var func; inline function createRandomizeButton(name) { local x = 50; local y = 50; local parent = ""; local widget = Content.addPanel(name, x, y); widget.data.name = name; widget.setPaintRoutine(function(g) { if (this.getValue() == 0) { g.setColour(Colours.lightgrey); g.fillRoundedRectangle([0, 0, this.getWidth(), this.getHeight()], 2.0); g.setColour(Colours.black); g.setFont("Arial Bold", 6); g.drawAlignedText("R", [0, 0, this.getWidth(), this.getHeight()], "centred"); } else { g.setColour(Colours.lightblue); g.fillRoundedRectangle([0, 0, this.getWidth(), this.getHeight()], 2.0); g.setColour(Colours.black); g.setFont("Arial Bold", 6); g.drawAlignedText("R", [0, 0, this.getWidth(), this.getHeight()], "centred"); } }); switch (name) { //Arpeggiator Controls case "Button_RandomizeArpNotes": x = 369; y = 22; parent = "Panel_Arp"; break; case "Button_RandomizeArpVelocity": x = 369; y = 124; parent = "Panel_Arp"; break; case "Button_RandomizeArpLength": x = 369; y = 188; parent = "Panel_Arp"; break; case "Button_RandomizeArpSteps": x = 85; y = 30; parent = "Panel_Arp"; break; case "Button_RandomizeArpSpeed": x = 85; y = 80; parent = "Panel_Arp"; break; case "Button_RandomizeArpOctaves": x = 85; y = 129; parent = "Panel_Arp"; break; case "Button_RandomizeArpSwing": x = 85; y = 180; parent = "Panel_Arp"; break; //ADSR Controls case "Button_RandomizeADSRAttack": x = 62; y = 146; parent = "Panel_AHDSR"; break; case "Button_RandomizeADSRDecay": x = 132; y = 146; parent = "Panel_AHDSR"; break; case "Button_RandomizeADSRSustain": x = 202; y = 146; parent = "Panel_AHDSR"; break; case "Button_RandomizeADSRRelease": x = 272; y = 146; parent = "Panel_AHDSR"; break; //FX //Filter case "Button_RandomizeFXFilterFreq": x = 30; y = 152; parent = "Panel_FilterSettings"; break; case "Button_RandomizeFXFilterQ": x = 225; y = 152; parent = "Panel_FilterSettings"; break; //Amplifier case "Button_RandomizeFXAmpLow": x = 82; y = 65; parent = "Panel_AmpSettings"; break; case "Button_RandomizeFXAmpMid": x = 154; y = 65; parent = "Panel_AmpSettings"; break; case "Button_RandomizeFXAmpHigh": x = 226; y = 65; parent = "Panel_AmpSettings"; break; case "Button_RandomizeFXAmpDrive": x = 90; y = 120; parent = "Panel_AmpSettings"; break; case "Button_RandomizeFXAmpOutput": x = 184; y = 120; parent = "Panel_AmpSettings"; break; case "Button_RandomizeFXAmpCabinet": x = 206; y = 180; parent = "Panel_AmpSettings"; break; //Drive Controls case "Button_RandomizeFXDriveWaveShaperGain": x = 100; y = 102; parent = "Panel_DriveSettings"; break; case "Button_RandomizeFXDriveTubeDriveGain": x = 100; y = 184; parent = "Panel_DriveSettings"; break; //Widener Controls case "Button_RandomizeFXWidenerWidth": x = 100; y = 60; parent = "Panel_WidthSettings"; break; case "Button_RandomizeFXStutterRate": x = 100; y = 150; parent = "Panel_WidthSettings"; break; case "Button_RandomizeFXStutterAmount": x = 246; y = 150; parent = "Panel_WidthSettings"; break; //Phaser Controls case "Button_RandomizeFXPhaserRateA": x = 110; y = 86; parent = "Panel_PhaserSettings"; break; case "Button_RandomizeFXPhaserRateB": x = 110; y = 150; parent = "Panel_PhaserSettings"; break; case "Button_RandomizeFXPhaserFeedback": x = 246; y = 86; parent = "Panel_PhaserSettings"; break; case "Button_RandomizeFXPhaserMix": x = 246; y = 150; parent = "Panel_PhaserSettings"; break; //Degrade Controls case "Button_RandomizeFXDegradeBitDepth": x = 65; y = 100; parent = "Panel_DegradeSettings"; break; case "Button_RandomizeFXSampleHold": x = 200; y = 100; parent = "Panel_DegradeSettings"; break; //Reverb Controls case "Button_RandomizeFXReverbSize": x = 104; y = 82; parent = "Panel_ReverbSettings"; break; case "Button_RandomizeFXReverbDamping": x = 244; y = 82; parent = "Panel_ReverbSettings"; break; case "Button_RandomizeFXReverbWidth": x = 104; y = 140; parent = "Panel_ReverbSettings"; break; case "Button_RandomizeFXReverbMix": x = 244; y = 140; parent = "Panel_ReverbSettings"; break; //Delay Controls case "Button_RandomizeFXDelayTimeL": x = 120; y = 60; parent = "Panel_DelaySettings"; break; case "Button_RandomizeFXDelayTimeR": x = 250; y = 60; parent = "Panel_DelaySettings"; break; case "Button_RandomizeFXDelayFeedbackL": x = 120; y = 110; parent = "Panel_DelaySettings"; break; case "Button_RandomizeFXDelayFeedbackR": x = 250; y = 110; parent = "Panel_DelaySettings"; break; case "Button_RandomizeFXDelayMix": x = 250; y = 174; parent = "Panel_DelaySettings"; break; default: } //Set size Content.setPropertiesFromJSON(name, { "width": randomizeButtonWidth, "height": randomizeButtonHeight, "allowCallbacks": "Clicks & Hover", "opaque": 1, "saveInPreset": 1, "parentComponent": parent, }); widget.setMouseCallback(function(event) { if (event.clicked) { this.setValue(1 - this.getValue()); this.changed(); Console.print(this.getValue()); } else if (event.hover) { randomizeButtonPaintRoutineHover(); } else { randomizeButtonPaintRoutineDefault(); } }); widget.setPosition(x, y, randomizeButtonWidth, randomizeButtonHeight); return widget; } //Populate buttons. for (r in randomizationButtons) { //Create each button createRandomizeButton(r); Console.print(r); //sets a new Y position for the next button randomButtonYOffset += 22; } //Create individual functions for buttons. inline function randomArp() { randomizeArpNotes(); randomizeArpVelocity(); randomizeArpLength(); } inline function randomizeArpNotes() { Console.print("Arp Notes has been randomized!"); for (s=0; s<SliderPack_ArpNotes.getNumSliders(); s++) { SliderPack_ArpNotes.setSliderAtIndex(s, Math.randInt(-24,24)); SliderPack_ArpNotes.changed(); } } inline function randomizeArpVelocity() { Console.print("Arp Vel has been randomized!"); for (s=0; s<SliderPack_ArpVelocity.getNumSliders(); s++) { SliderPack_ArpVelocity.setSliderAtIndex(s, Math.randInt(1,127)); SliderPack_ArpVelocity.changed(); } } inline function randomizeArpLength() { Console.print("Arp Length has been randomized!"); for (s=0; s<SliderPack_ArpLength.getNumSliders(); s++) { SliderPack_ArpLength.setSliderAtIndex(s, Math.randInt(1,127)); SliderPack_ArpLength.changed(); } } inline function randomPad() { Console.print("ADSR has been randomized as Pad!"); //Attack Slider_Attack.setValue(Math.randInt(5, 20000)); Slider_Attack.changed(); //Decay Slider_Decay.setValue(Math.randInt(5, 5000)); Slider_Decay.changed(); //Sustain Slider_Sustain.setValue(0); Slider_Sustain.changed(); //Release Slider_Release.setValue(Math.randInt(5, 20000)); Slider_Release.changed(); } inline function randomStab() { Console.print("ADSR has been randomized as stab!"); Console.print(Button_RandomizeADSRAttack.getValue()); //problematic line //Attack Slider_Attack.setValue(Math.randInt(5, 150)); Slider_Attack.changed(); //Decay Slider_Decay.setValue(Math.randInt(5, 5000)); Slider_Decay.changed(); //Sustain Slider_Sustain.setValue(Math.randInt(-100, 0)); Slider_Sustain.changed(); //Release Slider_Release.setValue(Math.randInt(5, 2000)); Slider_Release.changed(); /* //Attack if (Button_RandomizeADSRAttack.getValue() == 1) { Slider_Attack.setValue(Math.randInt(5, 150)); Slider_Attack.changed(); } //Decay if (Button_RandomizeADSRDecay.getValue() == 1) { Slider_Decay.setValue(Math.randInt(5, 5000)); Slider_Decay.changed(); } //Sustain if (Button_RandomizeADSRSustain.getValue() == 1) { Slider_Sustain.setValue(Math.randInt(-100, 0)); Slider_Sustain.changed(); } //Release if (Button_RandomizeADSRRelease.getValue() == 1) { Slider_Release.setValue(Math.randInt(5, 2000)); Slider_Release.changed(); } */ } inline function randomFX() { local outputCompensation; local sliders = [ Slider_ReverbSize, Slider_ReverbWidth, Slider_ReverbDamping, Slider_WidthAmount, Slider_StutterLFORate, Slider_PhaserRateA, Slider_PhaserRateB, Slider_AmpEQLow, Slider_AmpEQMid, Slider_AmpEQHigh]; local mixSliders = [ Slider_CompMix, Slider_ReverbMix, Slider_PhaserMix, Slider_DelayFeedbackLeft, Slider_DelayFeedbackRight, Slider_PhaserFeedback]; //bypass buttons for (b in FXBypassButtons) { b.setValue(Math.round(Math.random())); b.changed(); } //sliders for (s in sliders) { s.setValue(Math.randInt(s.get("min"), s.get("max"))); s.changed(); } Console.print("FX has been randomized!"); //float sliders for (m in mixSliders) { m.setValue(Math.random()); m.changed(); } //degrade Slider_DegradeBitDepth.setValue(Math.randInt(4, 16)); Slider_DegradeBitDepth.changed(); Slider_DegradeSampleHold.setValue(Math.randInt(1, 24)); Slider_DegradeSampleHold.changed(); //filter Slider_FilterFreq.setValue(Math.randInt(350, 20000)); Slider_FilterFreq.changed(); local randomFloat = 0.0; randomFloat = Math.randInt(1, 4) - Math.range(Math.random(), 0.0, 0.7); randomFloat = Engine.doubleToString(randomFloat, 2); randomFloat = Math.range(randomFloat, 0.3, 4.0); Slider_FilterQ.setValue(randomFloat); Slider_FilterQ.changed(); //drive Slider_DriveWaveshaperGain.setValue(Math.randInt(0, 12)); Slider_DriveWaveshaperGain.changed(); Slider_DriveTubeGain.setValue(Math.randInt(0, 12)); Slider_DriveTubeGain.changed(); //amplifier Slider_AmpGain.setValue(Math.randInt(0, 100)); Slider_AmpGain.changed(); outputCompensation = Engine.getDecibelsForGainFactor(Slider_AmpGain.getValue() / 60); outputCompensation = -14 - outputCompensation; outputCompensation = Math.range(outputCompensation, -14, 0); Slider_AmpOutput.setValue(Math.round(outputCompensation)); Slider_AmpOutput.changed(); ComboBox_AmpCabSelect.setValue(Math.randInt(1, 14)); ComboBox_AmpCabSelect.changed(); //delay Button_DelaySync.setValue(Math.round(Math.random())); Button_DelaySync.changed(); if (Button_DelaySync.getValue() == 1) { local controls = [Slider_DelayTimeLeftSynced, Slider_DelayTimeRightSynced, Slider_DelayFeedbackLeft, Slider_DelayFeedbackRight]; for (c in controls) { c.setValue(Math.randInt(c.get("min"), c.get("max"))); c.changed(); } } else { local controls = [Slider_DelayTimeLeftFree, Slider_DelayTimeRightFree, ]; for (c in controls) { c.setValue(Math.randInt(c.get("min"), c.get("max"))); c.changed(); } } randomFloat = Math.range(Math.random(), 0.0, 0.5); randomFloat = Engine.doubleToString(randomFloat, 2); randomFloat = Math.range(randomFloat, 0.0, 0.5); Slider_DelayMix.setValue(randomFloat); Slider_DelayMix.changed(); } //Randomize Panel const var Button_OpenRandomizePanel = Content.getComponent("Button_OpenRandomizePanel"); const var Panel_RandomizeContainer = Content.getComponent("Panel_RandomizeContainer"); //Open the panel inline function onButton_OpenRandomizePanelControl(component, value) { Panel_RandomizeContainer.set("visible", value); }; Content.getComponent("Button_OpenRandomizePanel").setControlCallback(onButton_OpenRandomizePanelControl); //Populate the panel const var randomButtons = ["Button_RandomAll", "Button_RandomArp", "Button_RandomStab", "Button_RandomPad", "Button_RandomFX"]; var randomButtonsYOffset = 0; inline function randomAll() { local chance = Math.random(); if (chance < 0.5) randomStab(); else randomPad(); randomArp(); randomFX(); } inline function createRandomButton(name, count) { local widget = Content.addPanel(name); local y = Panel_RandomizeContainer.getHeight() / 5 * count; switch (name) { case "Button_RandomAll": widget.data.name = "ALL"; widget.data.func = randomAll; break; case "Button_RandomArp": widget.data.name = "ARP"; widget.data.func = randomArp; break; case "Button_RandomStab": widget.data.name = "STAB"; widget.data.func = randomStab; break; case "Button_RandomPad": widget.data.name = "PAD"; widget.data.func = randomPad; break; case "Button_RandomFX": widget.data.name = "FX"; widget.data.func = randomFX; break; default: } widget.setPaintRoutine(function(g) { g.fillAll(0x30000000); g.setColour(0x30000000); g.fillRoundedRectangle([0,0,this.getWidth(),this.getHeight()], 4.0); g.setColour(Colours.white); g.setFont("Arial", 11); g.drawAlignedText(this.data.name, [0, 0, this.getWidth(), this.getHeight()], "centred"); }); widget.setMouseCallback(function(event) { if (event.clicked) { Console.print(this.data.name); this.data.func(); } else if (event.hover) { this.setPaintRoutine(function(g) { g.setColour(Colours.darkgrey); g.fillRoundedRectangle([0,0,this.getWidth(),this.getHeight()], 4.0); g.setColour(Colours.white); g.setFont("Arial", 11); g.drawAlignedText(this.data.name, [0, 0, this.getWidth(), this.getHeight()], "centred"); }); } else { this.setPaintRoutine(function(g) { g.fillAll(0x30000000); g.setColour(0x30000000); g.fillRoundedRectangle([0,0,this.getWidth(),this.getHeight()], 4.0); g.setColour(Colours.white); g.setFont("Arial", 11); g.drawAlignedText(this.data.name, [0, 0, this.getWidth(), this.getHeight()], "centred"); }); } }); widget.setPosition(x, y, randomizeButtonWidth, randomizeButtonHeight); //Set size Content.setPropertiesFromJSON(name, { "width": Panel_RandomizeContainer.getWidth(), "height": (Panel_RandomizeContainer.getHeight() / 5) - 1, "allowCallbacks": "Clicks & Hover", "opaque": 0, "saveInPreset": 0, "parentComponent": "Panel_RandomizeContainer", }); } for (r = 0; r<randomButtons.length; r++) { Console.print(randomButtons[r]); createRandomButton(randomButtons[r], r); } //Randomization Buttons Visibility const var randomizationButtonsVisibilityData = [110,109,0,0,128,64,0,0,200,65,113,6,129,207,65,25,4,158,64,0,0,56,66,0,0,200,65,109,0,0,128,64,0,0,200,65,113,6,129,207,65,131,64,52,66,0,0,56,66,0,0,200,65,109,0,0,112,65,0,0,200,65,98,0,0,112,65,23,217,155,65,23,217,155,65,0,0,112,65,0,0,200,65,0,0, 112,65,98,233,38,244,65,0,0,112,65,0,0,12,66,23,217,155,65,0,0,12,66,0,0,200,65,98,0,0,12,66,233,38,244,65,233,38,244,65,0,0,12,66,0,0,200,65,0,0,12,66,98,23,217,155,65,0,0,12,66,0,0,112,65,233,38,244,65,0,0,112,65,0,0,200,65,99,109,0,0,112,65,0,0,200, 65,98,0,0,112,65,23,217,155,65,23,217,155,65,0,0,112,65,0,0,200,65,0,0,112,65,98,233,38,244,65,0,0,112,65,0,0,12,66,23,217,155,65,0,0,12,66,0,0,200,65,98,0,0,12,66,233,38,244,65,233,38,244,65,0,0,12,66,0,0,200,65,0,0,12,66,98,23,217,155,65,0,0,12,66, 0,0,112,65,233,38,244,65,0,0,112,65,0,0,200,65,99,109,0,0,112,65,0,0,200,65,98,0,0,112,65,23,217,155,65,23,217,155,65,0,0,112,65,0,0,200,65,0,0,112,65,98,233,38,244,65,0,0,112,65,0,0,12,66,23,217,155,65,0,0,12,66,0,0,200,65,98,0,0,12,66,233,38,244,65, 233,38,244,65,0,0,12,66,0,0,200,65,0,0,12,66,98,23,217,155,65,0,0,12,66,0,0,112,65,233,38,244,65,0,0,112,65,0,0,200,65,99,109,0,0,184,65,0,0,200,65,98,0,0,184,65,2,43,191,65,2,43,191,65,0,0,184,65,0,0,200,65,0,0,184,65,98,254,212,208,65,0,0,184,65,0, 0,216,65,2,43,191,65,0,0,216,65,0,0,200,65,98,0,0,216,65,254,212,208,65,254,212,208,65,0,0,216,65,0,0,200,65,0,0,216,65,98,2,43,191,65,0,0,216,65,0,0,184,65,254,212,208,65,0,0,184,65,0,0,200,65,99,109,0,0,184,65,0,0,200,65,98,0,0,184,65,2,43,191,65,2, 43,191,65,0,0,184,65,0,0,200,65,0,0,184,65,98,254,212,208,65,0,0,184,65,0,0,216,65,2,43,191,65,0,0,216,65,0,0,200,65,98,0,0,216,65,254,212,208,65,254,212,208,65,0,0,216,65,0,0,200,65,0,0,216,65,98,2,43,191,65,0,0,216,65,0,0,184,65,254,212,208,65,0,0, 184,65,0,0,200,65,99,109,0,0,184,65,0,0,200,65,98,0,0,184,65,2,43,191,65,2,43,191,65,0,0,184,65,0,0,200,65,0,0,184,65,98,254,212,208,65,0,0,184,65,0,0,216,65,2,43,191,65,0,0,216,65,0,0,200,65,98,0,0,216,65,254,212,208,65,254,212,208,65,0,0,216,65,0,0, 200,65,0,0,216,65,98,2,43,191,65,0,0,216,65,0,0,184,65,254,212,208,65,0,0,184,65,0,0,200,65,99,101,0,0 ]; const var Button_RandomizationButtonsVisibility = Content.addPanel("Button_RandomizationButtonsVisibility", 486, 182); Button_RandomizationButtonsVisibility.set("height", 16); Button_RandomizationButtonsVisibility.set("width", 16); Content.setPropertiesFromJSON("Button_RandomizationButtonsVisibility", { "allowCallbacks": "Clicks & Hover", "opaque": 0, "saveInPreset": 0, "parentComponent": "Panel_BG", }); Button_RandomizationButtonsVisibility.setPaintRoutine(function(g) { path.loadFromData(randomizationButtonsVisibilityData); g.setColour(Colours.lightgrey); g.drawPath(path, [2, 2, 12, 12], 1); }); Button_RandomizationButtonsVisibility.setMouseCallback(function(event) { if (event.mouseUp) { this.setValue(1-this.getValue()); if (this.getValue() == 0) { this.setPaintRoutine(function(g) { path.loadFromData(randomizationButtonsVisibilityData); g.setColour(Colours.darkgrey); g.drawPath(path, [2, 2, 12, 12], 1); }); } else this.setPaintRoutine(function(g) { path.loadFromData(randomizationButtonsVisibilityData); g.setColour(Colours.lightgrey); g.drawPath(path, [2, 2, 12, 12], 1); }); for (r in randomizationButtons) { Content.setPropertiesFromJSON(r, { "visible": Button_RandomizationButtonsVisibility.getValue(), }); } } else if (event.hover) { if (this.getValue() == 0) { this.setPaintRoutine(function(g) { path.loadFromData(randomizationButtonsVisibilityData); g.setColour(Colours.darkgrey); g.drawPath(path, [2, 2, 10, 10], 1); }); } else this.setPaintRoutine(function(g) { path.loadFromData(randomizationButtonsVisibilityData); g.setColour(Colours.lightgrey); g.drawPath(path, [2, 2, 10, 10], 1); }); } else { if (this.getValue() == 0) { this.setPaintRoutine(function(g) { path.loadFromData(randomizationButtonsVisibilityData); g.setColour(Colours.darkgrey); g.drawPath(path, [2, 2, 12, 12], 1); }); } else this.setPaintRoutine(function(g) { path.loadFromData(randomizationButtonsVisibilityData); g.setColour(Colours.lightgrey); g.drawPath(path, [2, 2, 12, 12], 1); }); } });
-
Stop what you're doing and go watch this video - go to around 1:44.
https://youtu.be/xU8dLVISM-A?t=6285
You should be using a single panel for this kind of thing. In the video I did a similar thing to you, I was adding lots of buttons, Christoph was there in the chat and showed me a better way using a single panel.
-
@d-healey hahahah ok thank you
-
Yeah sorry but I don't think that method will help me, I need individual panels for each button because they're placed all over in different parent panels (hence the giant switch statement):
https://i.gyazo.com/a7de01a23927188fa2fcacf9b3da8164.mp4
Here you can see each button is correctly printing its own value, I just can't access it elsewhere
I'm obviously missing something basic like some control callback or something to make the X.getValue() be visible to other functions, I just don't have enough experience with panels to identify it
-
I see what you're doing now. Use buttons instead of panels and create them in the interface designer. If you want to position them algorithmically you can do that in a loop, but using the interface designer is simpler than using factory functions (especially when they are not being placed in a logical pattern like a grid).
-
@d-healey damn okay, that was actually going to be my first plan but I decided i'd try and be smart and do it in a script :face_with_tears_of_joy:
-
can you use paintroutines with buttons? i need vectors
-
@iamlamprey Yes, via custom look and feel.
-
Ok figured out the panel situation
Since I can use getValue within the factory method, I use this.data.name to find the index of the button array, then push that value into a new array buttonValues[] at the same index, which can be accessed anywhere :)
-
@iamlamprey I'm going to keep pushing you to buttons and LAF. It's a pita when you first start with it but once you get the hang of it you'll find it much easier to work with than panels.
-
Here's a really simple example
HiseSnippet 943.3ocsV8taaaCDmxwJnVatXEnO.B4S1.dBxIocCHXXN+wNvXMoFyYE6aczRmj4LEoGEcRMJ56xdT1ivdT1av1QIYK4M2fD2N8Iw6te79cGOdGGojAPZpTQrZbyx4.w5KsGuTnmd9TJSPFdAw5o1WQS0fxMWzYKmSSSgPhk0dWZDX0nNI66u99ynbpH.JEQHuQxBfWwRX5Roi58CLNe.MDtgkTw5i6MLPJNWxkKP9rmsOYNMXFMFtlZLqlMwZ+9gLsTMVS0PJZyYxvkimJuSja+aXorIbvrnKYLtQ4hImOkwCGsJVSIDq5iJi78xi7maeEKjsVdYF3qxT3VhnZNvp1lTp9FTp6GiRCj7PyF7QnmUE5UOmdOydbfhMWWpwvsuvdn.ObhnXZuJsxskT6jZ1mKQKDZuD5LXfBWrFQqW562w8E99sOooSSGL4mpc4zH2uysuHlI.u.Efg0kb4DJOeKekTN6TQ3..3sxgg.7TPLyTjLXgHPyjhVGDpn2ciLNlCmsPqkhC53FsRYbGW4jescSm22zwE+XQtsPAdxaAU6bQluXuHrN4TNuUdMQpWHUMKVAKMN1XAvSg6y9Ibr.pv3McUHd.cutppabWAO1KEz4Vr1v6lxzPgkwdlv9TNKV.g2.uSm4KM9SVD6QwzYG2CBviCEDdP6Sb9P6SVkVbkhqkZ30hVscduSCmO339uUEEsUclSXkjyA0VUatkotOfsDKRl.pNt2R4Kf0FhkdaVau+Cq1NHufqhgRwPAS+54Pw5xp+tao5mTTwZtlVvPzTc1sfmVbKHunhvvMogc9htjL5WsgD4Q.+vOM3G8oA+3s.+mFdAUSMcCJRHXRZNnzLyYg0EvsXq07dCMru.RmokyyxXIykBS5yZ+GPN6ckt7xdKq1j9NVndZofg8lBr3o5pRHOJmcXEm0Kohy98e4yuyNpZj0qZj8ae9c1wUb1eTMx9yzGjy9uc6wYNxvEbpdyAQlItEJvavazw2zUWjxzKqVC8HlN4u0oSa894CjtOydDSGLc67s1V3KVp++MeKl02zteTDDnKIac6A+7tNX+QPkeTtPyDwWQ0JFVyXe8hjw3Xj..YhPfyyPYV0L8.yW6aVaxLiAQX1h+F+JT10r1pPY2UJIIz.k7sA4MeLul3IYRPNIxdHUC7Ec3Z20MLss887II3ibdaPfIU70H22NlC2ALGsCXNdGv7hc.yK2ALeyNf4auWLl2Wd5BsLI+ZBJXT+rd+VV8ETrJKqhj7O.8o4CHB
-
@d-healey Cheers, I still have some png sliders so it'll still come in handy for that :)
-
This was all just so I don't have to individually make factory presets
-
@d-healey Going off your snippet, how would I separate elements for different L&F? Not all of my UI Buttons look the same
-
Ah just saw your post: https://forum.hise.audio/topic/2761/custom-look-and-feel-per-component/2
was this ever implemented?
-
@iamlamprey This is the PITA when you first start that I warned you about :p You can use the text property of the control to differentiate them. But what if I want to use the text property to show some text I hear you ask... then you have to get clever with substrings.