Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ void OnGeometryChanged(GeometryChangedEvent evt)
}
}

// Workaround for bug in GraphView that makes the node selection border way too big
VisualElement selectionBorder, nodeBorder;
internal void EnableSyncSelectionBorderHeight()
{
Expand All @@ -275,12 +274,11 @@ internal void EnableSyncSelectionBorderHeight()
selectionBorder = this.Q("selection-border");
nodeBorder = this.Q("node-border");

schedule.Execute(() => {
nodeBorder.RegisterCallback<GeometryChangedEvent>(e => {
selectionBorder.style.height = nodeBorder.localBound.height;
}).Every(17);
});
}
}

}
void CreateSettingButton()
{
settingButton = new Button(ToggleSettings){name = "settings-button"};
Expand Down Expand Up @@ -826,6 +824,10 @@ protected VisualElement AddControlField(string fieldName, string label = null, b
Regex s_ReplaceNodeIndexPropertyPath = new Regex(@"(^nodes.Array.data\[)(\d+)(\])");
internal void SyncSerializedPropertyPathes()
{
if (owner.serializedGraph == null)
return;

// Find the actual index of this node in the graph's node list
int nodeIndex = owner.graph.nodes.FindIndex(n => n == nodeTarget);

// If the node is not found, then it means that it has been deleted from serialized data.
Expand All @@ -835,6 +837,8 @@ internal void SyncSerializedPropertyPathes()
var nodeIndexString = nodeIndex.ToString();
foreach (var propertyField in this.Query<PropertyField>().ToList())
{
if (propertyField.bindingPath == null)
continue;
propertyField.Unbind();
// The property path look like this: nodes.Array.data[x].fieldName
// And we want to update the value of x with the new node index:
Expand Down Expand Up @@ -863,8 +867,17 @@ protected VisualElement AddControlField(FieldInfo field, string label = null, bo
#endif

if (typeof(IList).IsAssignableFrom(field.FieldType))
{
EnableSyncSelectionBorderHeight();

element.RegisterCallback<MouseDownEvent>(e => {
if (e.button == 0)
e.StopPropagation();
});
element.RegisterCallback<MouseMoveEvent>(e => {
if (e.pressedButtons == 1)
e.StopPropagation();
});
}
element.RegisterValueChangeCallback(e => {
UpdateFieldVisibility(field.Name, field.GetValue(nodeTarget));
valueChangedCallback?.Invoke();
Expand Down Expand Up @@ -1176,4 +1189,4 @@ void UpdatePortsForField(string fieldName)

#endregion
}
}
}