private void OnMouseDown(MouseDownEvent e) { if (this.m_Active) { e.StopImmediatePropagation(); } else if (!MouseCaptureController.IsMouseCaptureTaken()) { GraphElement graphElement = base.parent as GraphElement; if (graphElement != null) { if (graphElement.IsResizable()) { if (e.button == (int)this.activateButton) { this.m_Start = this.ChangeCoordinatesTo(base.parent, e.localMousePosition); this.m_StartPos = base.parent.layout; if (base.parent.style.positionType != PositionType.Manual) { Debug.LogWarning("Attempting to resize an object with a non manual position"); } this.m_Active = true; this.TakeMouseCapture(); e.StopPropagation(); } } } } }
private void OnMouseMove(MouseMoveEvent e) { GraphElement graphElement = base.parent as GraphElement; if (graphElement != null) { if (graphElement.IsResizable()) { if (this.m_Active && base.parent.style.positionType == PositionType.Manual) { Vector2 vector = this.ChangeCoordinatesTo(base.parent, e.localMousePosition) - this.m_Start; Vector2 vector2 = new Vector2(this.m_StartPos.width + vector.x, this.m_StartPos.height + vector.y); if (vector2.x < this.m_MinimumSize.x) { vector2.x = this.m_MinimumSize.x; } if (vector2.y < this.m_MinimumSize.y) { vector2.y = this.m_MinimumSize.y; } graphElement.SetPosition(new Rect(graphElement.layout.x, graphElement.layout.y, vector2.x, vector2.y)); graphElement.UpdatePresenterPosition(); GraphView firstAncestorOfType = graphElement.GetFirstAncestorOfType <GraphView>(); if (firstAncestorOfType != null && firstAncestorOfType.elementResized != null) { firstAncestorOfType.elementResized(graphElement); } this.m_LabelText.text = string.Format("{0:0}", base.parent.layout.width) + "x" + string.Format("{0:0}", base.parent.layout.height); e.StopPropagation(); } } } }
public void AddElement(GraphElement graphElement) { if (graphElement.IsResizable()) { graphElement.shadow.Add(new Resizer()); graphElement.style.borderBottom = 6; } int newLayer = graphElement.layer; if (!m_ContainerLayers.ContainsKey(newLayer)) { AddLayer(newLayer); } GetLayer(newLayer).Add(graphElement); // Attempt to restore selection on the new element if it // was previously selected (same GUID). RestorePersistedSelection(); }
private void OnMouseUp(MouseUpEvent e) { GraphElement graphElement = base.parent as GraphElement; if (graphElement != null) { if (graphElement.IsResizable()) { if (this.m_Active) { if (e.button == (int)this.activateButton && this.m_Active) { this.m_Active = false; this.ReleaseMouseCapture(); e.StopPropagation(); } } } } }