Skip to content

DYN-8947 - Add transient state to connectors #16247

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

Merged
merged 12 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/DynamoCore/Graph/Connectors/ConnectorModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ public bool IsHidden
RaisePropertyChanged(nameof(IsHidden));
}
}

private bool isTransient = false;
/// <summary>
/// IsTransient flag controlling the transient state of the connector
/// </summary>
internal bool IsTransient
{
get { return isTransient; }
set
{
isTransient = value;
RaisePropertyChanged(nameof(IsTransient));
}
}
/// <summary>
/// Returns start port model.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ Dynamo.Controls.ConnectionStateToBrushConverter.NoneBrush.get -> System.Windows.
Dynamo.Controls.ConnectionStateToBrushConverter.NoneBrush.set -> void
Dynamo.Controls.ConnectionStateToBrushConverter.SelectionBrush.get -> System.Windows.Media.SolidColorBrush
Dynamo.Controls.ConnectionStateToBrushConverter.SelectionBrush.set -> void
Dynamo.Controls.ConnectionStateToBrushConverter.TransientBrush.get -> System.Windows.Media.SolidColorBrush
Dynamo.Controls.ConnectionStateToBrushConverter.TransientBrush.set -> void
Dynamo.Controls.ConnectionStateToColorConverter
Dynamo.Controls.ConnectionStateToColorConverter.ConnectionStateToColorConverter() -> void
Dynamo.Controls.ConnectionStateToColorConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Expand All @@ -151,6 +153,8 @@ Dynamo.Controls.ConnectionStateToColorConverter.None.get -> System.Windows.Media
Dynamo.Controls.ConnectionStateToColorConverter.None.set -> void
Dynamo.Controls.ConnectionStateToColorConverter.Selection.get -> System.Windows.Media.Color
Dynamo.Controls.ConnectionStateToColorConverter.Selection.set -> void
Dynamo.Controls.ConnectionStateToColorConverter.Transient.get -> System.Windows.Media.Color
Dynamo.Controls.ConnectionStateToColorConverter.Transient.set -> void
Dynamo.Controls.ConnectionStateToVisibilityCollapsedConverter
Dynamo.Controls.ConnectionStateToVisibilityCollapsedConverter.ConnectionStateToVisibilityCollapsedConverter() -> void
Dynamo.Controls.ConnectionStateToVisibilityCollapsedConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Expand Down Expand Up @@ -2934,6 +2938,7 @@ Dynamo.ViewModels.PreviewState
Dynamo.ViewModels.PreviewState.ExecutionPreview = 1 -> Dynamo.ViewModels.PreviewState
Dynamo.ViewModels.PreviewState.Hover = 2 -> Dynamo.ViewModels.PreviewState
Dynamo.ViewModels.PreviewState.None = 3 -> Dynamo.ViewModels.PreviewState
Dynamo.ViewModels.PreviewState.Transient = 4 -> Dynamo.ViewModels.PreviewState
Dynamo.ViewModels.PreviewState.Selection = 0 -> Dynamo.ViewModels.PreviewState
Dynamo.ViewModels.PythonTemplatePathEventArgs
Dynamo.ViewModels.PythonTemplatePathEventArgs.Cancel.get -> bool
Expand Down
6 changes: 6 additions & 0 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ public class ConnectionStateToBrushConverter : IValueConverter
public SolidColorBrush ExecutionPreviewBrush { get; set; }
public SolidColorBrush NoneBrush { get; set; }
public SolidColorBrush SelectionBrush { get; set; }
public SolidColorBrush TransientBrush { get; set; }

public SolidColorBrush HoverBrush { get; set; }

