Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved support for conditional enabling of nodes #6064

Merged
merged 5 commits into from
Oct 3, 2024

Conversation

johnhaddon
Copy link
Member

This adds a PatternMatch node which is useful as an enabler of other nodes, particularly by matching against the current context. It also customises the GraphEditor logic to provide improved feedback on such setups using color-coded strike-throughs, and to improve interaction with them in the D shortcut by "disabling the enabler". More thorough details in the final commit message.

@johnhaddon johnhaddon self-assigned this Oct 1, 2024
Copy link
Contributor

@murraystevenson murraystevenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've given this a run through and it does appear to cover the desired use-case. Might be a little tricky for users to understand the distinction of the context yellow strikethrough on first encounter, but it is a logical use of the colour...

There's one thought inline about improving the PatternMatch UI metadata, though I'd be fine with seeing this merged either way...

""",

"nodeGadget:type", "GafferUI::AuxiliaryNodeGadget",
"auxiliaryNodeGadget:label", "*",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we register "nodeGadget:shape", "oval" for consistency with the other Auxiliary nodes in case a user switches this over to the StandardNodeGadget?

It'd probably be worth hiding the "string" and "pattern" nodules for that situation as well?

Black for nodes that are always disabled. Yellow for nodes that are disabled but in a potentiall context-sensitive way.
This consolidates it into the same file that creates the equivalent popup menu item, and will allow us to modify the behaviour for both shortcut and menu in a future commit. It also fixes a couple of small bugs as documented in Changes.md.
I'm not a huge fan of this, which is why I've split it into a separate commit from the rest. It's needed to integrate a custom "ContextEnabledEditScope" concept with Gaffer's new ContextTracker workflow. I'm not a huge fan of the concept, because it encourages serial chains of nodes, where often only one is enabled in a given context. This could often be more efficiently - and readably - represented by multiple input branches to a NameSwitch. And there are many different potential "procedural node enablers" and we might want to apply them to any node type. So just combining a PatternMatch (say) with an EditScope on an ad-hoc basis is more flexible than a fixed ContextEnabledEditScope. Nevertheless, the idea has caught on in certain circles, and we need to do our best to support it.

The existing custom "ContextEnabledEditScope" operates with an additional internal switch which bypasses the processing for the node when the context doesn't match. But Gaffer can't reason about this bypass at all because it doesn't use the standard `Node.enabled` plug. So such nodes do not display a strike-through in the GraphEditor, and don't show as disabled in the EditScope menu either. So, the plan is to replace the internal switch with an internal PatternMatch node, driving the `enabled` plug directly. With this, Gaffer already correctly displays the strike-through when the node is disabled due to context. But we need some additional special cases to improve the useability, and that is what this commit does :

- StandardNodeGadget : Add additional support for recognising when a node is disabled statically rather than dynamically. This consists of recognising the case where the `enabled` plug is driven by a node such a PatternMatch, and representing the node as statically disabled when the PatternMatch itself is disabled.
- GraphEditor : Add support for enabling/disabling the driving node when the `enabled` plug has an input connection.

With this, the custom ContextEnabledEditScope has the following behaviour :

- When it is disabled due to the context not matching, it is drawn with a yellow "context sensitive" strike-through.
- In that state, the user may press "D", which will disable the connected PatternMatch node, turning the strike-through black - denoting "always disabled". Pressing "D" again will return to the yellow strike-through by enabling the PatternMatch node again.
- When the node is enabled due to the context matching is displays as usual. And "D" will again give it a black strike-through by disabling the PatternMatch node.
Bringing it into line with other AuxiliaryNodeGadget setups.
@johnhaddon
Copy link
Member Author

There's one thought inline about improving the PatternMatch UI metadata, though I'd be fine with seeing this merged either way...

Done in 91f02c8. Merging...

@johnhaddon johnhaddon merged commit 7777d77 into GafferHQ:main Oct 3, 2024
5 checks passed
@johnhaddon johnhaddon deleted the patternMatch branch October 3, 2024 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Pending release
Development

Successfully merging this pull request may close these issues.

2 participants