Cable drag events

I’m thinking about adding CV inputs that replace the knob they override to my For Four module.

I suspect that adding a custom handler for whatever event handles the enabling / disabling of input or output ports when a cable is being dragged is the best way to implement it.

When an input cable is being dragged, hide the knobs and show the ports, when drag ends any that aren’t connected rehide the port and show the knob.

I’m not sure what to search for to find the current event implementation in src. Is there a way for me to hook into that event to implement this?

You’re already off here. CV input voltages add to parameter values, not replace them.

If it is for compactness of the layout you could try stack the port upon the knob. Might take a little bit bigger knob to make it work well. You could make the ports visually smaller by removing the outer ring. It’s on my to-do list but I’m slow with these things, so I do not know at what mouse pointer distance what is influenced.

Fundamental knobs with smaller ports,

Ingo

I’ve a module in progress that does that, works fine.

image

1 Like

have you tried what the minimum workable knob size is?

So long as the knob is bigger than the port that sits on top of it, so you’ve something to ‘grab’ with the mouse pointer, it works.

thanks.

Whatever box.size the component has will be the drag radius

I meant specifically my modules implementation rather than in general. I’m fairly sure I’ve used modules that work how you describe, ones that change the knob from a level to an attentuation and ones that ignore the knob when a cable is connected.

Mine falls in this last group as the input in question is a binary pattern select, not a level. I just wanted to add the graphic swap so it’s like having 25 versions of the module that autoswitch depending on the cabling.

It’s partly for size, but mostly for clarity - if a knob isn’t going to do anything, I don’t want to see it :slight_smile:

I found what I was looking for in PortWidget::Draw

Here’s how I’ve implemented it.

struct OptionalInput : app::SvgPort {
        OptionalInput() {
                setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/PJ301M.svg")));
        }

        void step() {
            if (!module)
                    return;

            CableWidget* cw = APP->scene->rack->incompleteCable;
            if (cw) {
                    if (cw->outputPort)
                        Widget::show();
                    else
                        Widget::hide();
            } else if (module->inputs[portId].isConnected()){
                Widget::show();
            } else {
                Widget::hide();
            }
            Widget::step();
        }
};