コード例 #1
0
        internal void BringToFront(Placemat placemat)
        {
            m_Placemats.Remove(placemat);
            m_Placemats.AddLast(placemat);

            UpdateElementsOrder();
        }
コード例 #2
0
        internal void SendToBack(Placemat placemat)
        {
            m_Placemats.Remove(placemat);
            m_Placemats.AddFirst(placemat);

            UpdateElementsOrder();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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 });
            }
        }
コード例 #5
0
        // 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);
                        }
                    }
                }
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        // 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);
        }
コード例 #8
0
 void RemovePlacemat(Placemat placemat)
 {
     placemat.RemoveFromHierarchy();
     m_Placemats.Remove(placemat);
 }
コード例 #9
0
 void AddPlacemat(Placemat placemat)
 {
     m_Placemats.AddLast(placemat);
     Add(placemat);
 }