mgunyho / Little-Utils

Little Utils plugin for VCV Rack
European Union Public License 1.2
15 stars 5 forks source link

Teleport: mirror the port labels of the ports being teleported. #11

Closed EnigmaCurry closed 1 year ago

EnigmaCurry commented 1 year ago

Hi there! I'd like to make the suggestion that teleport should mirror the source port names to the mirrored location. That way I can hover my mouse over the output ports on the TeleportOut module to see what the source port name is. I've got a first pass on the code here, and I think I've got rid of all the obvious segfaults, but its not battle tested yet. I added some code to slow down the update, configOutput seems like a heavy process, so its only performed every 1s.

SteveRussell33 commented 1 year ago

Nice QoL! Looks good here so far.

mgunyho commented 1 year ago

Thanks, this indeed looks like a good improvement! I'll look into it in more detail soon.

At a quick glance, accessing the name of a port on the other end of a cable via the global scene looks quite convoluted. Are you sure there is no simpler API for accessing the labels at the module (not widget) level?

EnigmaCurry commented 1 year ago

I think I need to get a hold of the Port not the Input, the example I found was for the Widget, but I wondered the same, so I will investigate if it can be done from the module process

EnigmaCurry commented 1 year ago

cross reference https://community.vcvrack.com/t/can-a-module-find-out-what-other-module-is-plugged-into-it/18449 I found the example in the MindMeld Meld module.

EnigmaCurry commented 1 year ago

I found that I can pretty easily move the existing cable interrogation function out of the Widget::step and into the Module::process. But I still need access to the PortWidget object, as it seems like that is the only way to get access to the Cable object. So I set the reference to the PortWidget on the Module itself via a new method setPortWidget. So its only a little less complex now.

mgunyho commented 1 year ago

Alright, I finally got a chance to take a look at this. So after a bit of digging, it seems like indeed the only way to get a handle of the cables attached to a port is from APP->scene->rack->getCablesOnPort(port), where port is a PortWidget, and this returns a vector of CableWidgets.

Ideally, IMO the correct place to update the port info would be at the module level in TeleportInModule::onPortChange, but I couldn't access the cable there. I tried to use things like APP->engine->getCableIds() and then APP->engine->getCable(cableId), but those will create a mutex on the engine (one for each cable in the case of getCable()), which is not good.

In the latest version, we have to keep track of an extra vector of PortWidgets, which should be unnecessary. So I suggest we revert f0f2d72da1354a9d7775ecd86bd0e20f0ae03190 and do the logic in the Widget.

I'll still need to think a bit more about how/where to manage the information about the port labels. I suppose the "check once every second" in step() is a decent solution, but I still want to see if there is a cleaner way to do it.

EnigmaCurry commented 1 year ago

Closing this in favor of #12.