hoffstadt / DearPyGui

Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies
https://dearpygui.readthedocs.io/en/latest/
MIT License
13.11k stars 682 forks source link

Node/Attributes Link Limit #2145

Open cloasdata opened 1 year ago

cloasdata commented 1 year ago

Is your feature request related to a problem? Please describe. Node links can have mutliple outgoing links, despite of the need for it. Implementationwise the etablishement of a link can be avoided, but this does not stop the user from still draging another one and questioning themself then why the link is not etablished when I still can pull the wire.

Describe the solution you'd like Provide a additional parameter like

dpg.add_node_attribute(
    ...,
    link_limit: int = -1,
    ...,
)

once a number <=1 is supplied, dragging stops when link_limit is reached.

Describe alternatives you've considered In the model layer of the gui, I check the node model, if we have already made a link, and return the etablished link instead of etablish a addtional one.

v-ein commented 1 year ago

If I understand correctly, you'd like to make the link connection point "inactive" once a link between two nodes is established. While it might make sense in some scenarios, there are other cases where it does make sense to allow multiple links. Something like this:

image

One output attribute here is connected to multiple input points, which might be pretty normal.

cloasdata commented 1 year ago

I do not want to drag wire from a connected output to another input. Sure it could make sense for other things, but in our case it simple does not. For branching we do have particular nodes.

v-ein commented 1 year ago

Got it.

Unfortunately got some bad news for you: I've looked at the code, and it turns out Dear ImGui (the C++ "backend") does not have a concept of disabling link connection points ("pins" it calls them), nor is there a way to impose any limit on the number of links. That said, the feature will be rather hard to implement. One could probably hack into NodeEditor internals and cross fingers that it won't break at some point in future.