1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
using System;
using UnityEngine;
using UnityEngine.Timeline;
namespace UnityEditor.Timeline
{
partial class TimelineWindow
{
TimeAreaItem m_TimelineDuration;
void DurationGUI(TimelineItemArea area, double duration)
{
// don't show the duration if the time area is not visible for some other reason.
if (!currentMode.ShouldShowTimeArea(state))
return;
bool headerMode = area == TimelineItemArea.Header;
if (state.IsEditingASubTimeline())
{
if (headerMode)
HighlightTimeAreaRange(state.editSequence.GetEvaluableRange(), DirectorStyles.Instance.customSkin.colorSubSequenceDurationLine);
return;
}
// don't show the duration if there's none.
if (state.editSequence.asset.durationMode == TimelineAsset.DurationMode.BasedOnClips && duration <= 0.0f)
return;
if (m_TimelineDuration == null || m_TimelineDuration.style != styles.endmarker)
{
m_TimelineDuration = new TimeAreaItem(styles.endmarker, OnTrackDurationDrag)
{
tooltip = "End of sequence marker",
boundOffset = new Vector2(0.0f, -DirectorStyles.kDurationGuiThickness)
};
}
DrawDuration(headerMode, !headerMode, duration);
}
void DrawDuration(bool drawhead, bool drawline, double duration)
{
if (state.TimeIsInRange((float)duration))
{
// Set the colors based on the mode
Color lineColor = DirectorStyles.Instance.customSkin.colorEndmarker;
Color headColor = Color.white;
bool canMoveHead = !EditorApplication.isPlaying && state.editSequence.asset.durationMode == TimelineAsset.DurationMode.FixedLength;
if (canMoveHead)
{
if (Event.current.type == EventType.MouseDown)
{
if (m_TimelineDuration.bounds.Contains(Event.current.mousePosition))
{
if (m_PlayHead != null && m_PlayHead.bounds.Contains(Event.current.mousePosition))
{
// ignore duration markers if the mouse is over the TimeCursor.
canMoveHead = false;
}
}
}
}
else
{
lineColor.a *= 0.66f;
headColor = DirectorStyles.Instance.customSkin.colorDuration;
}
if (canMoveHead)
m_TimelineDuration.HandleManipulatorsEvents(state);
m_TimelineDuration.lineColor = lineColor;
m_TimelineDuration.headColor = headColor;
m_TimelineDuration.drawHead = drawhead;
m_TimelineDuration.drawLine = drawline;
m_TimelineDuration.canMoveHead = canMoveHead;
// Draw the TimeAreaItem
// Rect trackheadRect = treeviewBounds;
//trackheadRect.height = clientArea.height;
m_TimelineDuration.Draw(sequenceRect, state, duration);
}
// Draw Blue line in timeline indicating the duration...
if (state.editSequence.asset != null && drawhead)
{
HighlightTimeAreaRange(state.editSequence.GetEvaluableRange(), DirectorStyles.Instance.customSkin.colorDurationLine);
}
}
void HighlightTimeAreaRange(Range range, Color lineColor)
{
if (range.length <= 0.0 || !state.RangeIsVisible(range)) return;
Rect lineRect = Rect.MinMaxRect(
Math.Max(state.TimeToPixel(range.start), state.timeAreaRect.xMin),
state.timeAreaRect.y - DirectorStyles.kDurationGuiThickness + state.timeAreaRect.height,
Math.Min(state.TimeToPixel(range.end), state.timeAreaRect.xMax),
state.timeAreaRect.y + state.timeAreaRect.height);
EditorGUI.DrawRect(lineRect, lineColor);
}
// Drag handler for the gui
void OnTrackDurationDrag(double newTime)
{
if (state.editSequence.asset.durationMode == TimelineAsset.DurationMode.FixedLength && !state.editSequence.isReadOnly)
{
// this is the first call to the drag
if (m_TimelineDuration.firstDrag)
{
TimelineUndo.PushUndo(state.editSequence.asset, "Change Duration");
}
state.editSequence.asset.fixedDuration = newTime;
// when setting a new length, modify the duration of the timeline playable directly instead of
// rebuilding the whole graph
state.UpdateRootPlayableDuration(newTime);
}
m_TimelineDuration.showTooltip = true;
}
}
}
|