internal void BringToFront(Placemat placemat) { m_Placemats.Remove(placemat); m_Placemats.AddLast(placemat); UpdateElementsOrder(); }
internal void SendToBack(Placemat placemat) { m_Placemats.Remove(placemat); m_Placemats.AddFirst(placemat); UpdateElementsOrder(); }
internal void CyclePlacemat(Placemat placemat, CycleDirection direction) { var node = m_Placemats.Find(placemat); if (node == null) { return; } var next = direction == CycleDirection.Up ? node.Next : node.Previous; if (next != null) { m_Placemats.Remove(placemat); if (direction == CycleDirection.Down) { m_Placemats.AddBefore(next, node); } else { m_Placemats.AddAfter(next, node); } } UpdateElementsOrder(); }
void GetElementsToMove(Placemat placemat, HashSet <GraphElement> elementsToMove) { var method = typeof(Placemat).GetMethod("GetElementsToMove", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { method.Invoke(placemat, new object[] { false, elementsToMove }); } }
// TODO: Move to local function of Collapse once we move to C# 7.0 or higher. void RecurseRebuildCollapsedElements_LocalFunc(Placemat currentPlacemat, IList <GraphElement> graphElements, List <GraphElement> collapsedElementsElsewhere) { var currRect = currentPlacemat.ExpandedPosition; var currentActivePlacematRect = new Rect( currRect.x + k_SelectRectOffset, currRect.y + k_SelectRectOffset, currRect.width - 2 * k_SelectRectOffset, currRect.height - 2 * k_SelectRectOffset); foreach (var elem in graphElements) { if (elem.layout.Overlaps(currentActivePlacematRect)) { var placemat = elem as Placemat; if (placemat != null && placemat.ZOrder > currentPlacemat.ZOrder) { if (placemat.Collapsed) { foreach (var cge in placemat.CollapsedElements) { collapsedElementsElsewhere.Add(cge); } } else { RecurseRebuildCollapsedElements_LocalFunc(placemat, graphElements, collapsedElementsElsewhere); } } if (placemat == null || placemat.ZOrder > currentPlacemat.ZOrder) { if (elem.resolvedStyle.visibility == Visibility.Visible) { m_CollapsedElements.Add(elem); } } } } }
public bool GetPortCenterOverride(Port port, out Vector2 overriddenPosition) { Node rootNode = port.node; if (rootNode != null) { Node currNode; while ((currNode = rootNode.GetFirstAncestorOfType <Node>()) != null) { rootNode = currNode; } //Find the furthest placemat containing the rootNode and that is collapsed (if any) Placemat placemat = m_Placemats.FirstOrDefault(p => p.Collapsed && p.WillDragNode(rootNode)); if (placemat != null) { return(placemat.GetPortCenterOverride(port, out overriddenPosition)); } } overriddenPosition = Vector3.zero; return(false); }
// TODO: Move to local function of ActOnGraphElementsOver once we move to C# 7.0 or higher. static bool RecurseActOnGraphElementsOver_LocalFunc(Placemat currentPlacemat, List <GraphElement> graphElements, Func <GraphElement, bool> act, bool includePlacemats) { if (currentPlacemat.Collapsed) { foreach (var elem in currentPlacemat.CollapsedElements) { var placemat = elem as Placemat; if (placemat != null && placemat.ZOrder > currentPlacemat.ZOrder) { if (RecurseActOnGraphElementsOver_LocalFunc(placemat, graphElements, act, includePlacemats)) { return(true); } } if (placemat == null || (includePlacemats && placemat.ZOrder > currentPlacemat.ZOrder)) { if (act(elem)) { return(true); } } } } else { var currRect = currentPlacemat.ExpandedPosition; var currentActivePlacematRect = new Rect( currRect.x + k_SelectRectOffset, currRect.y + k_SelectRectOffset, currRect.width - 2 * k_SelectRectOffset, currRect.height - 2 * k_SelectRectOffset); foreach (var elem in graphElements) { if (elem.layout.Overlaps(currentActivePlacematRect)) { var placemat = elem as Placemat; if (placemat != null && placemat.ZOrder > currentPlacemat.ZOrder) { if (RecurseActOnGraphElementsOver_LocalFunc(placemat, graphElements, act, includePlacemats)) { return(true); } } if (placemat == null || (includePlacemats && placemat.ZOrder > currentPlacemat.ZOrder)) { if (elem.resolvedStyle.visibility != Visibility.Hidden) { if (act(elem)) { return(true); } } } } } } return(false); }
void RemovePlacemat(Placemat placemat) { placemat.RemoveFromHierarchy(); m_Placemats.Remove(placemat); }
void AddPlacemat(Placemat placemat) { m_Placemats.AddLast(placemat); Add(placemat); }