Skip to content

Add an attribute flag to create/destroy links when visually snapping #41

Closed

Description

@Auburn

When creating a link the bezier curve visually snaps to nearby attributes, IsLinkedCreated/Destroyed could be based on this visual snapping instead of the mouse click. It would show the effects of the link you are creating as you drag it over different attributes, which is good feedback for the user.

Hopefully you understand what I'm envisioning, I think this would work well alongside the AttributeFlags_EnableLinkDetachWithDragClick flag. Thanks for this great node graph editor!

Activity

  1. Nelarius commented on Jun 21, 2020

    @Nelarius
    Owner

    Hi @Auburns !

    I guess the gist of the idea is to create the link on snap, so that there is a way to alter the link to show the user when a link would be created. I suppose that would be a useful addition, since the visual snap is the only thing currently indicating that a link could be created 🤔 I like being able to adjust the link target after the visual snap, just in case I got the pin wrong. So either it would have to be configurable, like you mentioned, or it could be signalled via separate event functions. I'll have to play around with the code and see what works!

  2. Auburn commented on Jun 21, 2020

    @Auburn
    CollaboratorAuthor

    I think you mostly have the right idea, except that when the link snaps to a pin you would still be able to break it by moving the mouse back, and reattach to another node without ever having to let go of the mouse button.

    Imagine this above situation but with the output updating as I drag the link over the various pins.

    It shouldn't require any extra event functions, just an attribute flag to enable the feature. I'm going to have a go at implementing it, I've mostly figured out how linking works in imnodes

  3. Auburn commented on Jun 21, 2020

    @Auburn
    CollaboratorAuthor

    Got it working quite nicely

    It just uses the IsLinkCreated & IsLinkDestroyed events.

    I did add an extra argument to IsLinkCreated(int* started_at_attribute_id, int* ended_at_attribute_id, bool* created_from_snap = 0);
    I'm using this to not destroy existing links just by hovering over them, so the developer can decide if that's the behaviour they want.

    After cleaning up the code a bit I can make a PR for it

  4. Nelarius commented on Jun 22, 2020

    @Nelarius
    Owner

    Right, snapping to the next pin would just trigger the IsLinkDestroyed event again 👍

    Sounds like you have a good idea of how this would work, so feel free to open a pr. I guess placing the feature behind a feature flag means that it's not a breaking change either?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址