Skip to content

Commit

Permalink
Optimization No longer forces connector type
Browse files Browse the repository at this point in the history
Fix If the connector is a Combobox can't click to expand it
  • Loading branch information
MakesYT committed Nov 19, 2024
1 parent 8c7112b commit ffbb57c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
20 changes: 15 additions & 5 deletions NodifyM.Avalonia.Example/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.ObjectModel;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Styling;
using CommunityToolkit.Mvvm.Input;
using NodifyM.Avalonia.ViewModelBase;
Expand All @@ -27,16 +28,25 @@ public MainWindowViewModel()
Connections.Add(new ConnectionViewModelBase(this,output1,knot1.Connector,"Test"));
Connections.Add(new ConnectionViewModelBase(this,knot1.Connector,input1));
Nodes =new(){

new NodeViewModelBase()
{
Location = new Point(400, 2000),
Title = "Node 1",
Input = new ObservableCollection<ConnectorViewModelBase>
Input = new ObservableCollection<object>
{
input1,

new ComboBox()
{
ItemsSource = new ObservableCollection<object>
{
"Item 1",
"Item 2",
"Item 3"
}
}
},
Output = new ObservableCollection<ConnectorViewModelBase>
Output = new ObservableCollection<object>
{

new ConnectorViewModelBase()
Expand All @@ -50,7 +60,7 @@ public MainWindowViewModel()
{
Title = "Node 2",
Location = new Point(-100,-100),
Input = new ObservableCollection<ConnectorViewModelBase>
Input = new ObservableCollection<object>
{
new ConnectorViewModelBase()
{
Expand All @@ -63,7 +73,7 @@ public MainWindowViewModel()
Title = "Input 2"
}
},
Output = new ObservableCollection<ConnectorViewModelBase>
Output = new ObservableCollection<object>
{
output1,
new ConnectorViewModelBase()
Expand Down
14 changes: 14 additions & 0 deletions NodifyM.Avalonia/Controls/BaseNode.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,25 @@ protected override void OnPointerReleased(PointerReleasedEventArgs e)
protected override void OnPointerPressed(PointerPressedEventArgs e)
{
base.OnPointerPressed(e);

if (e.Handled)
{
return;
}

if (e.Source is Control control)
{
if (control is ComboBox)
{
return;
}

if (control.TemplatedParent is ComboBox)
{
return;
}
}

_editor.SelectItem(this);
if (!e.GetCurrentPoint(this)
.Properties.IsLeftButtonPressed) return;
Expand Down
2 changes: 2 additions & 0 deletions NodifyM.Avalonia/ViewModelBase/ConnectorViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ public enum ConnectorFlow
private string _title;
[ObservableProperty]
private bool _isConnected;
[ObservableProperty]
private bool _canConnect;
public ConnectorFlow? Flow { get; set; }
}
4 changes: 2 additions & 2 deletions NodifyM.Avalonia/ViewModelBase/NodeViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public partial class NodeViewModelBase : BaseNodeViewModel

[ObservableProperty] private string _title;
[ObservableProperty] private string _footer;
[ObservableProperty] private ObservableCollection<ConnectorViewModelBase> input = new();
[ObservableProperty] private ObservableCollection<ConnectorViewModelBase> output = new();
[ObservableProperty] private ObservableCollection<object> input = new();
[ObservableProperty] private ObservableCollection<object> output = new();
}

0 comments on commit ffbb57c

Please sign in to comment.