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

Update release branch #83

Merged
merged 22 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5af6910
Fix NodeOutput content alignment
miroiu Apr 26, 2023
c7d4ff5
Added performance improvement example for #60
miroiu Apr 26, 2023
c1d7250
[Playground] Highlight connection on mouse over
miroiu Apr 29, 2023
d38465a
Fix connector not opening context menu #61
miroiu May 20, 2023
fc2c304
Generate settings panel from viewmodel (#62)
Riju-bak Jun 29, 2023
de7ce78
Fix blurry text on zoom for playground app
miroiu Aug 1, 2023
145ad29
make the connector can center vertically.
MakesYT Aug 23, 2023
1701c39
improve
MakesYT Aug 24, 2023
c79a3bc
UPDATE changelog
MakesYT Aug 25, 2023
23ffe5a
Merge pull request #67 from MakesYT/master
miroiu Aug 25, 2023
3ee7260
Update FUNDING.yml
miroiu Aug 26, 2023
539c147
Update FUNDING.yml
miroiu Aug 26, 2023
52f4cfe
Fix custom border thickness causing layout shifting
miroiu Sep 5, 2023
36fab14
Merge pull request #72 from miroiu/fix/70-borderthickness
miroiu Sep 6, 2023
df7fc91
The node should not move after being selected, even if snapping corre…
fantasydr Oct 13, 2023
146f52c
Do not prevent single axis movement
fantasydr Oct 14, 2023
1fab72f
Update CHANGELOG.md for #75
fantasydr Oct 31, 2023
1f222b8
Merge pull request #75 from fantasydr/fix-unintentional-movement
miroiu Oct 31, 2023
8064823
[Nodify] PendingConnection.PreviewTarget fixes
miroiu Oct 31, 2023
441e3fc
Added drag and drop example in Calculator app
miroiu Jan 10, 2024
3732c8f
Merge pull request #82 from miroiu/feature/drag-drop
miroiu Jan 14, 2024
c7b0d1c
Bump version for release
miroiu Jan 17, 2024
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
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# These are supported funding model platforms

github: miroiu
custom: ["https://www.buymeacoffee.com/miroiu", "https://paypal.me/miroiuemanuel"]
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@
> - Features:
> - Bugfixes:

#### **Version 5.1.0**

> - Breaking Changes:
> - Features:
> - Added ItemContainer.SelectedBorderThickness dependency property
> - Added NodifyEditor.GetLocationInsideEditor
> - 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

#### **Version 5.0.2**

> - Bugfixes:
> - Fixed NodeOutput content horizontal alignment
> - Fixed Connector not opening Context Menu

#### **Version 5.0.1**

> - Bugfixes:
Expand Down
92 changes: 90 additions & 2 deletions Examples/Nodify.Calculator/EditorView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:local="clr-namespace:Nodify.Calculator"
xmlns:nodify="https://miroiu.github.io/nodify"
xmlns:shared="clr-namespace:Nodify;assembly=Nodify.Shared"
xmlns:sys="clr-namespace:System;assembly=System.Runtime"
d:DataContext="{d:DesignInstance Type=local:EditorViewModel}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
Expand Down Expand Up @@ -33,6 +34,40 @@
Transform="{Binding ViewportTransform, ElementName=Editor}"
Drawing="{StaticResource LargeGridGeometry}" />

<LinearGradientBrush x:Key="AnimatedBrush" StartPoint="0 0" EndPoint="1 0">
<GradientStop Color="#6366f1" Offset="0" />
<GradientStop Color="#a855f7" Offset="0.5" />
<GradientStop Color="#ec4899" Offset="1" />
</LinearGradientBrush>
<Border x:Key="AnimatedBorderPlaceholder" BorderBrush="{StaticResource AnimatedBrush}" />

<Storyboard x:Key="AnimateBorder" RepeatBehavior="Forever">
<PointAnimation Storyboard.TargetProperty="BorderBrush.(LinearGradientBrush.StartPoint)"
Storyboard.Target="{StaticResource AnimatedBorderPlaceholder}"
Duration="0:0:2" To="1 0" />
<PointAnimation Storyboard.TargetProperty="BorderBrush.(LinearGradientBrush.StartPoint)"
Storyboard.Target="{StaticResource AnimatedBorderPlaceholder}"
Duration="0:0:2" To="1 1" BeginTime="0:0:2" />
<PointAnimation Storyboard.TargetProperty="BorderBrush.(LinearGradientBrush.StartPoint)"
Storyboard.Target="{StaticResource AnimatedBorderPlaceholder}"
Duration="0:0:2" To="0 1" BeginTime="0:0:4" />
<PointAnimation Storyboard.TargetProperty="BorderBrush.(LinearGradientBrush.StartPoint)"
Storyboard.Target="{StaticResource AnimatedBorderPlaceholder}"
Duration="0:0:2" To="0 0" BeginTime="0:0:6" />
<PointAnimation Storyboard.TargetProperty="BorderBrush.(LinearGradientBrush.EndPoint)"
Storyboard.Target="{StaticResource AnimatedBorderPlaceholder}"
Duration="0:0:2" To="1 1" />
<PointAnimation Storyboard.TargetProperty="BorderBrush.(LinearGradientBrush.EndPoint)"
Storyboard.Target="{StaticResource AnimatedBorderPlaceholder}"
Duration="0:0:2" To="0 1" BeginTime="0:0:2" />
<PointAnimation Storyboard.TargetProperty="BorderBrush.(LinearGradientBrush.EndPoint)"
Storyboard.Target="{StaticResource AnimatedBorderPlaceholder}"
Duration="0:0:2" To="0 0" BeginTime="0:0:4" />
<PointAnimation Storyboard.TargetProperty="BorderBrush.(LinearGradientBrush.EndPoint)"
Storyboard.Target="{StaticResource AnimatedBorderPlaceholder}"
Duration="0:0:2" To="1 0" BeginTime="0:0:6" />
</Storyboard>

<local:ItemToListConverter x:Key="ItemToListConverter" />

<DataTemplate x:Key="ConnectionTemplate"
Expand Down Expand Up @@ -60,8 +95,11 @@
Value="{Binding IsSelected}" />
<Setter Property="ActualSize"
Value="{Binding Size, Mode=OneWayToSource}" />
<Setter Property="BorderBrush" Value="{Binding BorderBrush, Source={StaticResource AnimatedBorderPlaceholder}}" />
<Setter Property="BorderThickness" Value="2" />
</Style>
</UserControl.Resources>

<Grid>
<nodify:NodifyEditor DataContext="{Binding Calculator}"
ItemsSource="{Binding Operations}"
Expand All @@ -74,6 +112,8 @@
Background="{StaticResource SmallGridLinesDrawingBrush}"
ItemContainerStyle="{StaticResource ItemContainerStyle}"
GridCellSize="15"
AllowDrop="True"
Drop="OnDropNode"
x:Name="Editor">
<nodify:NodifyEditor.Resources>
<Style TargetType="{x:Type nodify:NodeInput}"
Expand Down Expand Up @@ -250,7 +290,9 @@
ConnectionTemplate="{StaticResource ConnectionTemplate}"
ItemContainerStyle="{StaticResource ItemContainerStyle}"
Background="Transparent"
GridCellSize="15"
GridCellSize="15"
AllowDrop="True"
Drop="OnDropNode"
Visibility="{Binding DataContext.IsExpanded, RelativeSource={RelativeSource AncestorType=nodify:GroupingNode}, Converter={shared:BooleanToVisibilityConverter}}">

<nodify:NodifyEditor.InputBindings>
Expand Down Expand Up @@ -300,15 +342,61 @@
Command="{Binding GroupSelectionCommand}" />
</nodify:NodifyEditor.InputBindings>

<nodify:NodifyEditor.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Name="AnimateBorder" Storyboard="{StaticResource AnimateBorder}" />
</EventTrigger>
</nodify:NodifyEditor.Triggers>

<CompositeCollection>
<nodify:DecoratorContainer DataContext="{Binding OperationsMenu}"
Location="{Binding Location}">
<local:OperationsMenuView />
</nodify:DecoratorContainer>
</CompositeCollection>
</nodify:NodifyEditor>

<Grid Background="{StaticResource LargeGridLinesDrawingBrush}"
Panel.ZIndex="-2" />

<Border HorizontalAlignment="Right"
MinWidth="200"
MaxWidth="300"
Padding="7"
Margin="10"
CornerRadius="3"
BorderThickness="2">
<Border.Background>
<SolidColorBrush Color="{DynamicResource BackgroundColor}"
Opacity="0.7" />
</Border.Background>
<ScrollViewer>
<ItemsControl ItemsSource="{Binding Calculator.OperationsMenu.AvailableOperations}">
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="FrameworkElement.Margin" Value="5"/>
<Setter Property="FrameworkElement.HorizontalAlignment" Value="Left"/>
<Setter Property="FrameworkElement.Cursor" Value="Hand"/>
<Setter Property="FrameworkElement.ToolTip" Value="Drag and drop into the editor"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:OperationViewModel}">
<nodify:Node Content="{Binding Title}"
Input="{Binding Input}"
BorderBrush="{StaticResource AnimatedBrush}"
BorderThickness="2"
MouseMove="OnNodeDrag">
<nodify:Node.Output>
<CompositeCollection>
<sys:String>Output</sys:String>
</CompositeCollection>
</nodify:Node.Output>
</nodify:Node>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Border>
</Grid>
</UserControl>
22 changes: 22 additions & 0 deletions Examples/Nodify.Calculator/EditorView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,27 @@ private void CloseOperationsMenu(object sender, RoutedEventArgs e)
calculator.OperationsMenu.Close();
}
}

