mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Node script editor - Prevent creating loops
Node script popout editor - Added auto-layout hotkey (Ctrl+F)
This commit is contained in:
1 parent
65b8b377ec
commit
8e3b6c3459
4 files changed
+101
-19
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
@@ -197,8 +198,14 @@ public class NodeScriptViewModel : ActivatableViewModelBase
|
||||
DragViewModel = new DragCableViewModel(sourcePinViewModel);
|
||||
|
||||
DragViewModel.DragPoint = position;
|
||||
if (targetPinVmModel == null)
|
||||
return true;
|
||||
if (!targetPinVmModel.IsCompatibleWith(sourcePinViewModel))
|
||||
return false;
|
||||
|
||||
return targetPinVmModel == null || targetPinVmModel.IsCompatibleWith(sourcePinViewModel);
|
||||
return sourcePinViewModel.Pin.Direction == PinDirection.Output
|
||||
? !targetPinVmModel.Pin.Node.IsInLoop(sourcePinViewModel.Pin.Node)
|
||||
: !sourcePinViewModel.Pin.Node.IsInLoop(targetPinVmModel.Pin.Node);
|
||||
}
|
||||
|
||||
public void FinishPinDrag(PinViewModel sourcePinViewModel, PinViewModel? targetPinVmModel, Point position)
|
||||
@@ -211,7 +218,10 @@ public class NodeScriptViewModel : ActivatableViewModelBase
|
||||
// If dropped on top of a compatible pin, connect to it
|
||||
if (targetPinVmModel != null && targetPinVmModel.IsCompatibleWith(sourcePinViewModel))
|
||||
{
|
||||
_nodeEditorService.ExecuteCommand(NodeScript, new ConnectPins(sourcePinViewModel.Pin, targetPinVmModel.Pin));
|
||||
if (sourcePinViewModel.Pin.Direction == PinDirection.Output && !targetPinVmModel.Pin.Node.IsInLoop(sourcePinViewModel.Pin.Node))
|
||||
_nodeEditorService.ExecuteCommand(NodeScript, new ConnectPins(sourcePinViewModel.Pin, targetPinVmModel.Pin));
|
||||
else if (sourcePinViewModel.Pin.Direction == PinDirection.Input && !sourcePinViewModel.Pin.Node.IsInLoop(targetPinVmModel.Pin.Node))
|
||||
_nodeEditorService.ExecuteCommand(NodeScript, new ConnectPins(sourcePinViewModel.Pin, targetPinVmModel.Pin));
|
||||
}
|
||||
// If not dropped on a pin allow the user to create a new node
|
||||
else if (targetPinVmModel == null)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<Window.KeyBindings>
|
||||
<KeyBinding Command="{CompiledBinding History.Undo}" Gesture="Ctrl+Z" />
|
||||
<KeyBinding Command="{CompiledBinding History.Redo}" Gesture="Ctrl+Y" />
|
||||
<KeyBinding Command="{CompiledBinding AutoArrange}" Gesture="Ctrl+F" />
|
||||
</Window.KeyBindings>
|
||||
<Grid Margin="15" ColumnDefinitions="*,*" RowDefinitions="Auto,Auto,*">
|
||||
<Menu Grid.Row="0" Grid.ColumnSpan="2" VerticalAlignment="Top" Margin="-10 -10 -10 0">
|
||||
@@ -43,7 +44,7 @@
|
||||
</DataTemplate>
|
||||
</MenuItem.DataTemplates>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Auto-arrange" Command="{CompiledBinding AutoArrange}">
|
||||
<MenuItem Header="Auto-arrange" Command="{CompiledBinding AutoArrange}" InputGesture="Ctrl+F">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Sort" />
|
||||
</MenuItem.Icon>
|
||||
|
||||
Reference in new issue
Block a user