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

Added Orientation to NodeInput and NodeOutput #105

Merged
merged 2 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
> - Added DrawDirectionalArrowsGeometry and DrawDirectionalArrowheadGeometry to BaseConnection to allow customizing the directional arrows
> - Improved EditorGestures to allow changing input gestures at runtime
> - Added new gesture types: AnyGesture, AllGestures, and InputGestureRef
> - Added Orientation dependency property to NodeInput and NodeOutput
> - Bugfixes:
> - Fixed BaseConnection.Text not always displaying in the center of the connection
> - Fixed a bug where the item container would incorrectly transition to the dragging state on mouse over
Expand Down
20 changes: 7 additions & 13 deletions Examples/Nodify.Playground/Editor/NodifyEditorView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,7 @@
<DataTemplate DataType="{x:Type local:ConnectorViewModel}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" Margin="0 0 5 0" VerticalAlignment="Center" />
<ComboBox DisplayMemberPath="Name"
SelectedValuePath="Value"
SelectedValue="{Binding Shape}"
ItemsSource="{Binding Shape, Converter={shared:EnumValuesConverter}}" />
<CheckBox />
</StackPanel>
</DataTemplate>
</Setter.Value>
Expand All @@ -346,6 +343,8 @@
Value="{Binding Anchor, Mode=OneWayToSource}" />
<Setter Property="IsConnected"
Value="{Binding IsConnected}" />
<Setter Property="Background"
Value="Transparent" />
</Style>

<Style TargetType="{x:Type nodify:NodeOutput}"
Expand All @@ -368,6 +367,8 @@
Value="{Binding Anchor, Mode=OneWayToSource}" />
<Setter Property="IsConnected"
Value="{Binding IsConnected}" />
<Setter Property="Background"
Value="Transparent" />
</Style>

<DataTemplate DataType="{x:Type local:KnotNodeViewModel}">
Expand Down Expand Up @@ -400,10 +401,7 @@
<ItemsControl ItemsSource="{Binding}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:ConnectorViewModel}">
<StackPanel Orientation="Vertical" Margin="5 0 5 0">
<nodify:Connector Anchor="{Binding Anchor, Mode=OneWayToSource}" />
<TextBlock Text="{Binding Title}" />
</StackPanel>
<nodify:NodeInput Orientation="Vertical" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
Expand All @@ -419,11 +417,7 @@
<ItemsControl ItemsSource="{Binding}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:ConnectorViewModel}">
<StackPanel Orientation="Vertical"
Margin="5 0 5 0">
<TextBlock Text="{Binding Title}" />
<nodify:Connector Anchor="{Binding Anchor, Mode=OneWayToSource}" />
</StackPanel>
<nodify:NodeOutput Orientation="Vertical" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
Expand Down
8 changes: 8 additions & 0 deletions Nodify/Nodes/NodeInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class NodeInput : Connector
public static readonly DependencyProperty HeaderProperty = HeaderedContentControl.HeaderProperty.AddOwner(typeof(NodeInput));
public static readonly DependencyProperty HeaderTemplateProperty = HeaderedContentControl.HeaderTemplateProperty.AddOwner(typeof(NodeInput));
public static readonly DependencyProperty ConnectorTemplateProperty = DependencyProperty.Register(nameof(ConnectorTemplate), typeof(ControlTemplate), typeof(NodeInput));
public static readonly DependencyProperty OrientationProperty = StackPanel.OrientationProperty.AddOwner(typeof(NodeInput), new FrameworkPropertyMetadata(Orientation.Horizontal, FrameworkPropertyMetadataOptions.AffectsMeasure));

/// <summary>
/// Gets of sets the data used for the control's header.
Expand Down Expand Up @@ -41,6 +42,13 @@ public ControlTemplate ConnectorTemplate
set => SetValue(ConnectorTemplateProperty, value);
}

/// <inheritdoc cref="StackPanel.Orientation" />
public Orientation Orientation
{
get => (Orientation)GetValue(OrientationProperty);
set => SetValue(OrientationProperty, value);
}

#endregion

