Skip to content

Commit

Permalink
[Nodify] PendingConnection.PreviewTarget fixes
Browse files Browse the repository at this point in the history
[Playground] Hide pending connection preview container when PreviewText is null #76
Add tooltip back to playground settings
  • Loading branch information
miroiu committed Oct 31, 2023
1 parent 1f222b8 commit 8064823
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
> - Added ItemContainer.SelectedBorderThickness dependency property
> - Bugfixes:
> - Fixed PendingConnection.PreviewTarget not being set to null when there is no actual target
> - Fixed PendingConnection.PreviewTarget not being set on Connector.PendingConnectionStartedEvent
> - Fixed PendingConnection.PreviewTarget not being set to null on Connector.PendingConnectionCompletedEvent
> - Fixed connectors panel not being affected by Node.VerticalAlignment
> - Changing BorderThickness causes layout shift when selecting an item container
> - Fixed the unintentional movement caused by snapping correction
Expand Down
2 changes: 1 addition & 1 deletion Examples/Nodify.Playground/Editor/NodifyEditorView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
<Border Background="{TemplateBinding Background}"
Canvas.Left="{Binding TargetAnchor.X, RelativeSource={RelativeSource TemplatedParent}}"
Canvas.Top="{Binding TargetAnchor.Y, RelativeSource={RelativeSource TemplatedParent}}"
Visibility="{TemplateBinding EnablePreview, Converter={shared:BooleanToVisibilityConverter}}"
Visibility="{Binding PreviewText, Converter={shared:StringToVisibilityConverter}}"
Padding="{TemplateBinding Padding}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public object? PreviewTarget
}
}

private string _previewText = "Drop on connector";
public string PreviewText
private string? _previewText;
public string? PreviewText
{
get => _previewText;
set => SetProperty(ref _previewText, value);
Expand All @@ -44,7 +44,7 @@ protected virtual void OnPreviewTargetChanged()
ConnectorViewModel con when con == Source => $"Can't connect to self",
ConnectorViewModel con => $"{(canConnect ? "Connect" : "Can't connect")} to {con.Title ?? "pin"}",
FlowNodeViewModel flow => $"{(canConnect ? "Connect" : "Can't connect")} to {flow.Title ?? "node"}",
_ => $"Drop on connector"
_ => null
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/Nodify.Playground/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<ColumnDefinition Width="Auto" SharedSizeGroup="PropertyName" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" Margin="0 5 5 0" Grid.Column="0" />
<TextBlock Text="{Binding Name}" ToolTip="{Binding Description}" Margin="0 5 5 0" Grid.Column="0" />
<ContentControl Content="{Binding}" Margin="5 5 5 0" Grid.Column="1">
<ContentControl.Style>
<Style TargetType="{x:Type ContentControl}">
Expand Down
21 changes: 21 additions & 0 deletions Examples/Nodify.Shared/Converters/StringToVisibilityConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;

namespace Nodify
{
public class StringToVisibilityConverter : MarkupExtension, IValueConverter
{
public Visibility NullVisibility { get; set; } = Visibility.Collapsed;

public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
=> string.IsNullOrEmpty(value as string) ? NullVisibility : Visibility.Visible;

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
=> throw new NotImplementedException();

public override object ProvideValue(IServiceProvider serviceProvider) => this;
}
}
10 changes: 10 additions & 0 deletions Nodify/Connections/PendingConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ protected virtual void OnPendingConnectionStarted(object sender, PendingConnecti
{
StartedCommand?.Execute(Source);
}

if(EnablePreview)
{
PreviewTarget = e.SourceConnector;
}
}
}

Expand Down Expand Up @@ -336,6 +341,11 @@ protected virtual void OnPendingConnectionCompleted(object sender, PendingConnec
CompletedCommand?.Execute(Target);
}
}

if(EnablePreview)
{
PreviewTarget = null;
}
}
}

Expand Down

0 comments on commit 8064823

Please sign in to comment.