-
Notifications
You must be signed in to change notification settings - Fork 435
Support token editing within GraphEditor UI #2943
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
base: main
Are you sure you want to change the base?
Changes from 11 commits
019edba
cc15276
3709caf
18b0081
ee565f7
090bf5c
b526ec7
7e81ef7
b3cee30
04f9d02
8d0767b
33fe3a7
3644bd6
0a6f9e5
7e9717e
74b237a
67130cd
3bc659e
360fcb5
2f41f79
21b7828
6bb8add
e2e2126
400f793
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,72 @@ mx::NodeGraphPtr UiNode::getNodeGraph() const | |
| return _element ? _element->asA<mx::NodeGraph>() : nullptr; | ||
| } | ||
|
|
||
| void UiNode::buildUiTokenMap() | ||
| { | ||
| // Helper inline lambda function to avoid repeating code for mapping of tokens declared on element itself vs on element's corresponding nodedef | ||
| auto handleTokenMapping = [&](const mx::ConstInterfaceElementPtr& interfaceElem, mx::ElementPtr sourceElem) | ||
| { | ||
| std::vector<mx::TokenPtr> tokens = interfaceElem->getActiveTokens(); | ||
| for (auto token : tokens) | ||
| { | ||
| std::string key = token->getName(); | ||
|
|
||
| // Insert into map, but do not allow parent values to override child values | ||
| _uiTokenMap.try_emplace(key, std::make_shared<UiToken>(token, sourceElem)); | ||
| } | ||
| }; | ||
|
|
||
| _uiTokenMap.clear(); // Assume we want clean slate | ||
|
|
||
| mx::ElementPtr currElem = getNode(); | ||
| while (currElem) | ||
| { | ||
| if (mx::ConstInterfaceElementPtr interfaceElem = currElem->asA<mx::InterfaceElement>()) | ||
| { | ||
| handleTokenMapping(interfaceElem, currElem); | ||
|
|
||
| // If the node is a nodegraph, also check for tokens on corresponding nodedef | ||
| if (mx::ConstNodeGraphPtr nodegraph = currElem->asA<mx::NodeGraph>()) | ||
|
jstone-lucasfilm marked this conversation as resolved.
|
||
| { | ||
| if (mx::NodeDefPtr nodedef = nodegraph->getNodeDef()) | ||
| { | ||
| handleTokenMapping(nodedef, nodedef); | ||
| } | ||
| } | ||
| } | ||
| currElem = currElem->getParent(); | ||
| } | ||
|
|
||
| // Traverse through inputs and determine which tokens their value depends on | ||
| for (const auto& input : getNode()->getActiveInputs()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apologies, as I should have caught this in my earlier review, but I believe we need a null check for this call to Since you're storing the return value of For example, this might look like the following: |
||
| { | ||
| if (input->getType() != "filename") | ||
| continue; | ||
|
|
||
| mx::StringResolverPtr inputResolver = input->createStringResolver(); | ||
| const mx::StringMap& inputTokens = inputResolver->getFilenameSubstitutions(); | ||
|
|
||
| mx::StringMap inputTokensRenormalized; | ||
| for (const auto& entry : inputTokens) | ||
| { | ||
| // Store tokens without excess delimiters | ||
| inputTokensRenormalized[entry.first] = entry.first.substr(1, entry.first.size() - 2); | ||
| } | ||
|
|
||
| std::string inputValue = input->getValueString(); | ||
| if (inputValue.empty() && input->hasInterfaceName()) | ||
| inputValue = input->getInterfaceInput()->getValueString(); // Get value from referenced interface | ||
|
|
||
| for (const auto& entry : inputTokens) | ||
| { | ||
| if (inputValue.find(entry.first) != std::string::npos) | ||
| { | ||
| // Append to affected inputs of corresponding entry in token map | ||
| _uiTokenMap[inputTokensRenormalized[entry.first]]->addAffectedInput(input); | ||
|
jstone-lucasfilm marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| } | ||
| } | ||
| // return the uiNode connected with input name | ||
| UiNodePtr UiNode::getConnectedNode(const std::string& name) | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.