void IEdgeConnectorListener.OnDropOutsidePort(Edge edge, Vector2 position) { VFXSlot startSlot = controller.model; VFXView view = this.GetFirstAncestorOfType <VFXView>(); VFXViewController viewController = view.controller; List <VisualElement> picked = new List <VisualElement>(); panel.PickAll(position, picked); VFXNodeUI endNode = null; foreach (var element in picked) { if (element is VFXNodeUI node) { endNode = node; break; } } VFXDataEdge dataEdge = edge as VFXDataEdge; bool exists = false; if (dataEdge.controller != null) { exists = true; view.controller.RemoveElement(dataEdge.controller); } if (endNode != null) { VFXNodeController nodeController = endNode.controller; if (nodeController != null) { IVFXSlotContainer slotContainer = nodeController.slotContainer; if (controller.direction == Direction.Input) { foreach (var output in nodeController.outputPorts.Where(t => t.model == null || t.model.IsMasterSlot())) { if (viewController.CreateLink(controller, output)) { break; } } } else { foreach (var input in nodeController.inputPorts.Where(t => t.model == null || t.model.IsMasterSlot() && !t.model.HasLink(true))) { if (viewController.CreateLink(input, controller)) { break; } } } } } else if (controller.direction == Direction.Input && Event.current.modifiers == EventModifiers.Alt) { VFXModelDescriptorParameters parameterDesc = VFXLibrary.GetParameters().FirstOrDefault(t => t.name == controller.portType.UserFriendlyName()); if (parameterDesc != null) { Vector2 pos = view.contentViewContainer.GlobalToBound(position) - new Vector2(140, 20); VFXParameter parameter = viewController.AddVFXParameter(pos, parameterDesc, false); parameter.SetSettingValue("m_Exposed", true); startSlot.Link(parameter.outputSlots[0]); CopyValueToParameter(parameter); viewController.AddVFXModel(pos, parameter); } } else if (!exists) { if (direction == Direction.Input || viewController.model.visualEffectObject is VisualEffectSubgraphOperator) // no context for subgraph operators. { VFXFilterWindow.Show(VFXViewWindow.currentWindow, Event.current.mousePosition, view.ViewToScreenPosition(Event.current.mousePosition), new VFXNodeProvider(viewController, AddLinkedNode, ProviderFilter, new Type[] { typeof(VFXOperator), typeof(VFXParameter) })); } else { VFXFilterWindow.Show(VFXViewWindow.currentWindow, Event.current.mousePosition, view.ViewToScreenPosition(Event.current.mousePosition), new VFXNodeProvider(viewController, AddLinkedNode, ProviderFilter, new Type[] { typeof(VFXOperator), typeof(VFXParameter), typeof(VFXContext) })); } } }
protected VFXDataAnchor(Orientation anchorOrientation, Direction anchorDirection, Type type, VFXNodeUI node) : base(anchorOrientation, anchorDirection, Capacity.Multi, type) { Profiler.BeginSample("VFXDataAnchor.VFXDataAnchor"); this.AddStyleSheetPath("VFXDataAnchor"); AddToClassList("VFXDataAnchor"); this.AddStyleSheetPath("VFXTypeColor"); m_ConnectorHighlight = new VisualElement(); m_ConnectorHighlight.style.position = PositionType.Absolute; m_ConnectorHighlight.style.top = 0f; m_ConnectorHighlight.style.left = 0f; m_ConnectorHighlight.style.bottom = 0f; m_ConnectorHighlight.style.right = 0f; m_ConnectorHighlight.pickingMode = PickingMode.Ignore; VisualElement connector = m_ConnectorBox as VisualElement; connector.Add(m_ConnectorHighlight); m_Node = node; RegisterCallback <MouseEnterEvent>(OnMouseEnter); RegisterCallback <MouseLeaveEvent>(OnMouseLeave); this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu)); Profiler.EndSample(); }
void IEdgeConnectorListener.OnDropOutsidePort(Edge edge, Vector2 position) { VFXSlot startSlot = controller.model; VFXView view = this.GetFirstAncestorOfType <VFXView>(); VFXViewController viewController = view.controller; VFXNodeUI endNode = null; foreach (var node in view.GetAllNodes()) { if (node.worldBound.Contains(position)) { endNode = node; } } VFXDataEdge dataEdge = edge as VFXDataEdge; bool exists = false; if (dataEdge.controller != null) { exists = true; view.controller.RemoveElement(dataEdge.controller); } if (endNode != null) { VFXNodeController nodeController = endNode.controller; if (nodeController != null) { IVFXSlotContainer slotContainer = nodeController.slotContainer; if (controller.direction == Direction.Input) { foreach (var output in nodeController.outputPorts.Where(t => t.model == null || t.model.IsMasterSlot())) { if (viewController.CreateLink(controller, output)) { break; } } } else { foreach (var input in nodeController.inputPorts.Where(t => t.model == null || t.model.IsMasterSlot())) { if (viewController.CreateLink(input, controller)) { break; } } } } } else if (controller.direction == Direction.Input && Event.current.modifiers == EventModifiers.Alt) { VFXModelDescriptorParameters parameterDesc = VFXLibrary.GetParameters().FirstOrDefault(t => t.name == controller.portType.UserFriendlyName()); if (parameterDesc != null) { VFXParameter parameter = viewController.AddVFXParameter(view.contentViewContainer.GlobalToBound(position) - new Vector2(360, 0), parameterDesc); startSlot.Link(parameter.outputSlots[0]); CopyValueToParameter(parameter); } } else if (!exists) { VFXFilterWindow.Show(VFXViewWindow.currentWindow, Event.current.mousePosition, view.ViewToScreenPosition(Event.current.mousePosition), new VFXNodeProvider(viewController, AddLinkedNode, ProviderFilter, new Type[] { typeof(VFXOperator), typeof(VFXParameter) })); } }
protected VFXDataAnchor(Orientation anchorOrientation, Direction anchorDirection, Type type, VFXNodeUI node) : base(anchorOrientation, anchorDirection, Capacity.Multi, type) { Profiler.BeginSample("VFXDataAnchor.VFXDataAnchor"); this.AddStyleSheetPath("VFXDataAnchor"); AddToClassList("VFXDataAnchor"); this.AddStyleSheetPath("VFXTypeColor"); m_Node = node; RegisterCallback <MouseEnterEvent>(OnMouseEnter); RegisterCallback <MouseLeaveEvent>(OnMouseLeave); this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu)); Profiler.EndSample(); }
// TODO This is a workaround to avoid having a generic type for the anchor as generic types mess with USS. public static new VFXOutputDataAnchor Create(VFXDataAnchorController controller, VFXNodeUI node) { var anchor = new VFXOutputDataAnchor(controller.orientation, controller.direction, controller.portType, node); anchor.m_EdgeConnector = new EdgeConnector <VFXDataEdge>(anchor); anchor.controller = controller; anchor.AddManipulator(anchor.m_EdgeConnector); return(anchor); }
protected VFXOutputDataAnchor(Orientation anchorOrientation, Direction anchorDirection, Type type, VFXNodeUI node) : base(anchorOrientation, anchorDirection, type, node) { m_Icon = new VisualElement() { name = "icon" }; //Add(new VisualElement() { name = "lineSpacer" }); AddToClassList("VFXOutputDataAnchor"); Add(m_Icon); //insert at first ( right since reversed) }
public virtual VFXDataAnchor InstantiateDataAnchor(VFXDataAnchorController controller, VFXNodeUI node) { if (controller.direction == Direction.Input) { VFXEditableDataAnchor anchor = VFXEditableDataAnchor.Create(controller, node); return(anchor); } else { return(VFXOutputDataAnchor.Create(controller, node)); } }
protected VFXEditableDataAnchor(Orientation anchorOrientation, Direction anchorDirection, Type type, VFXNodeUI node) : base(anchorOrientation, anchorDirection, type, node) { Profiler.BeginSample("VFXEditableDataAnchor.VFXEditableDataAnchor"); RegisterCallback <AttachToPanelEvent>(OnAttachToPanel); RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel); Profiler.EndSample(); }
// TODO This is a workaround to avoid having a generic type for the anchor as generic types mess with USS. public static new VFXEditableDataAnchor Create(VFXDataAnchorController controller, VFXNodeUI node) { Profiler.BeginSample("VFXEditableDataAnchor.Create"); var anchor = new VFXEditableDataAnchor(controller.orientation, controller.direction, controller.portType, node); anchor.m_EdgeConnector = new EdgeConnector <VFXDataEdge>(anchor); anchor.controller = controller; anchor.AddManipulator(anchor.m_EdgeConnector); Profiler.EndSample(); return(anchor); }
protected VFXInputParameterDataAnchor(Orientation anchorOrientation, Direction anchorDirection, Type type, VFXNodeUI node) : base(anchorOrientation, anchorDirection, type, node) { }
public override VFXDataAnchor InstantiateDataAnchor(VFXDataAnchorController controller, VFXNodeUI node) { if (controller.direction == Direction.Input) { return(VFXInputParameterDataAnchor.Create(controller, node)); } else { return(VFXOutputParameterDataAnchor.Create(controller, node)); } }