Expand All @@ -808,6 +809,8 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
var state = (PreviewState)value;
switch (state)
{
case PreviewState.Transient:
return TransientBrush;
case PreviewState.ExecutionPreview:
return ExecutionPreviewBrush;
case PreviewState.None:
Expand All @@ -833,12 +836,15 @@ public class ConnectionStateToColorConverter : IValueConverter
public Color None { get; set; }
public Color Selection { get; set; }
public Color Hover { get; set; }
public Color Transient { get; set; }

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var state = (PreviewState)value;
switch (state)
{
case PreviewState.Transient:
return Transient;
case PreviewState.ExecutionPreview:
return ExecutionPreview;
case PreviewState.None:
Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/UI/Themes/Modern/Connectors.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewModels="clr-namespace:Dynamo.ViewModels;assembly=DynamoCoreWpf"
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf"
Expand Down Expand Up @@ -168,4 +168,4 @@
</DataTemplate.Triggers>
</DataTemplate>

</ResourceDictionary>
</ResourceDictionary>
6 changes: 4 additions & 2 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoConverters.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
ExecutionPreview="#F2930C"
Hover="#808080"
None="#444"
Selection="#6AC0E7" />
Selection="#6AC0E7"
Transient="#D5BCF7"/>

<controls:ConnectionStateToBrushConverter x:Key="ConnectionStateToBrushConverter"
ExecutionPreviewBrush="#F2930C"
HoverBrush="#808080"
NoneBrush="#444"
SelectionBrush="#6AC0E7" />
SelectionBrush="#6AC0E7"
TransientBrush="#D5BCF7"/>

<controls:ConnectionStateToVisibilityCollapsedConverter x:Key="ConnectionStateToVisibilityCollapsedConverter" />
<controls:AttachmentToPathConverter x:Key="AttachmentToPathConverter" />
Expand Down
24 changes: 23 additions & 1 deletion src/DynamoCoreWpf/ViewModels/Core/ConnectorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace Dynamo.ViewModels
{
public enum PreviewState { Selection, ExecutionPreview, Hover, None }
public enum PreviewState { Selection, ExecutionPreview, Hover, None, Transient }

public partial class ConnectorViewModel : ViewModelBase
{
Expand All @@ -38,6 +38,7 @@ public partial class ConnectorViewModel : ViewModelBase
private bool isConnecting = false;
private bool isCollapsed = false;
private bool isHidden = false;
private bool isTransient = false;
private bool isTemporarilyVisible = false;
private string connectorDataToolTip;
private bool canShowConnectorTooltip = true;
Expand Down Expand Up @@ -199,6 +200,22 @@ public bool IsHidden
}
}

internal bool IsTransient
{
get => isTransient;
set
{
if (isTransient == value)
{
return;
}

isTransient = value;
RaisePropertyChanged(nameof(IsTransient));
RaisePropertyChanged(nameof(PreviewState));
}
}

/// <summary>
/// Property which overrides 'isDisplayed==false' condition. When this prop is set to true, wires are set to
/// 40% opacity.
Expand Down Expand Up @@ -505,6 +522,11 @@ public PreviewState PreviewState
return PreviewState.None;
}

if (IsTransient)
{
return PreviewState.Transient;
}

if (Nodevm.ShowExecutionPreview || NodeEnd.ShowExecutionPreview)
{
return PreviewState.ExecutionPreview;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,10 @@ internal void ConsolidateTransientNodes()
}

//set the last connector to be connected
var transientConnectors = node.WorkspaceViewModel.Connectors.Where(c => c.IsConnecting).ToList();
var transientConnectors = node.WorkspaceViewModel.Connectors.Where(c => c.IsTransient).ToList();
foreach (var connector in transientConnectors)
{
connector.IsTransient = false;
connector.IsConnecting = false;
}

Expand Down Expand Up @@ -817,6 +818,7 @@ internal void AddCluster(ClusterResultItem clusterResultItem)
{
entryConnector.IsHidden = true;
var entryConnectorViewModel = workspaceViewModel.Connectors.First(c => c.ConnectorModel.Equals(entryConnector));
entryConnectorViewModel.IsTransient = true;
entryConnectorViewModel.IsConnecting = true;
createdClusterItems.Add(entryConnector);
}
Expand All @@ -841,6 +843,11 @@ internal void AddCluster(ClusterResultItem clusterResultItem)
{
newConnector.IsHidden = true; // Hide the connector initially
createdClusterItems.Add(newConnector);

// toggle to be transient for preview purposes
var newConnectorViewModel = workspaceViewModel.Connectors.First(c => c.ConnectorModel.Equals(newConnector));
newConnectorViewModel.IsTransient = true;
newConnectorViewModel.IsConnecting = true;
}
}
}
Expand Down
Loading