void CreatePlacemat(DropdownMenuAction a) { Vector2 pos = a.eventInfo.localMousePosition; Vector2 localPos = VisualElementExtensions.ChangeCoordinatesTo(this, contentViewContainer, pos); CreatePlacemat(new Rect(localPos.x, localPos.y, 200, 200)); }
private void OnScroll(WheelEvent e) { Vector2 zoomCenter = VisualElementExtensions.ChangeCoordinatesTo(base.target, this.targetElement, e.localMousePosition); float zoomScale = 1f - e.delta.y * zoomStep; this.Zoom(zoomCenter, zoomScale); e.StopPropagation(); }
private GraphElement CreateGraphMathStackNode(Vector2 pos) { var stackNode = ScriptableObject.CreateInstance <MathStackNode>(); Vector2 localPos = VisualElementExtensions.ChangeCoordinatesTo(this, contentViewContainer, pos); stackNode.name = "Stack"; stackNode.m_Position = localPos; m_SimpleGraphViewWindow.AddNode(stackNode); return(m_SimpleGraphViewWindow.CreateNode(stackNode)); }
protected void OnMouseDown(MouseDownEvent e) { if (base.CanStartManipulation(e)) { this.m_Start = (this.m_Last = e.localMousePosition); this.m_ZoomCenter = VisualElementExtensions.ChangeCoordinatesTo(base.target, this.m_GraphUI, this.m_Start); this.m_Active = true; MouseCaptureController.TakeMouseCapture(base.target); e.StopPropagation(); } Debug.Log(e); }
private void CreateGroupNode(DropdownMenuAction a) { Vector2 pos = a.eventInfo.localMousePosition; var groupNode = ScriptableObject.CreateInstance <MathGroupNode>(); Vector2 localPos = VisualElementExtensions.ChangeCoordinatesTo(this, contentViewContainer, pos); groupNode.m_Title = "New Group"; groupNode.m_Position = localPos; m_SimpleGraphViewWindow.AddNode(groupNode); GraphElement graphGroup = m_SimpleGraphViewWindow.CreateNode(groupNode); AddElement(graphGroup); }
public override void BuildContextualMenu(ContextualMenuPopulateEvent evt) { foreach (var t in Enum.GetValues(typeof(ExpressionType))) { var type = (ExpressionType)t; if (type == ExpressionType.Undefined || type == ExpressionType.Results) { continue; } evt.menu.AppendAction($"Create {type}", menuAction => { var n = AddNode(type); var localPos = VisualElementExtensions.ChangeCoordinatesTo(this, contentViewContainer, menuAction.eventInfo.localMousePosition); n.SetPosition(new Rect(localPos, n.GetPosition().size)); }); } evt.menu.AppendSeparator(); base.BuildContextualMenu(evt); }
private void CreateStickyNote(DropdownMenuAction a) { Vector2 pos = a.eventInfo.localMousePosition; var stickyNote = ScriptableObject.CreateInstance <MathStickyNote>(); Vector2 localPos = VisualElementExtensions.ChangeCoordinatesTo(this, contentViewContainer, pos); stickyNote.title = "New Title"; stickyNote.contents = "Type something here"; stickyNote.position = new Rect(localPos, new Vector2(200, 180)); m_SimpleGraphViewWindow.AddStickyNote(stickyNote); var simpleStickyNote = new SimpleStickyNote(); simpleStickyNote.model = stickyNote; simpleStickyNote.userData = stickyNote; AddElement(simpleStickyNote); }