/// <summary> /// Insert an element into this element's contentContainer /// </summary> public void Insert(int index, VisualElement child) { if (child == null) { throw new ArgumentException("Cannot insert null child"); } if (index > childCount) { throw new ArgumentOutOfRangeException("Index out of range: " + index); } if (child == m_Owner) { throw new ArgumentException("Cannot insert element as its own child"); } if (m_Owner.elementPanel != null && m_Owner.elementPanel.duringLayoutPhase) { throw new InvalidOperationException(k_InvalidHierarchyChangeMsg); } child.RemoveFromHierarchy(); if (ReferenceEquals(m_Owner.m_Children, s_EmptyList)) { //TODO: Trigger a release on finalizer or something, this means we'll need to make the pool thread-safe as well m_Owner.m_Children = VisualElementListPool.Get(); } if (m_Owner.yogaNode.IsMeasureDefined) { m_Owner.RemoveMeasureFunction(); } PutChildAtIndex(child, index); int imguiContainerCount = child.imguiContainerDescendantCount + (child.isIMGUIContainer ? 1 : 0); if (imguiContainerCount > 0) { m_Owner.ChangeIMGUIContainerCount(imguiContainerCount); } child.hierarchy.SetParent(m_Owner); child.PropagateEnabledToChildren(m_Owner.enabledInHierarchy); child.InvokeHierarchyChanged(HierarchyChangeType.Add); child.IncrementVersion(VersionChangeType.Hierarchy); m_Owner.IncrementVersion(VersionChangeType.Hierarchy); }
public List <VisualElement> GetAffectedVisualElements() { List <VisualElement> elements = VisualElementListPool.Get(); for (int i = 0; i < shadow.childCount; ++i) { VisualElement element = shadow[i]; if (element.style.positionType == PositionType.Relative) { elements.Add(element); } } return(elements); }
public List <VisualElement> GetAffectedVisualElements() { List <VisualElement> elements = VisualElementListPool.Get(); for (int i = 0; i < hierarchy.childCount; ++i) { VisualElement element = hierarchy[i]; if (element.resolvedStyle.position == Position.Relative) { elements.Add(element); } } return(elements); }