private void OnDropNode(object sender, DragEventArgs e)
{
if(e.Source is NodifyEditor editor && editor.DataContext is CalculatorViewModel calculator
&& e.Data.GetData(typeof(OperationInfoViewModel)) is OperationInfoViewModel operation)
{
OperationViewModel op = OperationFactory.GetOperation(operation);
op.Location = editor.GetLocationInsideEditor(e);
calculator.Operations.Add(op);

e.Handled = true;
}
}

private void OnNodeDrag(object sender, MouseEventArgs e)
{
if(e.LeftButton == MouseButtonState.Pressed && ((FrameworkElement)sender).DataContext is OperationInfoViewModel operation)
{
var data = new DataObject(typeof(OperationInfoViewModel), operation);
DragDrop.DoDragDrop(this, data, DragDropEffects.Copy);
}
}
}
}
119 changes: 61 additions & 58 deletions Examples/Nodify.Calculator/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,77 +54,80 @@
</Style>
</shared:TabControlEx.ItemContainerStyle>
</shared:TabControlEx>

<Expander Header="Click to hide/show"
IsExpanded="True"
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Bottom">
<Border MaxWidth="325"
MaxHeight="300"
CornerRadius="3">
<Border.Background>
<SolidColorBrush Color="{DynamicResource BackgroundColor}"
Opacity="0.7" />
</Border.Background>
<StackPanel Margin="10"
IsHitTestVisible="False">
<StackPanel.Resources>
<Style TargetType="{x:Type TextBlock}"
BasedOn="{StaticResource {x:Type TextBlock}}">
<Setter Property="Margin"
Value="0 0 0 5" />
</Style>
</StackPanel.Resources>
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<StackPanel Margin="10"
IsHitTestVisible="False">
<StackPanel.Resources>
<Style TargetType="{x:Type TextBlock}"
BasedOn="{StaticResource {x:Type TextBlock}}">
<Setter Property="Margin"
Value="0 0 0 5" />
</Style>
</StackPanel.Resources>

