aluntzer / gtknodes

A GTK-based library to create functional flow graphs with the ability to pass arbitrary data between connected elements.
Other
92 stars 10 forks source link

Dynamically create node sources/sinks #12

Closed vgrcs closed 2 years ago

vgrcs commented 2 years ago

Hi,

I have tried to use a spinbutton to add new sources sockets after the call of the init() method. The sockets are in fact created, but there are only drawn if the GtkNodes.Node is at position (0,0). See Figure 1. The drag of the node fails to draw the sockets (Figure 2), but the lateral resize shows keeps the sockets visible (Figure 3) Figure-1 Figure-2 Figure-3

Best regards, Vitor

aluntzer commented 2 years ago

Hi!

Could you attach a minimal example please?

Thanks Armin

vgrcs commented 2 years ago

Sure, here it is. Thanks

main.py.txt

aluntzer commented 2 years ago

This is a very weird bug. It appears as if the coordinates relative to the parent widget are not properly propagated when a widget is dynamically added and the relative origin is never updated. I will investigate in detail, but this may take some time.

Thanks Armin

vgrcs commented 2 years ago

Hi, that's not a problem. A workaround will do for now. Here are a few further notes:

Many thanks in advance, ~Vitor

aluntzer commented 2 years ago

All done, including item_remove() method and node-to-foreground on click.

It turns out that the event window of the node socket item received a parent window different from the event window of the node when the node was already realized. The origin of this particular window was not moved when the node frame was dragged, because the node view had no reference of it, hence the coordinate origin never changed. I don't known what the underlying cause of this behaviour is, but I suspect that a new GDK window is created and assigned if the widget has no parent window set when it is realized. However, setting a parent window early when adding a new node item fixes the issue.

best regards Armin

vgrcs commented 2 years ago

Excellent! Thank you