private float OnMouseDrag() { float result; if (GUIUtility.hotControl != this.id) { result = this.currentValue; } else { var ext = Internal_SliderState.FromPointer(GetSliderState().Pointer); if (!ext.isDragging) { result = this.currentValue; } else { GUI.changed = true; this.CurrentEvent().Use(); float num = this.MousePosition() - ext.dragStartPos; float value = ext.dragStartValue + num / this.ValuesPerPixel(); result = this.Clamp(value); } } return(result); }
private void StartDraggingWithValue(float dragStartValue) { var ext = Internal_SliderState.FromPointer(GetSliderState().Pointer); ext.dragStartPos = this.MousePosition(); ext.dragStartValue = dragStartValue; ext.isDragging = true; }
private float OnRepaint() { this.slider.Draw(this.position, GUIContent.none, this.id); if (!this.IsEmptySlider() && this.currentValue >= this.MinValue() && this.currentValue <= this.MaxValue()) { this.thumb.Draw(this.ThumbRect(), GUIContent.none, this.id); } float result; if (GUIUtility.hotControl != this.id || !this.position.Contains(this.CurrentEvent().mousePosition) || this.IsEmptySlider()) { result = this.currentValue; } else if (this.ThumbRect().Contains(this.CurrentEvent().mousePosition)) { if (ScrollTroughSide != 0) { GUIUtility.hotControl = 0; } result = this.currentValue; } else { GUI.InternalRepaintEditorWindow(); if (DateTime.Now < Internal.nextScrollStepTime) { result = this.currentValue; } else if (this.CurrentScrollTroughSide() != ScrollTroughSide) { result = this.currentValue; } else { Internal.nextScrollStepTime = DateTime.Now.AddMilliseconds(30.0); if (this.SupportsPageMovements()) { Internal_SliderState.FromPointer(GetSliderState().Pointer).isDragging = false; GUI.changed = true; result = this.PageMovementValue(); } else { result = this.ClampedCurrentValue(); } } } return(result); }
private float OnMouseDown() { float result; if (!this.position.Contains(this.CurrentEvent().mousePosition) || this.IsEmptySlider()) { result = this.currentValue; } else { ScrollTroughSide = 0; GUIUtility.hotControl = this.id; this.CurrentEvent().Use(); if (this.ThumbSelectionRect().Contains(this.CurrentEvent().mousePosition)) { this.StartDraggingWithValue(this.ClampedCurrentValue()); result = this.currentValue; } else { GUI.changed = true; if (this.SupportsPageMovements()) { var ext = Internal_SliderState.FromPointer(GetSliderState().Pointer); ext.isDragging = false; Internal.nextScrollStepTime = DateTime.Now.AddMilliseconds(250.0); ScrollTroughSide = this.CurrentScrollTroughSide(); result = this.PageMovementValue(); } else { float num = this.ValueForCurrentMousePosition(); this.StartDraggingWithValue(num); result = this.Clamp(num); } } } return(result); }