示例#1
0
 public void UpdateGeometryFromContent()
 {
     if (base.panel != null && this.m_Initialized && !this.m_IsUpdatingGeometryFromContent && !this.m_IsMovingElements)
     {
         GraphView firstAncestorOfType = base.GetFirstAncestorOfType <GraphView>();
         if (firstAncestorOfType != null)
         {
             this.m_IsUpdatingGeometryFromContent = true;
             VisualElement contentViewContainer = firstAncestorOfType.contentViewContainer;
             Rect          rect = Rect.zero;
             if (this.m_ContainedElements != null)
             {
                 for (int i = 0; i < this.m_ContainedElements.Count; i++)
                 {
                     GraphElement graphElement = this.m_ContainedElements[i];
                     if (graphElement.panel == base.panel)
                     {
                         Rect rect2 = new Rect(0f, 0f, graphElement.GetPosition().width, graphElement.GetPosition().height);
                         if (GroupNode.IsValidRect(rect2))
                         {
                             rect2 = graphElement.ChangeCoordinatesTo(contentViewContainer, rect2);
                             if (!GroupNode.IsValidRect(rect))
                             {
                                 rect = rect2;
                             }
                             else
                             {
                                 rect = RectUtils.Encompass(rect, rect2);
                             }
                         }
                     }
                 }
             }
             if (this.m_ContainedElements == null || this.m_ContainedElements.Count == 0)
             {
                 float x = this.m_ContentItem.style.borderLeftWidth.value + this.m_ContentItem.style.paddingLeft.value;
                 float y = this.m_HeaderItem.layout.height + this.m_ContentItem.style.borderTopWidth.value + this.m_ContentItem.style.paddingTop.value;
                 rect = this.ChangeCoordinatesTo(contentViewContainer, new Rect(x, y, 0f, 0f));
             }
             float num = 10f;
             if (this.m_HeaderItem != null)
             {
                 Vector2 size = this.m_TitleItem.DoMeasure(100f, VisualElement.MeasureMode.Undefined, 100f, VisualElement.MeasureMode.Undefined);
                 if (GroupNode.IsValidSize(size))
                 {
                     num = size.x + this.m_TitleItem.style.marginLeft.value + this.m_TitleItem.style.paddingLeft.value + this.m_TitleItem.style.paddingRight.value + this.m_TitleItem.style.marginRight.value;
                 }
             }
             float   val   = num + this.m_HeaderItem.style.paddingLeft.value + this.m_HeaderItem.style.paddingRight.value;
             Vector2 size2 = rect.size;
             size2.x += this.m_ContentItem.style.borderLeftWidth.value + this.m_ContentItem.style.paddingLeft.value + this.m_ContentItem.style.paddingRight.value + this.m_ContentItem.style.borderRightWidth.value;
             size2.y += this.m_ContentItem.style.borderTopWidth.value + this.m_ContentItem.style.paddingTop.value + this.m_ContentItem.style.paddingBottom.value + this.m_ContentItem.style.borderBottomWidth.value;
             Rect position = default(Rect);
             position.position = contentViewContainer.ChangeCoordinatesTo(base.parent, rect.position);
             position.width    = Math.Max(size2.x, val) + base.style.borderLeftWidth.value + base.style.borderRightWidth.value;
             position.height   = size2.y + this.m_HeaderItem.layout.height + base.style.borderTopWidth.value + base.style.borderBottomWidth.value;
             position.x       -= this.m_ContentItem.style.paddingLeft.value + base.style.borderLeftWidth.value;
             position.y       -= this.m_ContentItem.style.paddingTop.value + this.m_HeaderItem.layout.height + base.style.borderTopWidth.value;
             this.SetPosition(position);
             Vector2 vector = this.ChangeCoordinatesTo(contentViewContainer, new Vector2(0f, 0f));
             this.mPreviousPosInCanvasSpace       = vector;
             this.m_ContainedElementsRect         = contentViewContainer.ChangeCoordinatesTo(this, rect);
             this.m_IsUpdatingGeometryFromContent = false;
         }
     }
 }