using System; namespace UnityEngine.Experimental.UIElements { // Token: 0x02000328 RID: 808 internal class IMSlider : IMElement { // Token: 0x060032D2 RID: 13010 RVA: 0x0004DFA4 File Offset: 0x0004C1A4 public IMSlider() { this.nextScrollStepTime = DateTime.Now; this.scrollTroughSide = 0; } // Token: 0x17000B86 RID: 2950 // (get) Token: 0x060032D3 RID: 13011 RVA: 0x0004DFD8 File Offset: 0x0004C1D8 // (set) Token: 0x060032D4 RID: 13012 RVA: 0x0004DFF4 File Offset: 0x0004C1F4 public float value { get; set; } // Token: 0x17000B87 RID: 2951 // (get) Token: 0x060032D5 RID: 13013 RVA: 0x0004E000 File Offset: 0x0004C200 // (set) Token: 0x060032D6 RID: 13014 RVA: 0x0004E01C File Offset: 0x0004C21C public DateTime nextScrollStepTime { get; set; } // Token: 0x17000B88 RID: 2952 // (get) Token: 0x060032D7 RID: 13015 RVA: 0x0004E028 File Offset: 0x0004C228 // (set) Token: 0x060032D8 RID: 13016 RVA: 0x0004E044 File Offset: 0x0004C244 private int scrollTroughSide { get; set; } // Token: 0x060032D9 RID: 13017 RVA: 0x0004E050 File Offset: 0x0004C250 public void SetProperties(Rect pos, float val, float pageSize, float start, float end, GUIStyle sliderStyle, GUIStyle thumbStyle, bool horiz) { base.position = pos; this.value = val; this.m_PageSize = pageSize; this.m_Start = start; this.m_End = end; this.m_SliderStyle = sliderStyle; this.m_ThumbStyle = thumbStyle; this.m_Horiz = horiz; } // Token: 0x060032DA RID: 13018 RVA: 0x0004E090 File Offset: 0x0004C290 public override bool OnGUI(Event evt) { return this.m_SliderStyle != null && this.m_ThumbStyle != null && base.OnGUI(evt); } // Token: 0x060032DB RID: 13019 RVA: 0x0004E0CC File Offset: 0x0004C2CC protected override int DoGenerateControlID() { return GUIUtility.GetControlID("IMSlider".GetHashCode(), base.focusType, base.position); } // Token: 0x060032DC RID: 13020 RVA: 0x0004E0FC File Offset: 0x0004C2FC protected override bool DoMouseDown(MouseEventArgs args) { bool flag; if (!base.position.Contains(args.mousePosition) || this.IsEmptySlider()) { flag = false; } else { this.scrollTroughSide = 0; GUIUtility.hotControl = base.id; if (this.ThumbSelectionRect().Contains(args.mousePosition)) { this.StartDraggingWithValue(this.Clampedvalue(), args.mousePosition); flag = true; } else { GUI.changed = true; if (this.SupportsPageMovements()) { this.SliderState().isDragging = false; this.nextScrollStepTime = SystemClock.now.AddMilliseconds(250.0); this.scrollTroughSide = this.CurrentScrollTroughSide(args.mousePosition); this.value = this.PageMovementValue(args.mousePosition); flag = true; } else { float num = this.ValueForCurrentMousePosition(args.mousePosition); this.StartDraggingWithValue(num, args.mousePosition); this.value = this.Clamp(num); flag = true; } } } return flag; } // Token: 0x060032DD RID: 13021 RVA: 0x0004E218 File Offset: 0x0004C418 protected override bool DoMouseDrag(MouseEventArgs args) { bool flag; if (GUIUtility.hotControl != base.id) { flag = false; } else { SliderState sliderState = this.SliderState(); if (!sliderState.isDragging) { flag = false; } else { GUI.changed = true; float num = this.MousePosition(args.mousePosition) - sliderState.dragStartPos; float num2 = sliderState.dragStartValue + num / this.ValuesPerPixel(); this.value = this.Clamp(num2); flag = true; } } return flag; } // Token: 0x060032DE RID: 13022 RVA: 0x0004E298 File Offset: 0x0004C498 protected override bool DoMouseUp(MouseEventArgs args) { bool flag; if (GUIUtility.hotControl == base.id) { GUIUtility.hotControl = 0; flag = true; } else { flag = false; } return flag; } // Token: 0x060032DF RID: 13023 RVA: 0x0004E2CC File Offset: 0x0004C4CC internal override void DoRepaint(IStylePainter args) { this.m_SliderStyle.Draw(base.position, GUIContent.none, base.id); if (!this.IsEmptySlider()) { this.m_ThumbStyle.Draw(this.ThumbRect(), GUIContent.none, base.id); } if (GUIUtility.hotControl == base.id && base.position.Contains(args.mousePosition) && !this.IsEmptySlider()) { if (this.ThumbRect().Contains(args.mousePosition)) { if (this.scrollTroughSide != 0) { GUIUtility.hotControl = 0; } } else { GUI.InternalRepaintEditorWindow(); if (!(SystemClock.now < this.nextScrollStepTime)) { if (this.CurrentScrollTroughSide(args.mousePosition) == this.scrollTroughSide) { this.nextScrollStepTime = SystemClock.now.AddMilliseconds(30.0); if (this.SupportsPageMovements()) { this.SliderState().isDragging = false; GUI.changed = true; this.value = this.PageMovementValue(args.mousePosition); } else { this.value = this.Clampedvalue(); } } } } } } // Token: 0x060032E0 RID: 13024 RVA: 0x0004E420 File Offset: 0x0004C620 private int CurrentScrollTroughSide(Vector2 mousePosition) { float num = ((!this.m_Horiz) ? mousePosition.y : mousePosition.x); float num2 = ((!this.m_Horiz) ? this.ThumbRect().y : this.ThumbRect().x); return (num <= num2) ? (-1) : 1; } // Token: 0x060032E1 RID: 13025 RVA: 0x0004E494 File Offset: 0x0004C694 private bool IsEmptySlider() { return this.m_Start == this.m_End; } // Token: 0x060032E2 RID: 13026 RVA: 0x0004E4B8 File Offset: 0x0004C6B8 private bool SupportsPageMovements() { return this.m_PageSize != 0f && GUI.usePageScrollbars; } // Token: 0x060032E3 RID: 13027 RVA: 0x0004E4E8 File Offset: 0x0004C6E8 private float PageMovementValue(Vector2 currentMousePos) { float num = this.value; int num2 = ((this.m_Start <= this.m_End) ? 1 : (-1)); if (this.MousePosition(currentMousePos) > this.PageUpMovementBound()) { num += this.m_PageSize * (float)num2 * 0.9f; } else { num -= this.m_PageSize * (float)num2 * 0.9f; } return this.Clamp(num); } // Token: 0x060032E4 RID: 13028 RVA: 0x0004E560 File Offset: 0x0004C760 private float PageUpMovementBound() { float num; if (this.m_Horiz) { num = this.ThumbRect().xMax - base.position.x; } else { num = this.ThumbRect().yMax - base.position.y; } return num; } // Token: 0x060032E5 RID: 13029 RVA: 0x0004E5C4 File Offset: 0x0004C7C4 private float ValueForCurrentMousePosition(Vector2 currentMousePos) { float num; if (this.m_Horiz) { num = (this.MousePosition(currentMousePos) - this.ThumbRect().width * 0.5f) / this.ValuesPerPixel() + this.m_Start - this.m_PageSize * 0.5f; } else { num = (this.MousePosition(currentMousePos) - this.ThumbRect().height * 0.5f) / this.ValuesPerPixel() + this.m_Start - this.m_PageSize * 0.5f; } return num; } // Token: 0x060032E6 RID: 13030 RVA: 0x0004E658 File Offset: 0x0004C858 private float Clamp(float val) { return Mathf.Clamp(val, this.MinValue(), this.MaxValue()); } // Token: 0x060032E7 RID: 13031 RVA: 0x0004E680 File Offset: 0x0004C880 private Rect ThumbSelectionRect() { return this.ThumbRect(); } // Token: 0x060032E8 RID: 13032 RVA: 0x0004E6A0 File Offset: 0x0004C8A0 private void StartDraggingWithValue(float dragStartValue, Vector2 currentMousePos) { SliderState sliderState = this.SliderState(); sliderState.dragStartPos = this.MousePosition(currentMousePos); sliderState.dragStartValue = dragStartValue; sliderState.isDragging = true; } // Token: 0x060032E9 RID: 13033 RVA: 0x0004E6D0 File Offset: 0x0004C8D0 private SliderState SliderState() { return (SliderState)GUIUtility.GetStateObject(typeof(SliderState), base.id); } // Token: 0x060032EA RID: 13034 RVA: 0x0004E700 File Offset: 0x0004C900 private Rect ThumbRect() { return (!this.m_Horiz) ? this.VerticalThumbRect() : this.HorizontalThumbRect(); } // Token: 0x060032EB RID: 13035 RVA: 0x0004E734 File Offset: 0x0004C934 private Rect VerticalThumbRect() { float num = this.ValuesPerPixel(); Rect rect; if (this.m_Start < this.m_End) { rect = new Rect(base.position.x + (float)this.m_SliderStyle.padding.left, (this.Clampedvalue() - this.m_Start) * num + base.position.y + (float)this.m_SliderStyle.padding.top, base.position.width - (float)this.m_SliderStyle.padding.horizontal, this.m_PageSize * num + this.ThumbSize()); } else { rect = new Rect(base.position.x + (float)this.m_SliderStyle.padding.left, (this.Clampedvalue() + this.m_PageSize - this.m_Start) * num + base.position.y + (float)this.m_SliderStyle.padding.top, base.position.width - (float)this.m_SliderStyle.padding.horizontal, this.m_PageSize * -num + this.ThumbSize()); } return rect; } // Token: 0x060032EC RID: 13036 RVA: 0x0004E880 File Offset: 0x0004CA80 private Rect HorizontalThumbRect() { float num = this.ValuesPerPixel(); Rect rect; if (this.m_Start < this.m_End) { rect = new Rect((this.Clampedvalue() - this.m_Start) * num + base.position.x + (float)this.m_SliderStyle.padding.left, base.position.y + (float)this.m_SliderStyle.padding.top, this.m_PageSize * num + this.ThumbSize(), base.position.height - (float)this.m_SliderStyle.padding.vertical); } else { rect = new Rect((this.Clampedvalue() + this.m_PageSize - this.m_Start) * num + base.position.x + (float)this.m_SliderStyle.padding.left, base.position.y, this.m_PageSize * -num + this.ThumbSize(), base.position.height); } return rect; } // Token: 0x060032ED RID: 13037 RVA: 0x0004E9A8 File Offset: 0x0004CBA8 private float Clampedvalue() { return this.Clamp(this.value); } // Token: 0x060032EE RID: 13038 RVA: 0x0004E9CC File Offset: 0x0004CBCC private float MousePosition(Vector2 currentMousePos) { float num; if (this.m_Horiz) { num = currentMousePos.x - base.position.x; } else { num = currentMousePos.y - base.position.y; } return num; } // Token: 0x060032EF RID: 13039 RVA: 0x0004EA20 File Offset: 0x0004CC20 private float ValuesPerPixel() { float num; if (this.m_Horiz) { num = (base.position.width - (float)this.m_SliderStyle.padding.horizontal - this.ThumbSize()) / (this.m_End - this.m_Start); } else { num = (base.position.height - (float)this.m_SliderStyle.padding.vertical - this.ThumbSize()) / (this.m_End - this.m_Start); } return num; } // Token: 0x060032F0 RID: 13040 RVA: 0x0004EAB0 File Offset: 0x0004CCB0 private float ThumbSize() { float num; if (this.m_Horiz) { num = ((this.m_ThumbStyle.fixedWidth == 0f) ? ((float)this.m_ThumbStyle.padding.horizontal) : this.m_ThumbStyle.fixedWidth); } else { num = ((this.m_ThumbStyle.fixedHeight == 0f) ? ((float)this.m_ThumbStyle.padding.vertical) : this.m_ThumbStyle.fixedHeight); } return num; } // Token: 0x060032F1 RID: 13041 RVA: 0x0004EB44 File Offset: 0x0004CD44 private float MaxValue() { return Mathf.Max(this.m_Start, this.m_End) - this.m_PageSize; } // Token: 0x060032F2 RID: 13042 RVA: 0x0004EB74 File Offset: 0x0004CD74 private float MinValue() { return Mathf.Min(this.m_Start, this.m_End); } // Token: 0x04000A61 RID: 2657 private float m_PageSize; // Token: 0x04000A62 RID: 2658 private float m_Start; // Token: 0x04000A63 RID: 2659 private float m_End; // Token: 0x04000A64 RID: 2660 private GUIStyle m_SliderStyle = GUIStyle.none; // Token: 0x04000A65 RID: 2661 private GUIStyle m_ThumbStyle = GUIStyle.none; // Token: 0x04000A66 RID: 2662 private bool m_Horiz; } }