<StackPanel Margin="0 0 0 20">
<TextBlock Text="(New) Drag a connection and drop it on the editor"
TextWrapping="Wrap"
Foreground="{DynamicResource NodeInput.BorderBrush}"
FontWeight="Bold"/>
<TextBlock Text="(New) CTRL + N : open new editor"
TextWrapping="Wrap"
Foreground="{DynamicResource NodeInput.BorderBrush}"
FontWeight="Bold"/>
<TextBlock Text="(New) CTRL + W : close current editor"
TextWrapping="Wrap"
Foreground="{DynamicResource NodeInput.BorderBrush}"
FontWeight="Bold"/>
<StackPanel Margin="0 0 0 20">
<TextBlock Text="(New) Drag and drop nodes from the toolbox"
TextWrapping="Wrap"
Foreground="{DynamicResource NodeInput.BorderBrush}"
FontWeight="Bold"/>
</StackPanel>
<TextBlock TextWrapping="Wrap">
<Run Foreground="Red"
FontWeight="Bold">CTRL + N/W</Run>
<Run>: open/close editor</Run>
</TextBlock>
<TextBlock TextWrapping="Wrap">
<Run Foreground="Red"
FontWeight="Bold">ALT + Click</Run>
<Run>: disconnect connector</Run>
</TextBlock>
<TextBlock TextWrapping="Wrap">
<Run Foreground="Red"
FontWeight="Bold">Right Click</Run>
<Run>: show operations menu (create nodes)</Run>
</TextBlock>
<TextBlock TextWrapping="Wrap">
<Run Foreground="Red"
FontWeight="Bold">Delete</Run>
<Run>: delete selection</Run>
</TextBlock>
<TextBlock TextWrapping="Wrap">
<Run Foreground="Red"
FontWeight="Bold">CTRL + T</Run>
<Run>: change theme</Run>
</TextBlock>
<TextBlock TextWrapping="Wrap">
<Run Foreground="Red"
FontWeight="Bold">C</Run>
<Run>: group selection (hold SHIFT and mouse drag the header to move the group node alone)</Run>
</TextBlock>
<TextBlock Text="Drag a connection and drop it on the editor"
TextWrapping="Wrap"
FontWeight="Bold" />
<TextBlock Text="Hover over a connector to see its value"
TextWrapping="Wrap"
FontWeight="Bold" />
<TextBlock Text="Create a Calculator node and double click it to open"
TextWrapping="Wrap"
FontWeight="Bold" />
<TextBlock Text="Create an Operation Graph and add operations to it"
TextWrapping="Wrap"
FontWeight="Bold" />
</StackPanel>
<TextBlock TextWrapping="Wrap">
<Run Foreground="Red"
FontWeight="Bold">ALT + Click</Run>
<Run>: disconnect connector</Run>
</TextBlock>
<TextBlock TextWrapping="Wrap">
<Run Foreground="Red"
FontWeight="Bold">Right Click</Run>
<Run>: show operations menu (create nodes)</Run>
</TextBlock>
<TextBlock TextWrapping="Wrap">
<Run Foreground="Red"
FontWeight="Bold">Delete</Run>
<Run>: delete selection</Run>
</TextBlock>
<TextBlock TextWrapping="Wrap">
<Run Foreground="Red"
FontWeight="Bold">CTRL + T</Run>
<Run>: change theme</Run>
</TextBlock>
<TextBlock TextWrapping="Wrap">
<Run Foreground="Red"
FontWeight="Bold">C</Run>
<Run>: group selection (hold SHIFT and mouse drag the header to move the group node alone)</Run>
</TextBlock>
<TextBlock Text="Hover over a connector to see its value"
TextWrapping="Wrap"
FontWeight="Bold" />
<TextBlock Text="Create a Calculator node and double click it to open"
TextWrapping="Wrap"
FontWeight="Bold" />
<TextBlock Text="Create an Operation Graph and add operations to it"
TextWrapping="Wrap"
FontWeight="Bold" />
</StackPanel>
</ScrollViewer>
</Border>
</Expander>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion Examples/Nodify.Calculator/Nodify.Calculator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StringMath" Version="4.0.0" />
<PackageReference Include="StringMath" Version="4.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
40 changes: 40 additions & 0 deletions Examples/Nodify.Playground/BaseSettingViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;

namespace Nodify.Playground
{
public class BaseSettingViewModel<T> : ObservableObject, ISettingViewModel
{
public string Name { get; }
public string? Description { get; }

private object? _value;

object? ISettingViewModel.Value
{
get => _value;
set => SetProperty(ref _value, value);
}

public SettingsType Type { get;}

public T Value
{
get => (T)((ISettingViewModel)this).Value!;
set => ((ISettingViewModel)this).Value = value;
}

public BaseSettingViewModel(string name, string? description = default)
{
Name = name;
Description = description;
Type = typeof(T) switch
{
{ } t when t == typeof(bool) => SettingsType.Boolean,
{ } t when t == typeof(uint) || t == typeof(double) => SettingsType.Number,
{ } t when t == typeof(PointEditor) => SettingsType.Point,
{ IsEnum: true } => SettingsType.Option,
_ => throw new InvalidOperationException($"Type {typeof(T).Name} does not have a matching {nameof(SettingsType)}.")
};
}
}
}
Loading
Loading