1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Node editor - Tweak pin positions

This commit is contained in:
Robert 2022-03-27 11:48:35 +02:00
parent 2ae1f5f56c
commit fcf0376a9a
9 changed files with 25 additions and 12 deletions

View File

@ -16,6 +16,7 @@
<UserControl.KeyBindings> <UserControl.KeyBindings>
<KeyBinding Command="{CompiledBinding History.Undo}" Gesture="Ctrl+Z"></KeyBinding> <KeyBinding Command="{CompiledBinding History.Undo}" Gesture="Ctrl+Z"></KeyBinding>
<KeyBinding Command="{CompiledBinding History.Redo}" Gesture="Ctrl+Y"></KeyBinding> <KeyBinding Command="{CompiledBinding History.Redo}" Gesture="Ctrl+Y"></KeyBinding>
<KeyBinding Command="{Binding DeleteSelectedNodes}" Gesture="Delete"></KeyBinding>
</UserControl.KeyBindings> </UserControl.KeyBindings>
<paz:ZoomBorder Name="ZoomBorder" <paz:ZoomBorder Name="ZoomBorder"
Stretch="None" Stretch="None"

View File

@ -103,6 +103,19 @@ public class NodeScriptViewModel : ActivatableViewModelBase
set => RaiseAndSetIfChanged(ref _dragViewModel, value); set => RaiseAndSetIfChanged(ref _dragViewModel, value);
} }
public void DeleteSelectedNodes()
{
List<NodeViewModel> toRemove = NodeViewModels.Where(vm => vm.IsSelected && !vm.Node.IsDefaultNode && !vm.Node.IsExitNode).ToList();
if (!toRemove.Any())
return;
using (_nodeEditorService.CreateCommandScope(NodeScript, "Delete nodes"))
{
foreach (NodeViewModel node in toRemove)
_nodeEditorService.ExecuteCommand(NodeScript, new DeleteNode(NodeScript, node.Node));
}
}
public void UpdateNodeSelection(List<NodeViewModel> nodes, bool expand, bool invert) public void UpdateNodeSelection(List<NodeViewModel> nodes, bool expand, bool invert)
{ {
_initialNodeSelection ??= NodeViewModels.Where(vm => vm.IsSelected).ToList(); _initialNodeSelection ??= NodeViewModels.Where(vm => vm.IsSelected).ToList();

View File

@ -41,7 +41,7 @@
VerticalAlignment="Top" VerticalAlignment="Top"
ColumnDefinitions="*,Auto"> ColumnDefinitions="*,Auto">
<TextBlock VerticalAlignment="Center" <TextBlock VerticalAlignment="Center"
Margin="5" Margin="10 0 0 0"
Text="{CompiledBinding Node.Name}" Text="{CompiledBinding Node.Name}"
ToolTip.Tip="{CompiledBinding Node.Description}"> ToolTip.Tip="{CompiledBinding Node.Description}">
</TextBlock> </TextBlock>
@ -57,7 +57,7 @@
</Border> </Border>
<Grid Grid.Row="1" ColumnDefinitions="Auto,*,Auto" Margin="5"> <Grid Grid.Row="1" ColumnDefinitions="Auto,*,Auto" Margin="4">
<StackPanel Grid.Column="0" IsVisible="{CompiledBinding HasInputPins}"> <StackPanel Grid.Column="0" IsVisible="{CompiledBinding HasInputPins}">
<ItemsControl Items="{CompiledBinding InputPinViewModels}" Margin="4 0" /> <ItemsControl Items="{CompiledBinding InputPinViewModels}" Margin="4 0" />
<ItemsControl Items="{CompiledBinding InputPinCollectionViewModels}" /> <ItemsControl Items="{CompiledBinding InputPinCollectionViewModels}" />

View File

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.PanAndZoom;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI; using Avalonia.ReactiveUI;

View File

@ -8,7 +8,7 @@
x:Class="Artemis.UI.Screens.VisualScripting.Pins.InputPinCollectionView" x:Class="Artemis.UI.Screens.VisualScripting.Pins.InputPinCollectionView"
x:DataType="pins:PinCollectionViewModel"> x:DataType="pins:PinCollectionViewModel">
<StackPanel> <StackPanel>
<Button Classes="icon-button icon-button-small" <Button Classes="icon-button icon-button-small pin-collection-button"
ToolTip.Tip="Add new pin" ToolTip.Tip="Add new pin"
Command="{CompiledBinding AddPin}"> Command="{CompiledBinding AddPin}">
<avalonia:MaterialIcon Kind="Add"></avalonia:MaterialIcon> <avalonia:MaterialIcon Kind="Add"></avalonia:MaterialIcon>

View File

@ -8,7 +8,7 @@
x:Class="Artemis.UI.Screens.VisualScripting.Pins.OutputPinCollectionView" x:Class="Artemis.UI.Screens.VisualScripting.Pins.OutputPinCollectionView"
x:DataType="pins:PinCollectionViewModel"> x:DataType="pins:PinCollectionViewModel">
<StackPanel> <StackPanel>
<Button Classes="icon-button icon-button-small" <Button Classes="icon-button icon-button-small pin-collection-button"
ToolTip.Tip="Add new pin" ToolTip.Tip="Add new pin"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Command="{CompiledBinding AddPin}"> Command="{CompiledBinding AddPin}">

View File

@ -6,8 +6,12 @@
</Border> </Border>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector=":is(Button).pin-collection-button">
<!-- <Setter Property="Margin" Value="0 2"/> -->
</Style>
<Style Selector="StackPanel#PinContainer"> <Style Selector="StackPanel#PinContainer">
<Setter Property="Height" Value="24" /> <Setter Property="Height" Value="26" />
<Setter Property="Cursor" Value="Hand" /> <Setter Property="Cursor" Value="Hand" />
</Style> </Style>
<Style Selector="StackPanel#PinContainer Border#PinPoint"> <Style Selector="StackPanel#PinContainer Border#PinPoint">

View File

@ -38,7 +38,7 @@ public class DataModelEventNodeCustomViewModel : CustomNodeViewModel
// Subscribe to node changes // Subscribe to node changes
_node.WhenAnyValue(n => n.Storage).Subscribe(UpdateDataModelPath).DisposeWith(d); _node.WhenAnyValue(n => n.Storage).Subscribe(UpdateDataModelPath).DisposeWith(d);
UpdateDataModelPath(_node.Storage); this.WhenAnyValue(vm => vm.DataModelPath).Subscribe(ApplyDataModelPath).DisposeWith(d);
Disposable.Create(() => Disposable.Create(() =>
{ {
@ -46,8 +46,6 @@ public class DataModelEventNodeCustomViewModel : CustomNodeViewModel
_dataModelPath = null; _dataModelPath = null;
}).DisposeWith(d); }).DisposeWith(d);
}); });
this.WhenAnyValue(vm => vm.DataModelPath).Subscribe(ApplyDataModelPath);
} }
public PluginSetting<bool> ShowFullPaths { get; } public PluginSetting<bool> ShowFullPaths { get; }

View File

@ -38,7 +38,7 @@ public class DataModelNodeCustomViewModel : CustomNodeViewModel
// Subscribe to node changes // Subscribe to node changes
_node.WhenAnyValue(n => n.Storage).Subscribe(UpdateDataModelPath).DisposeWith(d); _node.WhenAnyValue(n => n.Storage).Subscribe(UpdateDataModelPath).DisposeWith(d);
UpdateDataModelPath(_node.Storage); this.WhenAnyValue(vm => vm.DataModelPath).Subscribe(ApplyDataModelPath).DisposeWith(d);
Disposable.Create(() => Disposable.Create(() =>
{ {
@ -46,8 +46,6 @@ public class DataModelNodeCustomViewModel : CustomNodeViewModel
_dataModelPath = null; _dataModelPath = null;
}).DisposeWith(d); }).DisposeWith(d);
}); });
this.WhenAnyValue(vm => vm.DataModelPath).Subscribe(ApplyDataModelPath);
} }
public PluginSetting<bool> ShowFullPaths { get; } public PluginSetting<bool> ShowFullPaths { get; }