scripts
This commit is contained in:
@@ -0,0 +1,216 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.Experimental.UIElements
|
||||
{
|
||||
// Token: 0x0200035F RID: 863
|
||||
internal class VisualTreeBuilder
|
||||
{
|
||||
// Token: 0x060034FF RID: 13567 RVA: 0x00056AE4 File Offset: 0x00054CE4
|
||||
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;
|
||||
}
|
||||
|
||||
// Token: 0x17000C34 RID: 3124
|
||||
// (get) Token: 0x06003500 RID: 13568 RVA: 0x00056B34 File Offset: 0x00054D34
|
||||
// (set) Token: 0x06003501 RID: 13569 RVA: 0x00056B50 File Offset: 0x00054D50
|
||||
public VisualContainer topLevelVisualContainer { get; private set; }
|
||||
|
||||
// Token: 0x17000C35 RID: 3125
|
||||
// (get) Token: 0x06003502 RID: 13570 RVA: 0x00056B5C File Offset: 0x00054D5C
|
||||
// (set) Token: 0x06003503 RID: 13571 RVA: 0x00056B78 File Offset: 0x00054D78
|
||||
public bool verbose { get; set; }
|
||||
|
||||
// Token: 0x17000C36 RID: 3126
|
||||
// (get) Token: 0x06003504 RID: 13572 RVA: 0x00056B84 File Offset: 0x00054D84
|
||||
// (set) Token: 0x06003505 RID: 13573 RVA: 0x00056BA0 File Offset: 0x00054DA0
|
||||
public IMScrollView currentScrollView { get; private set; }
|
||||
|
||||
// Token: 0x06003506 RID: 13574 RVA: 0x00056BAC File Offset: 0x00054DAC
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06003507 RID: 13575 RVA: 0x00056C0C File Offset: 0x00054E0C
|
||||
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 visualContainer = this.m_CurrentContainer.parent;
|
||||
IMScrollView imscrollView = visualContainer as IMScrollView;
|
||||
while (visualContainer != null && imscrollView == null)
|
||||
{
|
||||
visualContainer = visualContainer.parent;
|
||||
imscrollView = visualContainer as IMScrollView;
|
||||
}
|
||||
this.currentScrollView = imscrollView;
|
||||
}
|
||||
this.m_CurrentViewState = this.m_ViewStates.Pop();
|
||||
this.m_CurrentContainer = this.m_CurrentContainer.parent;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06003508 RID: 13576 RVA: 0x00056D14 File Offset: 0x00054F14
|
||||
public void BeginGUI(VisualContainer container)
|
||||
{
|
||||
this.topLevelVisualContainer = container;
|
||||
this.m_CurrentContainer = this.topLevelVisualContainer;
|
||||
this.m_CurrentViewState = new VisualTreeBuilder.ViewState(0);
|
||||
this.m_ViewStates.Clear();
|
||||
}
|
||||
|
||||
// Token: 0x06003509 RID: 13577 RVA: 0x00056D44 File Offset: 0x00054F44
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600350A RID: 13578 RVA: 0x00056DF8 File Offset: 0x00054FF8
|
||||
public void NextElement<TType>(out TType widget) where TType : VisualElement, IOnGUIHandler, new()
|
||||
{
|
||||
Type typeFromHandle = typeof(TType);
|
||||
widget = (TType)((object)null);
|
||||
if (this.m_CurrentViewState.childIndex >= this.m_CurrentContainer.childrenCount)
|
||||
{
|
||||
TType ttype;
|
||||
if ((ttype = this.m_ElementPool.TryReuse<TType>()) == null)
|
||||
{
|
||||
ttype = new TType();
|
||||
}
|
||||
widget = ttype;
|
||||
this.m_CurrentContainer.AddChild(widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualElement childAt = this.m_CurrentContainer.GetChildAt(this.m_CurrentViewState.childIndex);
|
||||
if (childAt.GetType() == typeFromHandle)
|
||||
{
|
||||
widget = childAt as TType;
|
||||
}
|
||||
else
|
||||
{
|
||||
IOnGUIHandler onGUIHandler = childAt as IOnGUIHandler;
|
||||
if (onGUIHandler != null && onGUIHandler.id == 0 && !(onGUIHandler is VisualContainer))
|
||||
{
|
||||
this.m_CurrentContainer.RemoveChildAt(this.m_CurrentViewState.childIndex);
|
||||
this.m_ElementPool.Trash(onGUIHandler);
|
||||
this.NextElement<TType>(out widget);
|
||||
return;
|
||||
}
|
||||
TType ttype2;
|
||||
if ((ttype2 = this.m_ElementPool.TryReuse<TType>()) == null)
|
||||
{
|
||||
ttype2 = new TType();
|
||||
}
|
||||
widget = ttype2;
|
||||
this.m_CurrentContainer.InsertChild(this.m_CurrentViewState.childIndex, widget);
|
||||
}
|
||||
}
|
||||
Debug.Assert(widget != null);
|
||||
this.m_CurrentViewState = new VisualTreeBuilder.ViewState(this.m_CurrentViewState.childIndex + 1);
|
||||
}
|
||||
|
||||
// Token: 0x0600350B RID: 13579 RVA: 0x00056F7C File Offset: 0x0005517C
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000B36 RID: 2870
|
||||
private Recycler m_ElementPool;
|
||||
|
||||
// Token: 0x04000B37 RID: 2871
|
||||
private VisualContainer m_CurrentContainer;
|
||||
|
||||
// Token: 0x04000B38 RID: 2872
|
||||
private VisualTreeBuilder.ViewState m_CurrentViewState;
|
||||
|
||||
// Token: 0x04000B39 RID: 2873
|
||||
private Stack<VisualTreeBuilder.ViewState> m_ViewStates;
|
||||
|
||||
// Token: 0x02000360 RID: 864
|
||||
private struct ViewState
|
||||
{
|
||||
// Token: 0x0600350C RID: 13580 RVA: 0x00056FEC File Offset: 0x000551EC
|
||||
public ViewState(int childIndex)
|
||||
{
|
||||
this.childIndex = childIndex;
|
||||
}
|
||||
|
||||
// Token: 0x04000B3D RID: 2877
|
||||
public readonly int childIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user