public bool DoTimeline(Rect timeRect)
{
bool flag = false;
this.Init();
this.m_Rect = timeRect;
float a = this.m_TimeArea.PixelToTime(timeRect.xMin, timeRect);
float num2 = this.m_TimeArea.PixelToTime(timeRect.xMax, timeRect);
if (!Mathf.Approximately(a, this.StartTime))
{
this.StartTime = a;
GUI.changed = true;
}
if (!Mathf.Approximately(num2, this.StopTime))
{
this.StopTime = num2;
GUI.changed = true;
}
this.Time = Mathf.Max(this.Time, 0f);
if (Event.current.type == EventType.Repaint)
{
this.m_TimeArea.rect = timeRect;
}
this.m_TimeArea.BeginViewGUI();
this.m_TimeArea.EndViewGUI();
GUI.BeginGroup(timeRect);
Event current = Event.current;
Rect rect = new Rect(0f, 0f, timeRect.width, timeRect.height);
Rect position = new Rect(0f, 0f, timeRect.width, 18f);
Rect rect3 = new Rect(0f, 18f, timeRect.width, 132f);
float x = this.m_TimeArea.TimeToPixel(this.SrcStartTime, rect);
float pixelX = this.m_TimeArea.TimeToPixel(this.SrcStopTime, rect);
float num5 = this.m_TimeArea.TimeToPixel(this.DstStartTime, rect) + this.m_DstDragOffset;
float num6 = this.m_TimeArea.TimeToPixel(this.DstStopTime, rect) + this.m_DstDragOffset;
float num7 = this.m_TimeArea.TimeToPixel(this.TransitionStartTime, rect) + this.m_LeftThumbOffset;
float num8 = this.m_TimeArea.TimeToPixel(this.TransitionStopTime, rect) + this.m_RightThumbOffset;
float num9 = this.m_TimeArea.TimeToPixel(this.Time, rect);
Rect rect4 = new Rect(x, 85f, pixelX - x, 32f);
Rect rect5 = new Rect(num5, 117f, num6 - num5, 32f);
Rect rect6 = new Rect(num7, 0f, num8 - num7, 18f);
Rect rect7 = new Rect(num7, 18f, num8 - num7, rect.height - 18f);
Rect rect8 = new Rect(num7 - 9f, 5f, 9f, 15f);
Rect rect9 = new Rect(num8, 5f, 9f, 15f);
Rect rect10 = new Rect(num9 - 7f, 4f, 15f, 15f);
if (current.type == EventType.KeyDown)
{
if ((GUIUtility.keyboardControl == this.id) && (this.m_DragState == DragStates.Destination))
{
this.m_DstDragOffset = 0f;
}
if (this.m_DragState == DragStates.LeftSelection)
{
this.m_LeftThumbOffset = 0f;
}
if (this.m_DragState == DragStates.RightSelection)
{
this.m_RightThumbOffset = 0f;
}
if (this.m_DragState == DragStates.FullSelection)
{
this.m_LeftThumbOffset = 0f;
this.m_RightThumbOffset = 0f;
}
}
if ((current.type == EventType.MouseDown) && rect.Contains(current.mousePosition))
{
GUIUtility.hotControl = this.id;
GUIUtility.keyboardControl = this.id;
if (rect10.Contains(current.mousePosition))
{
this.m_DragState = DragStates.Playhead;
}
else if (rect4.Contains(current.mousePosition))
{
this.m_DragState = DragStates.Source;
}
else if (rect5.Contains(current.mousePosition))
{
this.m_DragState = DragStates.Destination;
}
else if (rect8.Contains(current.mousePosition))
{
this.m_DragState = DragStates.LeftSelection;
}
else if (rect9.Contains(current.mousePosition))
{
this.m_DragState = DragStates.RightSelection;
}
else if (rect6.Contains(current.mousePosition))
{
this.m_DragState = DragStates.FullSelection;
}
else if (position.Contains(current.mousePosition))
{
this.m_DragState = DragStates.TimeArea;
}
else if (rect3.Contains(current.mousePosition))
{
this.m_DragState = DragStates.TimeArea;
}
else
{
this.m_DragState = DragStates.None;
}
current.Use();
}
if ((current.type == EventType.MouseDrag) && (GUIUtility.hotControl == this.id))
{
switch (this.m_DragState)
{
case DragStates.LeftSelection:
if (((current.delta.x > 0f) && (current.mousePosition.x > x)) || ((current.delta.x < 0f) && (current.mousePosition.x < num8)))
{
this.m_LeftThumbOffset += current.delta.x;
}
this.EnforceConstraints();
break;
case DragStates.RightSelection:
if (((current.delta.x > 0f) && (current.mousePosition.x > num7)) || (current.delta.x < 0f))
{
this.m_RightThumbOffset += current.delta.x;
}
this.EnforceConstraints();
break;
case DragStates.FullSelection:
this.m_RightThumbOffset += current.delta.x;
this.m_LeftThumbOffset += current.delta.x;
this.EnforceConstraints();
break;
case DragStates.Destination:
this.m_DstDragOffset += current.delta.x;
this.EnforceConstraints();
break;
case DragStates.Source:
this.m_TimeArea.m_Translation.x += current.delta.x;
break;
case DragStates.Playhead:
if (((current.delta.x > 0f) && (current.mousePosition.x > x)) || ((current.delta.x < 0f) && (current.mousePosition.x <= this.m_TimeArea.TimeToPixel(this.SampleStopTime, rect))))
{
this.Time = this.m_TimeArea.PixelToTime(num9 + current.delta.x, rect);
}
break;
case DragStates.TimeArea:
this.m_TimeArea.m_Translation.x += current.delta.x;
break;
}
current.Use();
GUI.changed = true;
}
if ((current.type == EventType.MouseUp) && (GUIUtility.hotControl == this.id))
{
this.SrcStartTime = this.m_TimeArea.PixelToTime(x, rect);
this.SrcStopTime = this.m_TimeArea.PixelToTime(pixelX, rect);
this.DstStartTime = this.m_TimeArea.PixelToTime(num5, rect);
this.DstStopTime = this.m_TimeArea.PixelToTime(num6, rect);
this.TransitionStartTime = this.m_TimeArea.PixelToTime(num7, rect);
this.TransitionStopTime = this.m_TimeArea.PixelToTime(num8, rect);
GUI.changed = true;
this.m_DragState = DragStates.None;
flag = this.WasDraggingData();
this.m_LeftThumbOffset = 0f;
this.m_RightThumbOffset = 0f;
this.m_DstDragOffset = 0f;
GUIUtility.hotControl = 0;
current.Use();
}
GUI.Box(position, GUIContent.none, this.styles.header);
GUI.Box(rect3, GUIContent.none, this.styles.background);
this.m_TimeArea.DrawMajorTicks(rect3, 30f);
GUIContent content = EditorGUIUtility.TempContent(this.SrcName);
int num10 = !this.srcLoop ? 1 : (1 + ((int) ((num8 - rect4.xMin) / (rect4.xMax - rect4.xMin))));
Rect rect11 = rect4;
if (rect4.width < 10f)
{
rect11 = new Rect(rect4.x, rect4.y, (rect4.xMax - rect4.xMin) * num10, rect4.height);
num10 = 1;
}
for (int i = 0; i < num10; i++)
{
GUI.BeginGroup(rect11, GUIContent.none, this.styles.leftBlock);
float width = num7 - rect11.xMin;
float num13 = num8 - num7;
float num14 = (rect11.xMax - rect11.xMin) - (width + num13);
if (width > 0f)
{
GUI.Box(new Rect(0f, 0f, width, rect4.height), GUIContent.none, this.styles.onLeft);
}
if (num13 > 0f)
{
GUI.Box(new Rect(width, 0f, num13, rect4.height), GUIContent.none, this.styles.onOff);
}
if (num14 > 0f)
{
GUI.Box(new Rect(width + num13, 0f, num14, rect4.height), GUIContent.none, this.styles.offRight);
}
float b = 1f;
float num16 = this.styles.block.CalcSize(content).x;
float num17 = Mathf.Max(0f, width) - 20f;
float num18 = num17 + 15f;
if (((num17 < num16) && (num18 > 0f)) && (this.m_DragState == DragStates.LeftSelection))
{
b = 0f;
}
GUI.EndGroup();
float num19 = this.styles.leftBlock.normal.textColor.a;
if (!Mathf.Approximately(num19, b) && (Event.current.type == EventType.Repaint))
{
num19 = Mathf.Lerp(num19, b, 0.1f);
this.styles.leftBlock.normal.textColor = new Color(this.styles.leftBlock.normal.textColor.r, this.styles.leftBlock.normal.textColor.g, this.styles.leftBlock.normal.textColor.b, num19);
HandleUtility.Repaint();
}
GUI.Box(rect11, content, this.styles.leftBlock);
rect11 = new Rect(rect11.xMax, 85f, rect11.xMax - rect11.xMin, 32f);
}
GUIContent content2 = EditorGUIUtility.TempContent(this.DstName);
int num20 = !this.dstLoop ? 1 : (1 + ((int) ((num8 - rect5.xMin) / (rect5.xMax - rect5.xMin))));
rect11 = rect5;
if (rect5.width < 10f)
{
rect11 = new Rect(rect5.x, rect5.y, (rect5.xMax - rect5.xMin) * num20, rect5.height);
num20 = 1;
}
for (int j = 0; j < num20; j++)
{
GUI.BeginGroup(rect11, GUIContent.none, this.styles.rightBlock);
float num22 = num7 - rect11.xMin;
float num23 = num8 - num7;
float num24 = (rect11.xMax - rect11.xMin) - (num22 + num23);
if (num22 > 0f)
{
GUI.Box(new Rect(0f, 0f, num22, rect5.height), GUIContent.none, this.styles.offLeft);
}
if (num23 > 0f)
{
GUI.Box(new Rect(num22, 0f, num23, rect5.height), GUIContent.none, this.styles.offOn);
}
if (num24 > 0f)
{
GUI.Box(new Rect(num22 + num23, 0f, num24, rect5.height), GUIContent.none, this.styles.onRight);
}
float num25 = 1f;
float num26 = this.styles.block.CalcSize(content2).x;
float num27 = Mathf.Max(0f, num22) - 20f;
float num28 = num27 + 15f;
if (((num27 < num26) && (num28 > 0f)) && ((this.m_DragState == DragStates.LeftSelection) || (this.m_DragState == DragStates.Destination)))
{
num25 = 0f;
}
GUI.EndGroup();
float num29 = this.styles.rightBlock.normal.textColor.a;
if (!Mathf.Approximately(num29, num25) && (Event.current.type == EventType.Repaint))
{
num29 = Mathf.Lerp(num29, num25, 0.1f);
this.styles.rightBlock.normal.textColor = new Color(this.styles.rightBlock.normal.textColor.r, this.styles.rightBlock.normal.textColor.g, this.styles.rightBlock.normal.textColor.b, num29);
HandleUtility.Repaint();
}
GUI.Box(rect11, content2, this.styles.rightBlock);
rect11 = new Rect(rect11.xMax, rect11.yMin, rect11.xMax - rect11.xMin, 32f);
}
GUI.Box(rect7, GUIContent.none, this.styles.select);
GUI.Box(rect6, GUIContent.none, this.styles.selectHead);
this.m_TimeArea.TimeRuler(position, 30f);
GUI.Box(rect8, GUIContent.none, !this.m_HasExitTime ? this.styles.handLeftPrev : this.styles.handLeft);
GUI.Box(rect9, GUIContent.none, this.styles.handRight);
GUI.Box(rect10, GUIContent.none, this.styles.playhead);
Color color = Handles.color;
Handles.color = Color.white;
Handles.DrawLine(new Vector3(num9, 19f, 0f), new Vector3(num9, rect.height, 0f));
Handles.color = color;
bool flag2 = (this.SrcStopTime - this.SrcStartTime) < 0.03333334f;
bool flag3 = (this.DstStopTime - this.DstStartTime) < 0.03333334f;
if ((this.m_DragState == DragStates.Destination) && !flag3)
{
Rect rect12 = new Rect(num7 - 50f, rect5.y, 45f, rect5.height);
string t = string.Format("{0:0%}", (num7 - num5) / (num6 - num5));
GUI.Box(rect12, EditorGUIUtility.TempContent(t), this.styles.timeBlockRight);
}
if (this.m_DragState == DragStates.LeftSelection)
{
if (!flag2)
{
Rect rect13 = new Rect(num7 - 50f, rect4.y, 45f, rect4.height);
string str2 = string.Format("{0:0%}", (num7 - x) / (pixelX - x));
GUI.Box(rect13, EditorGUIUtility.TempContent(str2), this.styles.timeBlockRight);
}
if (!flag3)
{
Rect rect14 = new Rect(num7 - 50f, rect5.y, 45f, rect5.height);
string str3 = string.Format("{0:0%}", (num7 - num5) / (num6 - num5));
GUI.Box(rect14, EditorGUIUtility.TempContent(str3), this.styles.timeBlockRight);
}
}
if (this.m_DragState == DragStates.RightSelection)
{
if (!flag2)
{
Rect rect15 = new Rect(num8 + 5f, rect4.y, 45f, rect4.height);
string str4 = string.Format("{0:0%}", (num8 - x) / (pixelX - x));
GUI.Box(rect15, EditorGUIUtility.TempContent(str4), this.styles.timeBlockLeft);
}
if (!flag3)
{
Rect rect16 = new Rect(num8 + 5f, rect5.y, 45f, rect5.height);
string str5 = string.Format("{0:0%}", (num8 - num5) / (num6 - num5));
GUI.Box(rect16, EditorGUIUtility.TempContent(str5), this.styles.timeBlockLeft);
}
}
this.DoPivotCurves();
GUI.EndGroup();
return flag;
}