1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-31 17:53:32 +00:00

Node picker - Put data model nodes at the top, then static, then alphabetical

This commit is contained in:
Robert 2022-08-26 22:58:31 +02:00
parent 928d9711af
commit 6638eae126
3 changed files with 11 additions and 4 deletions

View File

@ -38,7 +38,8 @@
Grid.Row="1" Grid.Row="1"
Items="{CompiledBinding Categories}" Items="{CompiledBinding Categories}"
IsVisible="{CompiledBinding Categories.Count}" IsVisible="{CompiledBinding Categories.Count}"
SelectedItem="{CompiledBinding SelectedNode}"> SelectedItem="{CompiledBinding SelectedNode}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<TreeView.Styles> <TreeView.Styles>
<Style Selector="TreeViewItem"> <Style Selector="TreeViewItem">
<Setter Property="IsExpanded" Value="True" /> <Setter Property="IsExpanded" Value="True" />
@ -47,8 +48,8 @@
<TreeView.DataTemplates> <TreeView.DataTemplates>
<TreeDataTemplate DataType="{x:Type core:NodeData}"> <TreeDataTemplate DataType="{x:Type core:NodeData}">
<StackPanel Margin="-15 1 0 1" Background="Transparent" PointerReleased="InputElement_OnPointerReleased"> <StackPanel Margin="-15 1 0 1" Background="Transparent" PointerReleased="InputElement_OnPointerReleased">
<TextBlock Classes="BodyStrongTextBlockStyle" Text="{Binding Name}"></TextBlock> <TextBlock Classes="BodyStrongTextBlockStyle" Text="{Binding Name}" TextWrapping="Wrap"></TextBlock>
<TextBlock Foreground="{DynamicResource TextFillColorSecondary}" Text="{Binding Description}"></TextBlock> <TextBlock Foreground="{DynamicResource TextFillColorSecondary}" Text="{Binding Description}" TextWrapping="Wrap"></TextBlock>
</StackPanel> </StackPanel>
</TreeDataTemplate> </TreeDataTemplate>
<TreeDataTemplate ItemsSource="{Binding Items}"> <TreeDataTemplate ItemsSource="{Binding Items}">

View File

@ -10,6 +10,7 @@ using Artemis.UI.Shared.Services.NodeEditor;
using Artemis.UI.Shared.Services.NodeEditor.Commands; using Artemis.UI.Shared.Services.NodeEditor.Commands;
using Avalonia; using Avalonia;
using DynamicData; using DynamicData;
using DynamicData.Binding;
using ReactiveUI; using ReactiveUI;
namespace Artemis.UI.Screens.VisualScripting; namespace Artemis.UI.Screens.VisualScripting;
@ -35,6 +36,11 @@ public class NodePickerViewModel : ActivatableViewModelBase
nodeSourceList.Connect() nodeSourceList.Connect()
.Filter(nodeFilter) .Filter(nodeFilter)
.Sort(SortExpressionComparer<NodeData>
.Descending(d => d.Category == "Data Model")
.ThenByDescending(d => d.Category == "Static")
.ThenByAscending(d => d.Category)
.ThenByAscending(d => d.Name))
.GroupWithImmutableState(n => n.Category) .GroupWithImmutableState(n => n.Category)
.Bind(out ReadOnlyObservableCollection<DynamicData.List.IGrouping<NodeData, string>> categories) .Bind(out ReadOnlyObservableCollection<DynamicData.List.IGrouping<NodeData, string>> categories)
.Subscribe(); .Subscribe();

View File

@ -4,7 +4,7 @@ using Artemis.VisualScripting.Nodes.List.Screens;
namespace Artemis.VisualScripting.Nodes.List; namespace Artemis.VisualScripting.Nodes.List;
[Node("List Operator", "Checks if any/all/no value in the input list matches the input value", "List", InputType = typeof(IEnumerable), OutputType = typeof(bool))] [Node("List Operator (Simple)", "Checks if any/all/no value in the input list matches the input value", "List", InputType = typeof(IEnumerable), OutputType = typeof(bool))]
public class ListOperatorNode : Node<ListOperator, ListOperatorNodeCustomViewModel> public class ListOperatorNode : Node<ListOperator, ListOperatorNodeCustomViewModel>
{ {
public ListOperatorNode() : base("List Operator", "Checks if any/all/no value in the input list matches the input value") public ListOperatorNode() : base("List Operator", "Checks if any/all/no value in the input list matches the input value")