254 lines
9.7 KiB
C#
254 lines
9.7 KiB
C#
using System;
|
|
|
|
namespace UnityEngine.Experimental.UIElements
|
|
{
|
|
// Token: 0x02000327 RID: 807
|
|
internal class IMScrollView : IMContainer
|
|
{
|
|
// Token: 0x060032C2 RID: 12994 RVA: 0x0004D524 File Offset: 0x0004B724
|
|
public IMScrollView()
|
|
{
|
|
this.m_HorizontalScrollbar = GUIStyle.none;
|
|
this.m_VerticalScrollbar = GUIStyle.none;
|
|
this.m_Background = GUIStyle.none;
|
|
this.m_HorizontalScroller = new IMScroller();
|
|
this.m_VerticalScroller = new IMScroller();
|
|
}
|
|
|
|
// Token: 0x17000B83 RID: 2947
|
|
// (get) Token: 0x060032C3 RID: 12995 RVA: 0x0004D564 File Offset: 0x0004B764
|
|
// (set) Token: 0x060032C4 RID: 12996 RVA: 0x0004D580 File Offset: 0x0004B780
|
|
public Vector2 scrollPosition
|
|
{
|
|
get
|
|
{
|
|
return this.m_ScrollPosition;
|
|
}
|
|
private set
|
|
{
|
|
this.m_ScrollPosition = value;
|
|
}
|
|
}
|
|
|
|
// Token: 0x17000B84 RID: 2948
|
|
// (get) Token: 0x060032C5 RID: 12997 RVA: 0x0004D58C File Offset: 0x0004B78C
|
|
// (set) Token: 0x060032C6 RID: 12998 RVA: 0x0004D5AC File Offset: 0x0004B7AC
|
|
public float scrollPositionHorizontal
|
|
{
|
|
get
|
|
{
|
|
return this.m_ScrollPosition.x;
|
|
}
|
|
set
|
|
{
|
|
this.m_ScrollPosition.x = value;
|
|
}
|
|
}
|
|
|
|
// Token: 0x17000B85 RID: 2949
|
|
// (get) Token: 0x060032C7 RID: 12999 RVA: 0x0004D5BC File Offset: 0x0004B7BC
|
|
// (set) Token: 0x060032C8 RID: 13000 RVA: 0x0004D5DC File Offset: 0x0004B7DC
|
|
public float scrollPositionVertical
|
|
{
|
|
get
|
|
{
|
|
return this.m_ScrollPosition.y;
|
|
}
|
|
set
|
|
{
|
|
this.m_ScrollPosition.y = value;
|
|
}
|
|
}
|
|
|
|
// Token: 0x060032C9 RID: 13001 RVA: 0x0004D5EC File Offset: 0x0004B7EC
|
|
public void SetProperties(Rect pos, Vector2 scrollPos, Rect viewRect, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background)
|
|
{
|
|
base.position = pos;
|
|
this.scrollPosition = scrollPos;
|
|
this.viewRect = viewRect;
|
|
this.m_HorizontalScrollbar = horizontalScrollbar;
|
|
this.m_VerticalScrollbar = verticalScrollbar;
|
|
this.m_Background = background;
|
|
this.m_NeedsVertical = alwaysShowVertical;
|
|
this.m_NeedsHorizontal = alwaysShowHorizontal;
|
|
this.CheckState();
|
|
GUIStyle guistyle = ((this.m_HorizontalScrollbar == GUIStyle.none) ? GUIStyle.none : GUI.skin.GetStyle(this.m_HorizontalScrollbar.name + "thumb"));
|
|
GUIStyle guistyle2 = ((this.m_HorizontalScrollbar == GUIStyle.none) ? GUIStyle.none : GUI.skin.GetStyle(this.m_HorizontalScrollbar.name + "leftbutton"));
|
|
GUIStyle guistyle3 = ((this.m_HorizontalScrollbar == GUIStyle.none) ? GUIStyle.none : GUI.skin.GetStyle(this.m_HorizontalScrollbar.name + "rightbutton"));
|
|
this.m_HorizontalScroller.SetProperties(new Rect(base.position.x, base.position.yMax - this.m_HorizontalScrollbar.fixedHeight, this.m_ClipRect.width, this.m_HorizontalScrollbar.fixedHeight), this.scrollPosition.x, Mathf.Min(this.m_ClipRect.width, this.viewRect.width), 0f, this.viewRect.width, this.m_HorizontalScrollbar, guistyle, guistyle2, guistyle3, true);
|
|
GUIStyle guistyle4 = ((this.m_VerticalScrollbar == GUIStyle.none) ? GUIStyle.none : GUI.skin.GetStyle(this.m_VerticalScrollbar.name + "thumb"));
|
|
GUIStyle guistyle5 = ((this.m_VerticalScrollbar == GUIStyle.none) ? GUIStyle.none : GUI.skin.GetStyle(this.m_VerticalScrollbar.name + "upbutton"));
|
|
GUIStyle guistyle6 = ((this.m_VerticalScrollbar == GUIStyle.none) ? GUIStyle.none : GUI.skin.GetStyle(this.m_VerticalScrollbar.name + "downbutton"));
|
|
this.m_VerticalScroller.SetProperties(new Rect(this.m_ClipRect.xMax + (float)this.m_VerticalScrollbar.margin.left, this.m_ClipRect.y, this.m_VerticalScrollbar.fixedWidth, this.m_ClipRect.height), this.scrollPosition.y, Mathf.Min(this.m_ClipRect.height, this.viewRect.height), 0f, this.viewRect.height, this.m_VerticalScrollbar, guistyle4, guistyle5, guistyle6, false);
|
|
}
|
|
|
|
// Token: 0x060032CA RID: 13002 RVA: 0x0004D8C4 File Offset: 0x0004BAC4
|
|
public override void OnReuse()
|
|
{
|
|
base.OnReuse();
|
|
this.m_HorizontalScroller.OnReuse();
|
|
this.m_VerticalScroller.OnReuse();
|
|
}
|
|
|
|
// Token: 0x060032CB RID: 13003 RVA: 0x0004D8E4 File Offset: 0x0004BAE4
|
|
public void HandleScrollWheel(Event evt)
|
|
{
|
|
if (this.m_State.position.Contains(evt.mousePosition))
|
|
{
|
|
this.m_State.scrollPosition.x = Mathf.Clamp(this.m_State.scrollPosition.x + evt.delta.x * 20f, 0f, this.m_State.viewRect.width - this.m_State.visibleRect.width);
|
|
this.m_State.scrollPosition.y = Mathf.Clamp(this.m_State.scrollPosition.y + evt.delta.y * 20f, 0f, this.m_State.viewRect.height - this.m_State.visibleRect.height);
|
|
this.m_State.apply = true;
|
|
evt.Use();
|
|
}
|
|
}
|
|
|
|
// Token: 0x060032CC RID: 13004 RVA: 0x0004D9E4 File Offset: 0x0004BBE4
|
|
public override bool OnGUI(Event evt)
|
|
{
|
|
bool flag = false;
|
|
switch (evt.GetTypeForControl(base.id))
|
|
{
|
|
case EventType.Layout:
|
|
case EventType.Used:
|
|
goto IL_1F0;
|
|
case EventType.DragUpdated:
|
|
flag = this.DoDragUpdated(new MouseEventArgs(evt.mousePosition, evt.clickCount, evt.modifiers));
|
|
goto IL_1F0;
|
|
}
|
|
if (evt.type == EventType.Repaint && this.m_Background != GUIStyle.none)
|
|
{
|
|
this.m_Background.Draw(base.position, base.position.Contains(evt.mousePosition), false, this.m_NeedsHorizontal && this.m_NeedsVertical, false);
|
|
}
|
|
if (this.m_NeedsHorizontal && this.m_HorizontalScrollbar != GUIStyle.none)
|
|
{
|
|
flag = this.m_HorizontalScroller.OnGUI(evt);
|
|
this.scrollPositionHorizontal = this.m_HorizontalScroller.value;
|
|
}
|
|
else if (this.m_HorizontalScrollbar != GUIStyle.none)
|
|
{
|
|
this.scrollPositionHorizontal = 0f;
|
|
}
|
|
else
|
|
{
|
|
this.scrollPositionHorizontal = Mathf.Clamp(this.scrollPositionHorizontal, 0f, Mathf.Max(this.viewRect.width - base.position.width, 0f));
|
|
}
|
|
if (this.m_NeedsVertical && this.m_VerticalScrollbar != GUIStyle.none)
|
|
{
|
|
flag = this.m_VerticalScroller.OnGUI(evt);
|
|
this.scrollPositionVertical = this.m_VerticalScroller.value;
|
|
}
|
|
else if (this.m_VerticalScrollbar != GUIStyle.none)
|
|
{
|
|
this.scrollPositionVertical = 0f;
|
|
}
|
|
else
|
|
{
|
|
this.scrollPositionVertical = Mathf.Clamp(this.scrollPositionVertical, 0f, Mathf.Max(this.viewRect.height - base.position.height, 0f));
|
|
}
|
|
IL_1F0:
|
|
if (flag)
|
|
{
|
|
evt.Use();
|
|
}
|
|
GUIClip.Internal_Push(this.m_ClipRect, new Vector2(Mathf.Round(-this.scrollPosition.x - this.viewRect.x), Mathf.Round(-this.scrollPosition.y - this.viewRect.y)), Vector2.zero, false);
|
|
return flag;
|
|
}
|
|
|
|
// Token: 0x060032CD RID: 13005 RVA: 0x0004DC54 File Offset: 0x0004BE54
|
|
public void ScrollTo(Rect pos)
|
|
{
|
|
this.m_State.ScrollTo(pos);
|
|
}
|
|
|
|
// Token: 0x060032CE RID: 13006 RVA: 0x0004DC64 File Offset: 0x0004BE64
|
|
public bool ScrollTowards(Rect pos, float maxDelta)
|
|
{
|
|
return this.m_State.ScrollTowards(pos, maxDelta);
|
|
}
|
|
|
|
// Token: 0x060032CF RID: 13007 RVA: 0x0004DC88 File Offset: 0x0004BE88
|
|
public override void GenerateControlID()
|
|
{
|
|
this.m_HorizontalScroller.GenerateControlID();
|
|
this.m_VerticalScroller.GenerateControlID();
|
|
base.id = GUIUtility.GetControlID("ScrollView".GetHashCode(), FocusType.Passive);
|
|
}
|
|
|
|
// Token: 0x060032D0 RID: 13008 RVA: 0x0004DCB8 File Offset: 0x0004BEB8
|
|
private void CheckState()
|
|
{
|
|
Debug.Assert(base.id != 0, "Invalid zero control ID");
|
|
this.m_State = (ScrollViewState)GUIUtility.GetStateObject(typeof(ScrollViewState), base.id);
|
|
if (this.m_State.apply)
|
|
{
|
|
this.scrollPosition = this.m_State.scrollPosition;
|
|
this.m_State.apply = false;
|
|
}
|
|
this.m_State.position = base.position;
|
|
this.m_State.scrollPosition = this.scrollPosition;
|
|
this.m_State.viewRect = this.viewRect;
|
|
this.m_State.visibleRect = this.viewRect;
|
|
this.m_State.visibleRect.width = base.position.width;
|
|
this.m_State.visibleRect.height = base.position.height;
|
|
this.m_ClipRect = new Rect(base.position);
|
|
if (this.m_NeedsHorizontal || this.viewRect.width > this.m_ClipRect.width)
|
|
{
|
|
this.m_State.visibleRect.height = base.position.height - this.m_HorizontalScrollbar.fixedHeight + (float)this.m_HorizontalScrollbar.margin.top;
|
|
this.m_ClipRect.height = this.m_ClipRect.height - (this.m_HorizontalScrollbar.fixedHeight + (float)this.m_HorizontalScrollbar.margin.top);
|
|
this.m_NeedsHorizontal = true;
|
|
}
|
|
if (this.m_NeedsVertical || this.viewRect.height > this.m_ClipRect.height)
|
|
{
|
|
this.m_State.visibleRect.width = base.position.width - this.m_VerticalScrollbar.fixedWidth + (float)this.m_VerticalScrollbar.margin.left;
|
|
this.m_ClipRect.width = this.m_ClipRect.width - (this.m_VerticalScrollbar.fixedWidth + (float)this.m_VerticalScrollbar.margin.left);
|
|
this.m_NeedsVertical = true;
|
|
if (!this.m_NeedsHorizontal && this.viewRect.width > this.m_ClipRect.width)
|
|
{
|
|
this.m_State.visibleRect.height = base.position.height - this.m_HorizontalScrollbar.fixedHeight + (float)this.m_HorizontalScrollbar.margin.top;
|
|
this.m_ClipRect.height = this.m_ClipRect.height - (this.m_HorizontalScrollbar.fixedHeight + (float)this.m_HorizontalScrollbar.margin.top);
|
|
this.m_NeedsHorizontal = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x060032D1 RID: 13009 RVA: 0x0004DF8C File Offset: 0x0004C18C
|
|
private bool DoDragUpdated(MouseEventArgs args)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Token: 0x04000A55 RID: 2645
|
|
private ScrollViewState m_State;
|
|
|
|
// Token: 0x04000A56 RID: 2646
|
|
private Vector2 m_ScrollPosition;
|
|
|
|
// Token: 0x04000A57 RID: 2647
|
|
private GUIStyle m_HorizontalScrollbar;
|
|
|
|
// Token: 0x04000A58 RID: 2648
|
|
private GUIStyle m_VerticalScrollbar;
|
|
|
|
// Token: 0x04000A59 RID: 2649
|
|
private GUIStyle m_Background;
|
|
|
|
// Token: 0x04000A5A RID: 2650
|
|
public Rect viewRect;
|
|
|
|
// Token: 0x04000A5B RID: 2651
|
|
private bool m_NeedsVertical;
|
|
|
|
// Token: 0x04000A5C RID: 2652
|
|
private bool m_NeedsHorizontal;
|
|
|
|
// Token: 0x04000A5D RID: 2653
|
|
private Rect m_ClipRect;
|
|
|
|
// Token: 0x04000A5E RID: 2654
|
|
private readonly IMScroller m_HorizontalScroller;
|
|
|
|
// Token: 0x04000A5F RID: 2655
|
|
private readonly IMScroller m_VerticalScroller;
|
|
}
|
|
}
|