public override void Repaint(Event e) { Debug.Assert(GUIClip.Internal_GetCount() == 0, "UIElement is not compatible with IMGUI GUIClips, only GUIClip.ParentClipScope"); // if the surface DPI changes we need to invalidate styles if (!Mathf.Approximately(m_StyleContext.currentPixelsPerPoint, GUIUtility.pixelsPerPoint)) { m_RootContainer.Dirty(ChangeType.Styles); m_StyleContext.currentPixelsPerPoint = GUIUtility.pixelsPerPoint; } Profiler.BeginSample("Panel Repaint"); ValidatePersistentData(); ValidateLayout(); stylePainter.repaintEvent = e; // paint Rect clipRect = visualTree.clippingOptions != VisualElement.ClippingOptions.NoClipping ? visualTree.layout : GUIClip.topmostRect; whinedOnceAboutRotatedClipSpaceThisFrame = false; Profiler.BeginSample("Panel Root PaintSubTree"); PaintSubTree(e, visualTree, Matrix4x4.identity, VisualElement.ClippingOptions.NoClipping, clipRect); Profiler.EndSample(); Profiler.EndSample(); if (panelDebug != null) { if (panelDebug.EndRepaint()) { this.visualTree.Dirty(ChangeType.Repaint); } } }
private bool ValidateSubTree(VisualElement root) { if (root.renderData.lastLayout != new Rect(root.cssNode.LayoutX, root.cssNode.LayoutY, root.cssNode.LayoutWidth, root.cssNode.LayoutHeight)) { root.Dirty(ChangeType.Transform); root.renderData.lastLayout = new Rect(root.cssNode.LayoutX, root.cssNode.LayoutY, root.cssNode.LayoutWidth, root.cssNode.LayoutHeight); } bool hasNewLayout = root.cssNode.HasNewLayout; if (hasNewLayout) { for (int i = 0; i < root.shadow.childCount; i++) { this.ValidateSubTree(root.shadow[i]); } } using (PostLayoutEvent pooled = PostLayoutEvent.GetPooled(hasNewLayout)) { pooled.target = root; UIElementsUtility.eventDispatcher.DispatchEvent(pooled, this); } root.ClearDirty(ChangeType.Layout); root.cssNode.MarkLayoutSeen(); return(hasNewLayout); }
private bool ValidateSubTree(VisualElement root) { if (root.renderData.lastLayout != new Rect(root.cssNode.LayoutX, root.cssNode.LayoutY, root.cssNode.LayoutWidth, root.cssNode.LayoutHeight)) { root.Dirty(ChangeType.Transform); root.renderData.lastLayout = new Rect(root.cssNode.LayoutX, root.cssNode.LayoutY, root.cssNode.LayoutWidth, root.cssNode.LayoutHeight); } bool flag = root.cssNode.HasNewLayout; if (flag) { VisualContainer visualContainer = root as VisualContainer; if (visualContainer != null) { foreach (VisualElement current in visualContainer) { flag |= this.ValidateSubTree(current); } } } root.OnPostLayout(flag); root.ClearDirty(ChangeType.Layout); root.cssNode.MarkLayoutSeen(); return(flag); }
public void Insert(int index, VisualElement child) { if (child == null) { throw new ArgumentException("Cannot insert null child"); } if (index > childCount) { throw new IndexOutOfRangeException("Index out of range: " + index); } if (child == m_Owner) { throw new ArgumentException("Cannot insert element as its own child"); } child.RemoveFromHierarchy(); child.shadow.SetParent(m_Owner); if (m_Owner.m_Children == null) { //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.yogaNode.SetMeasureFunction(null); } PutChildAtIndex(child, index); child.SetEnabledFromHierarchy(m_Owner.enabledInHierarchy); // child styles are dependent on topology child.Dirty(ChangeType.Styles); child.Dirty(ChangeType.Transform); m_Owner.Dirty(ChangeType.Layout); // persistent data key may have changed or needs initialization if (!string.IsNullOrEmpty(child.persistenceKey)) { child.Dirty(ChangeType.PersistentData); } }
void ValidateSubTree(VisualElement root) { Rect cssRect = new Rect(root.cssNode.LayoutX, root.cssNode.LayoutY, root.cssNode.LayoutWidth, root.cssNode.LayoutHeight); Rect lastRect = root.renderData.lastLayout; bool rectChanged = lastRect != cssRect; // if the last layout rect is different than the current one we must dirty transform on children if (rectChanged) { if (lastRect.position != cssRect.position) { root.Dirty(ChangeType.Transform); } root.renderData.lastLayout = cssRect; } // ignore clean sub trees bool hasNewLayout = root.cssNode.HasNewLayout; if (hasNewLayout) { for (int i = 0; i < root.shadow.childCount; ++i) { ValidateSubTree(root.shadow[i]); } } if (rectChanged) { using (var evt = PostLayoutEvent.GetPooled(hasNewLayout, lastRect, cssRect)) { evt.target = root; UIElementsUtility.eventDispatcher.DispatchEvent(evt, this); } } // reset both flags at the end root.ClearDirty(ChangeType.Layout); if (hasNewLayout) { root.cssNode.MarkLayoutSeen(); } }