Morning all
I'm sure as always its something I've missed. I've set up this XY pad to control 2 simple Gains. Its looking as it should and the dot behaving on the panel as it should adn when the cursor moves the dots the knobs respond correctly and so do the simple gains.
Now the knobs work and control the simple gains also But don't then force the dot to respond on the pad. If someone can have a look at the code here it would be most helpful. Thanks in advance
///XY Panel
const var XYPadPnl = Content.getComponent("XYPadPnl");
const var SimpleGain1 = Synth.getEffect("Simple Gain1");
const var SimpleGain2 = Synth.getEffect("Simple Gain2");
XYPadPnl.setControlCallback(onXYPadPnlControl);
inline function onXYPadPnlControl(component, value)
{
component.repaint();
}
///Knobs
const var knobs = [];
for (i = 0; i < 2; i++)
{
knobs[i] = Content.getComponent("Knob"+(i+1));
knobs[i].setControlCallback(XYPad);
}
// Mouse CB
XYPadPnl.setMouseCallback(function(event)
{
if (event.clicked || event.drag)
{
this.data.x = Math.range(event.x / this.getWidth(), 0, 1);
this.data.y = Math.range(event.y / this.getHeight(), 0, 1);
this.changed();
knobs[0].setValue(1*this.data.x);
knobs[1].setValue(1-(1*this.data.y));
knobs[0].changed();
knobs[1].changed();
}
});
// Paint routine
const SIZE = 10
XYPadPnl.setPaintRoutine(function(g)
{
var l = this.getLocalBounds(0);
g.fillAll(this.get("bgColour"));
var x = Math.range(this.data.x * this.getWidth(), 0, this.getWidth() - SIZE);
var y = Math.range(this.data.y * this.getHeight(), 0, this.getHeight() - SIZE);
//Draw Dot
g.setColour(this.get("itemColour"));
g.fillEllipse([x, y, SIZE, SIZE]);
});
inline function XYPad(component, value)
{
local idx = knobs.indexOf(component);
XYPadPnl.repaint();
};
inline function onKnob1Control(component, value)
{
if(value)
SimpleGain1.setAttribute(SimpleGain1.Gain,(1 - value)*-100);
};
Content.getComponent("Knob1").setControlCallback(onKnob1Control);