-
Notifications
You must be signed in to change notification settings - Fork 653
[DYN-8997] CBN output port to show the name of the variable #16300
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: master
Are you sure you want to change the base?
[DYN-8997] CBN output port to show the name of the variable #16300
Conversation
…ut-port-to-show-the-name-of-the-variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-8997
@@ -1007,19 +1025,23 @@ private void SetOutputPorts() | |||
// Clear out all the output port models | |||
OutPorts.RemoveAll((p) => true); | |||
|
|||
// Add an output port for each definition. If there is only one port, force it to the top (LineIndex = 0) | |||
// regardless of code line, so it is not shifted by comments or empty lines. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aparajit-pratap , this design was suggested during last week's canthup - the idea was to keep the single output port aligned with the input port. I’ll bring up your concern with the team in today’s meeting, and I’ll make adjustments if agreed.
foreach (var def in allDefs) | ||
{ | ||
var tooltip = IsTempIdentifier(def.Key) ? string.Format(Resources.CodeBlockTempIdentifierOutputLabel, def.Value) : def.Key; | ||
string portLabel = outputPortNames.TryGetValue(def.Key, out var label) ? label : string.Empty; | ||
int lineIndex = (totalPorts == 1) ? 0 : def.Value - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would strongly suggest lineIndex
to always be set to def.Value - 1
.
// Special case: When a code block node has multiple outputs, its output ports are smaller than regular node outputs. | ||
// Adding +9 here ensures the first code block output aligns visually with the first input port of any node. | ||
// For a single output port, we skip this offset so the port and its connector are centered at the very top, | ||
// regardless of any empty lines or comments in the code block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I disagree with this design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest removing the special condition for a single statement CBN to have the output port always placed at the topmost line. I don't see why it's needed. I agree with the idea of showing the single output port be bigger than when there are multiple ports but I strongly feel that the output port should always align with the code statement, even when there are whitespaces or comments.
In other words, the placement of the output port should be like it is currently:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the CBN output port behavior so that it displays the variable name used on the left-hand side of code statements, ensuring proper alignment and tooltip display for both single and multiple statement code blocks. It also fixes a connector restoration issue by enforcing unique port identification.
- Outport controls are updated to adjust styling and margins based on the number of code block outputs.
- A new property (IsOnlyOutputPortInCodeBlock) has been introduced to differentiate single from multiple output ports.
- Layout adjustments and API documentation updates have been applied across several files to support these changes.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs | Adjusted outport margins and styling for CodeBlockNodes based on port count. |
src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs | Added property to check for a single output port in code blocks. |
src/DynamoCoreWpf/ViewModels/Core/OutPortViewModel.cs | Updated condensed port condition to incorporate single port logic. |
src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs | Revised port positioning and introduced a constant for collapsed port height. |
src/DynamoCoreWpf/PublicAPI.Unshipped.txt | Exposed the new IsOnlyOutputPortInCodeBlock property. |
src/DynamoCoreWpf/Controls/OutPorts.xaml.cs | Modified UI element margins and sizes based on the port type. |
src/DynamoCore/Graph/Nodes/PortModel.cs | Adjusted center position calculation to correctly offset code block outputs. |
src/DynamoCore/Graph/Nodes/CodeBlockNode.cs | Cleared and built output port labels with adjusted line indexing for single vs. multiple ports. |
@@ -805,6 +806,7 @@ private void ProcessCode(out string errorMessage, out string warningMessage, | |||
OutPorts.Clear(); | |||
InPorts.Clear(); | |||
inputPortNames.Clear(); | |||
outputPortNames.Clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] There are multiple calls to outputPortNames.Clear() in the ProcessCode method. Consolidating these calls may prevent potential redundancy and clarify the port name collection process.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change appears pretty straightforward. I do understand Aparajit's objection and barring a change in the requirements there, I think this looks good to go.
@@ -32,6 +32,9 @@ public class AnnotationViewModel : ViewModelBase | |||
private ObservableCollection<Dynamo.Configuration.StyleItem> groupStyleList; | |||
private IEnumerable<Configuration.StyleItem> preferencesStyleItemsList; | |||
private PreferenceSettings preferenceSettings; | |||
// TODO: Investigate why collapsed group ports appear 0.655px taller than actual port height. | |||
// This constant is currently used to visually align collapsed ports for CBNs with multiple outputs. | |||
private const double CodeBlockCollapsedPortVisualHeight = 17; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to document this one and use a const as it is even more magical due to the unknown nature
Purpose
This PR aims to address DYN-8997.
Changes:
Declarations
Check these if you believe they are true
*.resx
filesRelease Notes
The output port of code block node now displays the left side of the statement.
Reviewers
@DynamoDS/eidos
@jasonstratton.
FYIs
@dnenov
@achintyabhat