public void BeginGUI(VisualContainer container) { this.topLevelVisualContainer = container; this.m_CurrentContainer = this.topLevelVisualContainer; this.m_CurrentViewState = new VisualTreeBuilder.ViewState(0); this.m_ViewStates.Clear(); }
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 EndGUI() { if (this.topLevelVisualContainer == null) { Debug.Log("topLevelVisualContainer == null"); } else { if (this.m_CurrentContainer != this.topLevelVisualContainer) { if (this.verbose) { Debug.LogWarning("Non-symmetrical VisualContainer calls to GUI"); } while (this.m_CurrentContainer != this.topLevelVisualContainer) { this.EndView(); } } if (this.topLevelVisualContainer.childrenCount > this.m_CurrentViewState.childIndex) { this.RecycleDescendants(this.topLevelVisualContainer, this.m_CurrentViewState.childIndex); } this.topLevelVisualContainer = null; this.m_CurrentContainer = null; } }
public Panel(int instanceID, ContextType contextType, LoadResourceFunction loadResourceDelegate = null, IDataWatchService dataWatch = null, IDispatcher dispatcher = null) { this.instanceID = instanceID; this.contextType = contextType; LoadResourceFunction arg_3B_1 = loadResourceDelegate; if (loadResourceDelegate == null) { if (Panel.< > f__mg$cache0 == null) { Panel.< > f__mg$cache0 = new LoadResourceFunction(Resources.Load); } arg_3B_1 = Panel.< > f__mg$cache0; } this.loadResourceFunc = arg_3B_1; this.dataWatch = dataWatch; this.dispatcher = dispatcher; this.stylePainter = new StylePainter(); this.m_RootContainer = new VisualContainer(); this.m_RootContainer.name = VisualElementUtils.GetUniqueName("PanelContainer"); this.visualTree.ChangePanel(this); this.m_StyleContext = new StyleContext(this.m_RootContainer); this.defaultIMRoot = new IMContainer { name = "DefaultOnGUI", pickingMode = PickingMode.Ignore }; this.defaultIMRoot.StretchToParentSize(); this.visualTree.InsertChild(0, this.defaultIMRoot); this.allowPixelCaching = true; }
protected internal void PropagateChangesToParents() { ChangeType changeType = (ChangeType)0; if ((this.changesNeeded & ChangeType.Styles) > (ChangeType)0) { changeType |= ChangeType.StylesPath; changeType |= ChangeType.Repaint; } if ((this.changesNeeded & ChangeType.Transform) > (ChangeType)0) { changeType |= ChangeType.Repaint; } if ((this.changesNeeded & ChangeType.Layout) > (ChangeType)0) { changeType |= ChangeType.Repaint; } if ((this.changesNeeded & ChangeType.Repaint) > (ChangeType)0) { changeType |= ChangeType.Repaint; } for (VisualContainer parent = this.parent; parent != null; parent = parent.parent) { if ((parent.changesNeeded & changeType) == changeType) { break; } parent.changesNeeded |= changeType; } }
private EventPropagation SendEventToIMGUIContainers(VisualElement root, Event evt, VisualElement skipElement) { IMGUIContainer iMGUIContainer = root as IMGUIContainer; EventPropagation result; if (iMGUIContainer != null && iMGUIContainer != skipElement) { if (iMGUIContainer.HandleEvent(evt, iMGUIContainer) == EventPropagation.Stop) { result = EventPropagation.Stop; } else { result = EventPropagation.Continue; } } else { VisualContainer visualContainer = root as VisualContainer; if (visualContainer != null) { for (int i = 0; i < visualContainer.childrenCount; i++) { if (this.SendEventToIMGUIContainers(visualContainer.GetChildAt(i), evt, skipElement) == EventPropagation.Stop) { result = EventPropagation.Stop; return(result); } } } result = EventPropagation.Continue; } return(result); }
public void EndView() { if (this.m_ViewStates.Count < 1) { Debug.Assert(this.m_CurrentContainer == this.topLevelVisualContainer); if (this.verbose) { Debug.LogError("Unexpected call to EndView()"); } } else { if (this.m_CurrentContainer.childrenCount > this.m_CurrentViewState.childIndex) { this.RecycleDescendants(this.m_CurrentContainer, this.m_CurrentViewState.childIndex); } Debug.Assert(this.m_CurrentContainer.parent != null); if (this.m_CurrentContainer is IMScrollView) { VisualContainer parent = this.m_CurrentContainer.parent; IMScrollView iMScrollView = parent as IMScrollView; while (parent != null && iMScrollView == null) { parent = parent.parent; iMScrollView = (parent as IMScrollView); } this.currentScrollView = iMScrollView; } this.m_CurrentViewState = this.m_ViewStates.Pop(); this.m_CurrentContainer = this.m_CurrentContainer.parent; } }
public VisualTreeBuilder(Recycler r) { this.m_ElementPool = r; this.m_ViewStates = new Stack <VisualTreeBuilder.ViewState>(); this.m_CurrentContainer = null; this.m_CurrentViewState = new VisualTreeBuilder.ViewState(0); this.topLevelVisualContainer = null; this.verbose = false; this.currentScrollView = null; }
public void PropagateEnabled(VisualContainer c, bool enabled) { if (c != null) { foreach (VisualElement current in c) { current.enabled = enabled; this.PropagateEnabled(current as VisualContainer, enabled); } } }
static public int ClearChildren(IntPtr l) { try { UnityEngine.Experimental.UIElements.VisualContainer self = (UnityEngine.Experimental.UIElements.VisualContainer)checkSelf(l); self.ClearChildren(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_flexWrap(IntPtr l) { try { UnityEngine.Experimental.UIElements.VisualContainer self = (UnityEngine.Experimental.UIElements.VisualContainer)checkSelf(l); pushValue(l, true); pushEnum(l, (int)self.flexWrap); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int get_childrenCount(IntPtr l) { try { UnityEngine.Experimental.UIElements.VisualContainer self = (UnityEngine.Experimental.UIElements.VisualContainer)checkSelf(l); pushValue(l, true); pushValue(l, self.childrenCount); return(2); } catch (Exception e) { return(error(l, e)); } }
public void NextView <TType>(out TType view) where TType : IMContainer, new() { this.NextElement <TType>(out view); this.m_CurrentContainer = view; this.m_ViewStates.Push(this.m_CurrentViewState); this.m_CurrentViewState = new VisualTreeBuilder.ViewState(0); IMScrollView iMScrollView = this.m_CurrentContainer as IMScrollView; if (iMScrollView != null) { this.currentScrollView = iMScrollView; } }
static public int constructor(IntPtr l) { try { UnityEngine.Experimental.UIElements.VisualContainer o; o = new UnityEngine.Experimental.UIElements.VisualContainer(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int RemoveChildAt(IntPtr l) { try { UnityEngine.Experimental.UIElements.VisualContainer self = (UnityEngine.Experimental.UIElements.VisualContainer)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); self.RemoveChildAt(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_flexWrap(IntPtr l) { try { UnityEngine.Experimental.UIElements.VisualContainer self = (UnityEngine.Experimental.UIElements.VisualContainer)checkSelf(l); UnityEngine.Experimental.UIElements.StyleEnums.Wrap v; checkEnum(l, 2, out v); self.flexWrap = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_clipChildren(IntPtr l) { try { UnityEngine.Experimental.UIElements.VisualContainer self = (UnityEngine.Experimental.UIElements.VisualContainer)checkSelf(l); bool v; checkType(l, 2, out v); self.clipChildren = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int AddStyleSheetPath(IntPtr l) { try { UnityEngine.Experimental.UIElements.VisualContainer self = (UnityEngine.Experimental.UIElements.VisualContainer)checkSelf(l); System.String a1; checkType(l, 2, out a1); self.AddStyleSheetPath(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int ContainsChild(IntPtr l) { try { UnityEngine.Experimental.UIElements.VisualContainer self = (UnityEngine.Experimental.UIElements.VisualContainer)checkSelf(l); UnityEngine.Experimental.UIElements.VisualElement a1; checkType(l, 2, out a1); var ret = self.ContainsChild(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
private VisualElement Pick(VisualElement root, Vector2 point) { VisualElement result; if ((root.pseudoStates & PseudoStates.Invisible) == PseudoStates.Invisible) { result = null; } else { VisualContainer visualContainer = root as VisualContainer; Vector3 vector = root.transform.inverse.MultiplyPoint3x4(point); bool flag = root.ContainsPoint(vector); if (visualContainer != null) { if (!flag && visualContainer.clipChildren) { result = null; return(result); } vector -= new Vector3(visualContainer.position.position.x, visualContainer.position.position.y, 0f); for (int i = visualContainer.childrenCount - 1; i >= 0; i--) { VisualElement childAt = visualContainer.GetChildAt(i); VisualElement visualElement = this.Pick(childAt, vector); if (visualElement != null) { result = visualElement; return(result); } } } PickingMode pickingMode = root.pickingMode; if (pickingMode != PickingMode.Position) { if (pickingMode != PickingMode.Ignore) { } } else if (flag) { result = root; return(result); } result = null; } return(result); }
private void PropagateToChildren(ChangeType type) { if ((type & this.changesNeeded) != type) { this.changesNeeded |= type; type &= (ChangeType.Styles | ChangeType.Transform); if (type != (ChangeType)0) { VisualContainer visualContainer = this as VisualContainer; if (visualContainer != null) { foreach (VisualElement current in visualContainer) { current.PropagateToChildren(type); } } } } }
private void RecycleDescendants(VisualContainer parent, int startAtIndex) { while (parent.childrenCount > startAtIndex) { VisualElement childAt = parent.GetChildAt(startAtIndex); VisualContainer visualContainer = childAt as VisualContainer; if (visualContainer != null) { this.RecycleDescendants(visualContainer, 0); } IOnGUIHandler onGUIHandler = childAt as IOnGUIHandler; if (onGUIHandler != null) { this.m_ElementPool.Trash(onGUIHandler); parent.RemoveChild(childAt); } else { startAtIndex++; } } }
public void PaintSubTree(Event e, VisualElement root, Matrix4x4 offset, Rect currentGlobalClip) { if ((root.pseudoStates & PseudoStates.Invisible) != PseudoStates.Invisible) { VisualContainer visualContainer = root as VisualContainer; if (visualContainer != null) { if (visualContainer.clipChildren) { Rect rect = this.ComputeAAAlignedBound(root.position, offset * root.globalTransform); if (!rect.Overlaps(currentGlobalClip)) { return; } float num = Mathf.Max(rect.x, currentGlobalClip.x); float num2 = Mathf.Min(rect.x + rect.width, currentGlobalClip.x + currentGlobalClip.width); float num3 = Mathf.Max(rect.y, currentGlobalClip.y); float num4 = Mathf.Min(rect.y + rect.height, currentGlobalClip.y + currentGlobalClip.height); currentGlobalClip = new Rect(num, num3, num2 - num, num4 - num3); } } else if (!this.ComputeAAAlignedBound(root.globalBound, offset).Overlaps(currentGlobalClip)) { return; } if (root.usePixelCaching && this.allowPixelCaching && root.globalBound.size.magnitude > Mathf.Epsilon) { IStylePainter stylePainter = this.stylePainter; Rect globalBound = root.globalBound; int num5 = (int)globalBound.width; int num6 = (int)globalBound.height; int num7 = (int)(globalBound.width * GUIUtility.pixelsPerPoint); int num8 = (int)(globalBound.height * GUIUtility.pixelsPerPoint); RenderTexture renderTexture = root.renderData.pixelCache; if (renderTexture != null && renderTexture.width != num7 && renderTexture.height != num8) { UnityEngine.Object.DestroyImmediate(renderTexture); root.renderData.pixelCache = null; } float opacity = this.stylePainter.opacity; if (root.IsDirty(ChangeType.Repaint) || root.renderData.pixelCache == null) { if (renderTexture == null) { renderTexture = (root.renderData.pixelCache = new RenderTexture(num7, num8, 32, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear)); } RenderTexture active = RenderTexture.active; RenderTexture.active = renderTexture; GL.Clear(true, true, new Color(0f, 0f, 0f, 0f)); offset = Matrix4x4.Translate(new Vector3(-globalBound.x, -globalBound.y, 0f)); Rect rect2 = new Rect(0f, 0f, (float)num5, (float)num6); GUIClip.SetTransform(offset * root.globalTransform, rect2); stylePainter.currentWorldClip = currentGlobalClip; root.DoRepaint(stylePainter); root.ClearDirty(ChangeType.Repaint); if (visualContainer != null) { int childrenCount = visualContainer.childrenCount; for (int i = 0; i < childrenCount; i++) { VisualElement childAt = visualContainer.GetChildAt(i); this.PaintSubTree(e, childAt, offset, rect2); if (childrenCount != visualContainer.childrenCount) { throw new NotImplementedException("Visual tree is read-only during repaint"); } } } RenderTexture.active = active; } stylePainter.currentWorldClip = currentGlobalClip; GUIClip.SetTransform(root.globalTransform, currentGlobalClip); stylePainter.DrawTexture(root.position, root.renderData.pixelCache, Color.white, ScaleMode.ScaleAndCrop, 0f, 0f, 0, 0, 0, 0); } else { GUIClip.SetTransform(offset * root.globalTransform, currentGlobalClip); this.stylePainter.currentWorldClip = currentGlobalClip; this.stylePainter.mousePosition = root.globalTransform.inverse.MultiplyPoint3x4(e.mousePosition); this.stylePainter.opacity = root.styles.opacity.GetSpecifiedValueOrDefault(1f); root.DoRepaint(this.stylePainter); this.stylePainter.opacity = 1f; root.ClearDirty(ChangeType.Repaint); if (visualContainer != null) { int childrenCount2 = visualContainer.childrenCount; for (int j = 0; j < childrenCount2; j++) { VisualElement childAt2 = visualContainer.GetChildAt(j); this.PaintSubTree(e, childAt2, offset, currentGlobalClip); if (childrenCount2 != visualContainer.childrenCount) { throw new NotImplementedException("Visual tree is read-only during repaint"); } } } } } }
internal static void BeginBuilder(VisualContainer w) { }