Files
2026-06-04 11:42:34 +02:00

409 lines
11 KiB
C#

using System;
namespace UnityEngine
{
// Token: 0x0200027F RID: 639
internal struct SliderHandler
{
// Token: 0x06002BDF RID: 11231 RVA: 0x0003A4AC File Offset: 0x000386AC
public SliderHandler(Rect position, float currentValue, float size, float start, float end, GUIStyle slider, GUIStyle thumb, bool horiz, int id)
{
this.position = position;
this.currentValue = currentValue;
this.size = size;
this.start = start;
this.end = end;
this.slider = slider;
this.thumb = thumb;
this.horiz = horiz;
this.id = id;
}
// Token: 0x06002BE0 RID: 11232 RVA: 0x0003A500 File Offset: 0x00038700
public float Handle()
{
float num;
if (this.slider == null || this.thumb == null)
{
num = this.currentValue;
}
else
{
switch (this.CurrentEventType())
{
case EventType.MouseDown:
return this.OnMouseDown();
case EventType.MouseUp:
return this.OnMouseUp();
case EventType.MouseDrag:
return this.OnMouseDrag();
case EventType.Repaint:
return this.OnRepaint();
}
num = this.currentValue;
}
return num;
}
// Token: 0x06002BE1 RID: 11233 RVA: 0x0003A5A0 File Offset: 0x000387A0
private float OnMouseDown()
{
float num;
if (!this.position.Contains(this.CurrentEvent().mousePosition) || this.IsEmptySlider())
{
num = this.currentValue;
}
else
{
GUI.scrollTroughSide = 0;
GUIUtility.hotControl = this.id;
this.CurrentEvent().Use();
if (this.ThumbSelectionRect().Contains(this.CurrentEvent().mousePosition))
{
this.StartDraggingWithValue(this.ClampedCurrentValue());
num = this.currentValue;
}
else
{
GUI.changed = true;
if (this.SupportsPageMovements())
{
this.SliderState().isDragging = false;
GUI.nextScrollStepTime = SystemClock.now.AddMilliseconds(250.0);
GUI.scrollTroughSide = this.CurrentScrollTroughSide();
num = this.PageMovementValue();
}
else
{
float num2 = this.ValueForCurrentMousePosition();
this.StartDraggingWithValue(num2);
num = this.Clamp(num2);
}
}
}
return num;
}
// Token: 0x06002BE2 RID: 11234 RVA: 0x0003A6A8 File Offset: 0x000388A8
private float OnMouseDrag()
{
float num;
if (GUIUtility.hotControl != this.id)
{
num = this.currentValue;
}
else
{
SliderState sliderState = this.SliderState();
if (!sliderState.isDragging)
{
num = this.currentValue;
}
else
{
GUI.changed = true;
this.CurrentEvent().Use();
float num2 = this.MousePosition() - sliderState.dragStartPos;
float num3 = sliderState.dragStartValue + num2 / this.ValuesPerPixel();
num = this.Clamp(num3);
}
}
return num;
}
// Token: 0x06002BE3 RID: 11235 RVA: 0x0003A730 File Offset: 0x00038930
private float OnMouseUp()
{
if (GUIUtility.hotControl == this.id)
{
this.CurrentEvent().Use();
GUIUtility.hotControl = 0;
}
return this.currentValue;
}
// Token: 0x06002BE4 RID: 11236 RVA: 0x0003A770 File Offset: 0x00038970
private float OnRepaint()
{
this.slider.Draw(this.position, GUIContent.none, this.id);
if (!this.IsEmptySlider())
{
this.thumb.Draw(this.ThumbRect(), GUIContent.none, this.id);
}
float num;
if (GUIUtility.hotControl != this.id || !this.position.Contains(this.CurrentEvent().mousePosition) || this.IsEmptySlider())
{
num = this.currentValue;
}
else if (this.ThumbRect().Contains(this.CurrentEvent().mousePosition))
{
if (GUI.scrollTroughSide != 0)
{
GUIUtility.hotControl = 0;
}
num = this.currentValue;
}
else
{
GUI.InternalRepaintEditorWindow();
if (SystemClock.now < GUI.nextScrollStepTime)
{
num = this.currentValue;
}
else if (this.CurrentScrollTroughSide() != GUI.scrollTroughSide)
{
num = this.currentValue;
}
else
{
GUI.nextScrollStepTime = SystemClock.now.AddMilliseconds(30.0);
if (this.SupportsPageMovements())
{
this.SliderState().isDragging = false;
GUI.changed = true;
num = this.PageMovementValue();
}
else
{
num = this.ClampedCurrentValue();
}
}
}
return num;
}
// Token: 0x06002BE5 RID: 11237 RVA: 0x0003A8D8 File Offset: 0x00038AD8
private EventType CurrentEventType()
{
return this.CurrentEvent().GetTypeForControl(this.id);
}
// Token: 0x06002BE6 RID: 11238 RVA: 0x0003A900 File Offset: 0x00038B00
private int CurrentScrollTroughSide()
{
float num = ((!this.horiz) ? this.CurrentEvent().mousePosition.y : this.CurrentEvent().mousePosition.x);
float num2 = ((!this.horiz) ? this.ThumbRect().y : this.ThumbRect().x);
return (num <= num2) ? (-1) : 1;
}
// Token: 0x06002BE7 RID: 11239 RVA: 0x0003A98C File Offset: 0x00038B8C
private bool IsEmptySlider()
{
return this.start == this.end;
}
// Token: 0x06002BE8 RID: 11240 RVA: 0x0003A9B0 File Offset: 0x00038BB0
private bool SupportsPageMovements()
{
return this.size != 0f && GUI.usePageScrollbars;
}
// Token: 0x06002BE9 RID: 11241 RVA: 0x0003A9E0 File Offset: 0x00038BE0
private float PageMovementValue()
{
float num = this.currentValue;
int num2 = ((this.start <= this.end) ? 1 : (-1));
if (this.MousePosition() > this.PageUpMovementBound())
{
num += this.size * (float)num2 * 0.9f;
}
else
{
num -= this.size * (float)num2 * 0.9f;
}
return this.Clamp(num);
}
// Token: 0x06002BEA RID: 11242 RVA: 0x0003AA58 File Offset: 0x00038C58
private float PageUpMovementBound()
{
float num;
if (this.horiz)
{
num = this.ThumbRect().xMax - this.position.x;
}
else
{
num = this.ThumbRect().yMax - this.position.y;
}
return num;
}
// Token: 0x06002BEB RID: 11243 RVA: 0x0003AABC File Offset: 0x00038CBC
private Event CurrentEvent()
{
return Event.current;
}
// Token: 0x06002BEC RID: 11244 RVA: 0x0003AAD8 File Offset: 0x00038CD8
private float ValueForCurrentMousePosition()
{
float num;
if (this.horiz)
{
num = (this.MousePosition() - this.ThumbRect().width * 0.5f) / this.ValuesPerPixel() + this.start - this.size * 0.5f;
}
else
{
num = (this.MousePosition() - this.ThumbRect().height * 0.5f) / this.ValuesPerPixel() + this.start - this.size * 0.5f;
}
return num;
}
// Token: 0x06002BED RID: 11245 RVA: 0x0003AB6C File Offset: 0x00038D6C
private float Clamp(float value)
{
return Mathf.Clamp(value, this.MinValue(), this.MaxValue());
}
// Token: 0x06002BEE RID: 11246 RVA: 0x0003AB94 File Offset: 0x00038D94
private Rect ThumbSelectionRect()
{
return this.ThumbRect();
}
// Token: 0x06002BEF RID: 11247 RVA: 0x0003ABB4 File Offset: 0x00038DB4
private void StartDraggingWithValue(float dragStartValue)
{
SliderState sliderState = this.SliderState();
sliderState.dragStartPos = this.MousePosition();
sliderState.dragStartValue = dragStartValue;
sliderState.isDragging = true;
}
// Token: 0x06002BF0 RID: 11248 RVA: 0x0003ABE4 File Offset: 0x00038DE4
private SliderState SliderState()
{
return (SliderState)GUIUtility.GetStateObject(typeof(SliderState), this.id);
}
// Token: 0x06002BF1 RID: 11249 RVA: 0x0003AC14 File Offset: 0x00038E14
private Rect ThumbRect()
{
return (!this.horiz) ? this.VerticalThumbRect() : this.HorizontalThumbRect();
}
// Token: 0x06002BF2 RID: 11250 RVA: 0x0003AC48 File Offset: 0x00038E48
private Rect VerticalThumbRect()
{
float num = this.ValuesPerPixel();
Rect rect;
if (this.start < this.end)
{
rect = new Rect(this.position.x + (float)this.slider.padding.left, (this.ClampedCurrentValue() - this.start) * num + this.position.y + (float)this.slider.padding.top, this.position.width - (float)this.slider.padding.horizontal, this.size * num + this.ThumbSize());
}
else
{
rect = new Rect(this.position.x + (float)this.slider.padding.left, (this.ClampedCurrentValue() + this.size - this.start) * num + this.position.y + (float)this.slider.padding.top, this.position.width - (float)this.slider.padding.horizontal, this.size * -num + this.ThumbSize());
}
return rect;
}
// Token: 0x06002BF3 RID: 11251 RVA: 0x0003AD94 File Offset: 0x00038F94
private Rect HorizontalThumbRect()
{
float num = this.ValuesPerPixel();
Rect rect;
if (this.start < this.end)
{
rect = new Rect((this.ClampedCurrentValue() - this.start) * num + this.position.x + (float)this.slider.padding.left, this.position.y + (float)this.slider.padding.top, this.size * num + this.ThumbSize(), this.position.height - (float)this.slider.padding.vertical);
}
else
{
rect = new Rect((this.ClampedCurrentValue() + this.size - this.start) * num + this.position.x + (float)this.slider.padding.left, this.position.y, this.size * -num + this.ThumbSize(), this.position.height);
}
return rect;
}
// Token: 0x06002BF4 RID: 11252 RVA: 0x0003AEBC File Offset: 0x000390BC
private float ClampedCurrentValue()
{
return this.Clamp(this.currentValue);
}
// Token: 0x06002BF5 RID: 11253 RVA: 0x0003AEE0 File Offset: 0x000390E0
private float MousePosition()
{
float num;
if (this.horiz)
{
num = this.CurrentEvent().mousePosition.x - this.position.x;
}
else
{
num = this.CurrentEvent().mousePosition.y - this.position.y;
}
return num;
}
// Token: 0x06002BF6 RID: 11254 RVA: 0x0003AF4C File Offset: 0x0003914C
private float ValuesPerPixel()
{
float num;
if (this.horiz)
{
num = (this.position.width - (float)this.slider.padding.horizontal - this.ThumbSize()) / (this.end - this.start);
}
else
{
num = (this.position.height - (float)this.slider.padding.vertical - this.ThumbSize()) / (this.end - this.start);
}
return num;
}
// Token: 0x06002BF7 RID: 11255 RVA: 0x0003AFDC File Offset: 0x000391DC
private float ThumbSize()
{
float num;
if (this.horiz)
{
num = ((this.thumb.fixedWidth == 0f) ? ((float)this.thumb.padding.horizontal) : this.thumb.fixedWidth);
}
else
{
num = ((this.thumb.fixedHeight == 0f) ? ((float)this.thumb.padding.vertical) : this.thumb.fixedHeight);
}
return num;
}
// Token: 0x06002BF8 RID: 11256 RVA: 0x0003B070 File Offset: 0x00039270
private float MaxValue()
{
return Mathf.Max(this.start, this.end) - this.size;
}
// Token: 0x06002BF9 RID: 11257 RVA: 0x0003B0A0 File Offset: 0x000392A0
private float MinValue()
{
return Mathf.Min(this.start, this.end);
}
// Token: 0x040007ED RID: 2029
private readonly Rect position;
// Token: 0x040007EE RID: 2030
private readonly float currentValue;
// Token: 0x040007EF RID: 2031
private readonly float size;
// Token: 0x040007F0 RID: 2032
private readonly float start;
// Token: 0x040007F1 RID: 2033
private readonly float end;
// Token: 0x040007F2 RID: 2034
private readonly GUIStyle slider;
// Token: 0x040007F3 RID: 2035
private readonly GUIStyle thumb;
// Token: 0x040007F4 RID: 2036
private readonly bool horiz;
// Token: 0x040007F5 RID: 2037
private readonly int id;
}
}