static NodeInput()
Expand Down
10 changes: 9 additions & 1 deletion Nodify/Nodes/NodeOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public class NodeOutput : Connector
public static readonly DependencyProperty HeaderProperty = HeaderedContentControl.HeaderProperty.AddOwner(typeof(NodeOutput));
public static readonly DependencyProperty HeaderTemplateProperty = HeaderedContentControl.HeaderTemplateProperty.AddOwner(typeof(NodeOutput));
public static readonly DependencyProperty ConnectorTemplateProperty = NodeInput.ConnectorTemplateProperty.AddOwner(typeof(NodeOutput));

public static readonly DependencyProperty OrientationProperty = NodeInput.OrientationProperty.AddOwner(typeof(NodeOutput), new FrameworkPropertyMetadata(Orientation.Horizontal, FrameworkPropertyMetadataOptions.AffectsMeasure));

/// <summary>
/// Gets of sets the data used for the control's header.
/// </summary>
Expand Down Expand Up @@ -41,6 +42,13 @@ public ControlTemplate ConnectorTemplate
set => SetValue(ConnectorTemplateProperty, value);
}

/// <inheritdoc cref="StackPanel.Orientation" />
public Orientation Orientation
{
get => (Orientation)GetValue(OrientationProperty);
set => SetValue(OrientationProperty, value);
}

#endregion

static NodeOutput()
Expand Down
2 changes: 2 additions & 0 deletions Nodify/Nodify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
> - Added source and target parameters to GetTextPosition in BaseConnection
> - EditorGestures is now a singleton instead of a static class (can be inherited from to create custom mappings)
> - Selection gestures for ItemContainer and GroupingNode are now separated from the NodifyEditor selection gestures
> - Renamed EditorGestures.Editor.Zoom to ZoomModifierKey
> - Features:
> - Added SourceOrientation and TargetOrientation to BaseConnection to support vertical connectors (vertical/mixed connection orientation)
> - Added DirectionalArrowsCount to BaseConnection to allow drawing multipe arrows on a connection flowing in the connection direction
> - Added DrawDirectionalArrowsGeometry and DrawDirectionalArrowheadGeometry to BaseConnection to allow customizing the directional arrows
> - Improved EditorGestures to allow changing input gestures at runtime
> - Added new gesture types: AnyGesture, AllGestures and InputGestureRef
> - Added Orientation dependency property to NodeInput and NodeOutput
> - Bugfixes:
> - Fixed BaseConnection.Text not always displaying in the center of the connection
> - Fixed a bug where the item container would incorrectly transition to the dragging state on mouse over
Expand Down
9 changes: 8 additions & 1 deletion Nodify/Themes/Styles/NodeInput.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
OpacityMask="{StaticResource FadeOpacityMask}"
Background="{TemplateBinding BorderBrush}" />

<StackPanel Orientation="Horizontal"
<StackPanel Orientation="{TemplateBinding Orientation}"
Margin="{TemplateBinding Padding}">

<Control x:Name="PART_Connector"
Expand All @@ -59,6 +59,13 @@
</StackPanel>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Orientation"
Value="Vertical">
<Setter TargetName="PART_Connector"
Property="Margin"
Value="0 0 0 5" />
</Trigger>

<Trigger Property="IsConnected"
Value="True">
<Setter TargetName="PART_Connector"
Expand Down
9 changes: 8 additions & 1 deletion Nodify/Themes/Styles/NodeOutput.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
OpacityMask="{StaticResource FadeOpacityMask}"
Background="{TemplateBinding BorderBrush}" />

<StackPanel Orientation="Horizontal"
<StackPanel Orientation="{TemplateBinding Orientation}"
HorizontalAlignment="Right"
Margin="{TemplateBinding Padding}">

Expand All @@ -60,6 +60,13 @@
</StackPanel>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Orientation"
Value="Vertical">
<Setter TargetName="PART_Connector"
Property="Margin"
Value="0 5 0 0" />
</Trigger>

<Trigger Property="IsConnected"
Value="True">
<Setter TargetName="PART_Connector"
Expand Down
Loading