public TimeArea.TimeRulerDragMode BrowseRuler(Rect position, int id, ref float time, float frameRate, bool pickAnywhere, GUIStyle thumbStyle)
{
Event current = Event.current;
Rect position1 = position;
if ((double)time != -1.0)
{
position1.x = Mathf.Round(this.TimeToPixel(time, position)) - (float)thumbStyle.overflow.left;
position1.width = thumbStyle.fixedWidth + (float)thumbStyle.overflow.horizontal;
}
switch (current.GetTypeForControl(id))
{
case EventType.MouseDown:
if (position1.Contains(current.mousePosition))
{
GUIUtility.hotControl = id;
TimeArea.s_PickOffset = current.mousePosition.x - this.TimeToPixel(time, position);
current.Use();
return(TimeArea.TimeRulerDragMode.Start);
}
if (pickAnywhere && position.Contains(current.mousePosition))
{
GUIUtility.hotControl = id;
float wholeFps = TimeArea.SnapTimeToWholeFPS(this.PixelToTime(current.mousePosition.x, position), frameRate);
TimeArea.s_OriginalTime = time;
if ((double)wholeFps != (double)time)
{
GUI.changed = true;
}
time = wholeFps;
TimeArea.s_PickOffset = 0.0f;
current.Use();
return(TimeArea.TimeRulerDragMode.Start);
}
break;
case EventType.MouseUp:
if (GUIUtility.hotControl == id)
{
GUIUtility.hotControl = 0;
current.Use();
return(TimeArea.TimeRulerDragMode.End);
}
break;
case EventType.MouseDrag:
if (GUIUtility.hotControl == id)
{
float wholeFps = TimeArea.SnapTimeToWholeFPS(this.PixelToTime(current.mousePosition.x - TimeArea.s_PickOffset, position), frameRate);
if ((double)wholeFps != (double)time)
{
GUI.changed = true;
}
time = wholeFps;
current.Use();
return(TimeArea.TimeRulerDragMode.Dragging);
}
break;
case EventType.KeyDown:
if (GUIUtility.hotControl == id && current.keyCode == KeyCode.Escape)
{
if ((double)time != (double)TimeArea.s_OriginalTime)
{
GUI.changed = true;
}
time = TimeArea.s_OriginalTime;
GUIUtility.hotControl = 0;
current.Use();
return(TimeArea.TimeRulerDragMode.Cancel);
}
break;
case EventType.Repaint:
if ((double)time != -1.0)
{
bool flag = position.Contains(current.mousePosition);
position1.x += (float)thumbStyle.overflow.left;
thumbStyle.Draw(position1, id == GUIUtility.hotControl, flag || id == GUIUtility.hotControl, false, false);
break;
}
break;
}
return(TimeArea.TimeRulerDragMode.None);
}