internal static void DoMinMaxSlider(Rect position, int id, ref float value, ref float size, float visualStart, float visualEnd, float startLimit, float endLimit, GUIStyle slider, GUIStyle thumb, bool horiz)
{
Event current = Event.current;
bool flag = size == 0f;
float min = Mathf.Min(visualStart, visualEnd);
float max = Mathf.Max(visualStart, visualEnd);
float dragStartLimit = Mathf.Min(startLimit, endLimit);
float dragEndLimit = Mathf.Max(startLimit, endLimit);
MinMaxSliderState state = s_MinMaxSliderState;
if ((GUIUtility.hotControl == id) && (state != null))
{
min = state.dragStartLimit;
dragStartLimit = state.dragStartLimit;
max = state.dragEndLimit;
dragEndLimit = state.dragEndLimit;
}
float num5 = 0f;
float num6 = Mathf.Clamp(value, min, max);
float num7 = Mathf.Clamp(value + size, min, max) - num6;
float num8 = (visualStart <= visualEnd) ? ((float) 1) : ((float) (-1));
if ((slider != null) && (thumb != null))
{
float num9;
float num10;
Rect rect;
Rect rect2;
Rect rect3;
float num13;
float num14;
if (horiz)
{
float num11 = (thumb.fixedWidth == 0f) ? ((float) thumb.padding.horizontal) : thumb.fixedWidth;
num9 = ((position.width - slider.padding.horizontal) - num11) / (max - min);
rect = new Rect((((num6 - min) * num9) + position.x) + slider.padding.left, position.y + slider.padding.top, (num7 * num9) + num11, position.height - slider.padding.vertical);
rect2 = new Rect(rect.x, rect.y, (float) thumb.padding.left, rect.height);
rect3 = new Rect(rect.xMax - thumb.padding.right, rect.y, (float) thumb.padding.right, rect.height);
num10 = current.mousePosition.x - position.x;
}
else
{
float num12 = (thumb.fixedHeight == 0f) ? ((float) thumb.padding.vertical) : thumb.fixedHeight;
num9 = ((position.height - slider.padding.vertical) - num12) / (max - min);
rect = new Rect(position.x + slider.padding.left, (((num6 - min) * num9) + position.y) + slider.padding.top, position.width - slider.padding.horizontal, (num7 * num9) + num12);
rect2 = new Rect(rect.x, rect.y, rect.width, (float) thumb.padding.top);
rect3 = new Rect(rect.x, rect.yMax - thumb.padding.bottom, rect.width, (float) thumb.padding.bottom);
num10 = current.mousePosition.y - position.y;
}
switch (current.GetTypeForControl(id))
{
case EventType.MouseDown:
if (position.Contains(current.mousePosition) && ((min - max) != 0f))
{
if (state == null)
{
state = s_MinMaxSliderState = new MinMaxSliderState();
}
state.dragStartLimit = startLimit;
state.dragEndLimit = endLimit;
if (rect.Contains(current.mousePosition))
{
state.dragStartPos = num10;
state.dragStartValue = value;
state.dragStartSize = size;
state.dragStartValuesPerPixel = num9;
if (rect2.Contains(current.mousePosition))
{
state.whereWeDrag = 1;
}
else if (rect3.Contains(current.mousePosition))
{
state.whereWeDrag = 2;
}
else
{
state.whereWeDrag = 0;
}
GUIUtility.hotControl = id;
current.Use();
}
else if (slider != GUIStyle.none)
{
if ((size != 0f) && flag)
{
if (horiz)
{
if (num10 > (rect.xMax - position.x))
{
value += (size * num8) * 0.9f;
}
else
{
value -= (size * num8) * 0.9f;
}
}
else if (num10 > (rect.yMax - position.y))
{
value += (size * num8) * 0.9f;
}
else
{
value -= (size * num8) * 0.9f;
}
state.whereWeDrag = 0;
GUI.changed = true;
s_NextScrollStepTime = DateTime.Now.AddMilliseconds((double) kFirstScrollWait);
num13 = !horiz ? current.mousePosition.y : current.mousePosition.x;
num14 = !horiz ? rect.y : rect.x;
state.whereWeDrag = (num13 <= num14) ? 3 : 4;
}
else
{
if (horiz)
{
value = (((num10 - (rect.width * 0.5f)) / num9) + min) - (size * 0.5f);
}
else
{
value = (((num10 - (rect.height * 0.5f)) / num9) + min) - (size * 0.5f);
}
state.dragStartPos = num10;
state.dragStartValue = value;
state.dragStartSize = size;
state.dragStartValuesPerPixel = num9;
state.whereWeDrag = 0;
GUI.changed = true;
}
GUIUtility.hotControl = id;
value = Mathf.Clamp(value, dragStartLimit, dragEndLimit - size);
current.Use();
}
break;
}
break;
case EventType.MouseUp:
if (GUIUtility.hotControl == id)
{
current.Use();
GUIUtility.hotControl = 0;
}
break;
case EventType.MouseDrag:
if (GUIUtility.hotControl == id)
{
float num15 = (num10 - state.dragStartPos) / state.dragStartValuesPerPixel;
switch (state.whereWeDrag)
{
case 0:
value = Mathf.Clamp(state.dragStartValue + num15, dragStartLimit, dragEndLimit - size);
break;
case 1:
value = state.dragStartValue + num15;
size = state.dragStartSize - num15;
if (value < dragStartLimit)
{
size -= dragStartLimit - value;
value = dragStartLimit;
}
if (size < num5)
{
value -= num5 - size;
size = num5;
}
break;
case 2:
size = state.dragStartSize + num15;
if ((value + size) > dragEndLimit)
{
size = dragEndLimit - value;
}
if (size < num5)
{
size = num5;
}
break;
}
GUI.changed = true;
current.Use();
return;
}
break;
case EventType.Repaint:
slider.Draw(position, GUIContent.none, id);
thumb.Draw(rect, GUIContent.none, id);
if (((GUIUtility.hotControl == id) && position.Contains(current.mousePosition)) && ((min - max) != 0f))
{
if (rect.Contains(current.mousePosition))
{
if ((state != null) && ((state.whereWeDrag == 3) || (state.whereWeDrag == 4)))
{
GUIUtility.hotControl = 0;
}
}
else if (DateTime.Now >= s_NextScrollStepTime)
{
num13 = !horiz ? current.mousePosition.y : current.mousePosition.x;
num14 = !horiz ? rect.y : rect.x;
int num17 = (num13 <= num14) ? 3 : 4;
if (num17 == state.whereWeDrag)
{
if ((size != 0f) && flag)
{
if (horiz)
{
if (num10 > (rect.xMax - position.x))
{
value += (size * num8) * 0.9f;
}
else
{
value -= (size * num8) * 0.9f;
}
}
else if (num10 > (rect.yMax - position.y))
{
value += (size * num8) * 0.9f;
}
else
{
value -= (size * num8) * 0.9f;
}
state.whereWeDrag = -1;
GUI.changed = true;
}
value = Mathf.Clamp(value, dragStartLimit, dragEndLimit - size);
s_NextScrollStepTime = DateTime.Now.AddMilliseconds((double) kScrollWait);
}
}
break;
}
break;
}
}
}