279 lines
7.6 KiB
C#
279 lines
7.6 KiB
C#
using System;
|
|
|
|
namespace UnityEngine.Experimental.UIElements
|
|
{
|
|
// Token: 0x0200031E RID: 798
|
|
public class IMGUIContainer : VisualElement
|
|
{
|
|
// Token: 0x0600326D RID: 12909 RVA: 0x0004BF9C File Offset: 0x0004A19C
|
|
public IMGUIContainer(Action onGUIHandler)
|
|
{
|
|
this.m_OnGUIHandler = onGUIHandler;
|
|
this.contextType = ContextType.Editor;
|
|
}
|
|
|
|
// Token: 0x17000B72 RID: 2930
|
|
// (get) Token: 0x0600326E RID: 12910 RVA: 0x0004BFBC File Offset: 0x0004A1BC
|
|
// (set) Token: 0x0600326F RID: 12911 RVA: 0x0004BFD8 File Offset: 0x0004A1D8
|
|
public int executionContext { get; set; }
|
|
|
|
// Token: 0x17000B73 RID: 2931
|
|
// (get) Token: 0x06003270 RID: 12912 RVA: 0x0004BFE4 File Offset: 0x0004A1E4
|
|
// (set) Token: 0x06003271 RID: 12913 RVA: 0x0004C000 File Offset: 0x0004A200
|
|
internal Rect lastWorldClip { get; set; }
|
|
|
|
// Token: 0x17000B74 RID: 2932
|
|
// (get) Token: 0x06003272 RID: 12914 RVA: 0x0004C00C File Offset: 0x0004A20C
|
|
private GUILayoutUtility.LayoutCache cache
|
|
{
|
|
get
|
|
{
|
|
if (this.m_Cache == null)
|
|
{
|
|
this.m_Cache = new GUILayoutUtility.LayoutCache();
|
|
}
|
|
return this.m_Cache;
|
|
}
|
|
}
|
|
|
|
// Token: 0x17000B75 RID: 2933
|
|
// (get) Token: 0x06003273 RID: 12915 RVA: 0x0004C040 File Offset: 0x0004A240
|
|
// (set) Token: 0x06003274 RID: 12916 RVA: 0x0004C05C File Offset: 0x0004A25C
|
|
public ContextType contextType { get; set; }
|
|
|
|
// Token: 0x17000B76 RID: 2934
|
|
// (get) Token: 0x06003275 RID: 12917 RVA: 0x0004C068 File Offset: 0x0004A268
|
|
// (set) Token: 0x06003276 RID: 12918 RVA: 0x0004C084 File Offset: 0x0004A284
|
|
internal int GUIDepth { get; private set; }
|
|
|
|
// Token: 0x06003277 RID: 12919 RVA: 0x0004C090 File Offset: 0x0004A290
|
|
internal override void DoRepaint(IStylePainter painter)
|
|
{
|
|
base.DoRepaint(painter);
|
|
this.lastWorldClip = painter.currentWorldClip;
|
|
this.HandleEvent(painter.repaintEvent, this);
|
|
}
|
|
|
|
// Token: 0x06003278 RID: 12920 RVA: 0x0004C0B4 File Offset: 0x0004A2B4
|
|
internal override void ChangePanel(BaseVisualElementPanel p)
|
|
{
|
|
if (base.elementPanel != null)
|
|
{
|
|
base.elementPanel.IMGUIContainersCount--;
|
|
}
|
|
base.ChangePanel(p);
|
|
if (base.elementPanel != null)
|
|
{
|
|
base.elementPanel.IMGUIContainersCount++;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06003279 RID: 12921 RVA: 0x0004C10C File Offset: 0x0004A30C
|
|
private void SaveGlobals()
|
|
{
|
|
this.m_GUIGlobals.matrix = GUI.matrix;
|
|
this.m_GUIGlobals.color = GUI.color;
|
|
this.m_GUIGlobals.contentColor = GUI.contentColor;
|
|
this.m_GUIGlobals.backgroundColor = GUI.backgroundColor;
|
|
this.m_GUIGlobals.enabled = GUI.enabled;
|
|
this.m_GUIGlobals.changed = GUI.changed;
|
|
this.m_GUIGlobals.displayIndex = Event.current.displayIndex;
|
|
}
|
|
|
|
// Token: 0x0600327A RID: 12922 RVA: 0x0004C190 File Offset: 0x0004A390
|
|
private void RestoreGlobals()
|
|
{
|
|
GUI.matrix = this.m_GUIGlobals.matrix;
|
|
GUI.color = this.m_GUIGlobals.color;
|
|
GUI.contentColor = this.m_GUIGlobals.contentColor;
|
|
GUI.backgroundColor = this.m_GUIGlobals.backgroundColor;
|
|
GUI.enabled = this.m_GUIGlobals.enabled;
|
|
GUI.changed = this.m_GUIGlobals.changed;
|
|
Event.current.displayIndex = this.m_GUIGlobals.displayIndex;
|
|
}
|
|
|
|
// Token: 0x0600327B RID: 12923 RVA: 0x0004C214 File Offset: 0x0004A414
|
|
private bool DoOnGUI(Event evt)
|
|
{
|
|
bool flag;
|
|
if (this.m_OnGUIHandler == null || base.panel == null)
|
|
{
|
|
flag = false;
|
|
}
|
|
else
|
|
{
|
|
int num = GUIClip.Internal_GetCount();
|
|
this.SaveGlobals();
|
|
int num2 = ((this.executionContext == 0) ? base.elementPanel.instanceID : this.executionContext);
|
|
UIElementsUtility.BeginContainerGUI(this.cache, num2, evt, this);
|
|
this.GUIDepth = GUIUtility.Internal_GetGUIDepth();
|
|
EventType type = Event.current.type;
|
|
bool flag2 = false;
|
|
try
|
|
{
|
|
this.m_OnGUIHandler();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (type != EventType.Layout)
|
|
{
|
|
throw;
|
|
}
|
|
flag2 = GUIUtility.IsExitGUIException(ex);
|
|
if (!flag2)
|
|
{
|
|
Debug.LogException(ex);
|
|
}
|
|
}
|
|
GUIUtility.CheckForTabEvent(evt);
|
|
EventType type2 = Event.current.type;
|
|
UIElementsUtility.EndContainerGUI();
|
|
this.RestoreGlobals();
|
|
if (!flag2)
|
|
{
|
|
if (type2 != EventType.Ignore && type2 != EventType.Used)
|
|
{
|
|
int num3 = GUIClip.Internal_GetCount();
|
|
if (num3 > num)
|
|
{
|
|
Debug.LogError("GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced)");
|
|
}
|
|
else if (num3 < num)
|
|
{
|
|
Debug.LogError("GUI Error: You are popping more GUIClips than you are pushing. Make sure they are balanced)");
|
|
}
|
|
}
|
|
}
|
|
while (GUIClip.Internal_GetCount() > num)
|
|
{
|
|
GUIClip.Internal_Pop();
|
|
}
|
|
if (type2 == EventType.Used)
|
|
{
|
|
base.Dirty(ChangeType.Repaint);
|
|
flag = true;
|
|
}
|
|
else
|
|
{
|
|
flag = false;
|
|
}
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
// Token: 0x0600327C RID: 12924 RVA: 0x0004C38C File Offset: 0x0004A58C
|
|
public override void OnLostKeyboardFocus()
|
|
{
|
|
GUIUtility.keyboardControl = 0;
|
|
}
|
|
|
|
// Token: 0x0600327D RID: 12925 RVA: 0x0004C398 File Offset: 0x0004A598
|
|
public override EventPropagation HandleEvent(Event evt, VisualElement finalTarget)
|
|
{
|
|
EventPropagation eventPropagation;
|
|
if (this.m_OnGUIHandler == null || base.elementPanel == null || !base.elementPanel.IMGUIEventInterests.WantsEvent(evt.type))
|
|
{
|
|
eventPropagation = EventPropagation.Continue;
|
|
}
|
|
else
|
|
{
|
|
EventType type = evt.type;
|
|
evt.type = EventType.Layout;
|
|
bool flag = this.DoOnGUI(evt);
|
|
evt.type = type;
|
|
flag |= this.DoOnGUI(evt);
|
|
if (flag)
|
|
{
|
|
eventPropagation = EventPropagation.Stop;
|
|
}
|
|
else
|
|
{
|
|
if (evt.type == EventType.MouseUp && this.HasCapture())
|
|
{
|
|
GUIUtility.hotControl = 0;
|
|
}
|
|
if (base.elementPanel == null)
|
|
{
|
|
GUIUtility.ExitGUI();
|
|
}
|
|
eventPropagation = EventPropagation.Continue;
|
|
}
|
|
}
|
|
return eventPropagation;
|
|
}
|
|
|
|
// Token: 0x0600327E RID: 12926 RVA: 0x0004C450 File Offset: 0x0004A650
|
|
protected internal override Vector2 DoMeasure(float desiredWidth, VisualElement.MeasureMode widthMode, float desiredHeight, VisualElement.MeasureMode heightMode)
|
|
{
|
|
float num = float.NaN;
|
|
float num2 = float.NaN;
|
|
if (widthMode != VisualElement.MeasureMode.Exactly || heightMode != VisualElement.MeasureMode.Exactly)
|
|
{
|
|
this.DoOnGUI(new Event
|
|
{
|
|
type = EventType.Layout
|
|
});
|
|
num = this.m_Cache.topLevel.minWidth;
|
|
num2 = this.m_Cache.topLevel.minHeight;
|
|
}
|
|
if (widthMode != VisualElement.MeasureMode.Exactly)
|
|
{
|
|
if (widthMode == VisualElement.MeasureMode.AtMost)
|
|
{
|
|
num = Mathf.Min(num, desiredWidth);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
num = desiredWidth;
|
|
}
|
|
if (heightMode != VisualElement.MeasureMode.Exactly)
|
|
{
|
|
if (heightMode == VisualElement.MeasureMode.AtMost)
|
|
{
|
|
num2 = Mathf.Min(num2, desiredHeight);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
num2 = desiredHeight;
|
|
}
|
|
return new Vector2(num, num2);
|
|
}
|
|
|
|
// Token: 0x04000A32 RID: 2610
|
|
private readonly Action m_OnGUIHandler;
|
|
|
|
// Token: 0x04000A35 RID: 2613
|
|
private GUILayoutUtility.LayoutCache m_Cache = null;
|
|
|
|
// Token: 0x04000A38 RID: 2616
|
|
private IMGUIContainer.GUIGlobals m_GUIGlobals;
|
|
|
|
// Token: 0x0200031F RID: 799
|
|
private struct GUIGlobals
|
|
{
|
|
// Token: 0x04000A39 RID: 2617
|
|
public Matrix4x4 matrix;
|
|
|
|
// Token: 0x04000A3A RID: 2618
|
|
public Color color;
|
|
|
|
// Token: 0x04000A3B RID: 2619
|
|
public Color contentColor;
|
|
|
|
// Token: 0x04000A3C RID: 2620
|
|
public Color backgroundColor;
|
|
|
|
// Token: 0x04000A3D RID: 2621
|
|
public bool enabled;
|
|
|
|
// Token: 0x04000A3E RID: 2622
|
|
public bool changed;
|
|
|
|
// Token: 0x04000A3F RID: 2623
|
|
public int displayIndex;
|
|
}
|
|
}
|
|
}
|