TimelineItemGUI.cs
2.46 KB
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
using System;
using System.Collections.Generic;
using UnityEngine.Timeline;
using UnityEngine;
namespace UnityEditor.Timeline
{
static class ItemToItemGui
{
static Dictionary<object, TimelineItemGUI> s_ItemToItemGUI =
new Dictionary<object, TimelineItemGUI>();
public static void Add(TimelineClip clip, TimelineItemGUI gui)
{
s_ItemToItemGUI[clip] = gui;
}
public static void Add(IMarker marker, TimelineItemGUI gui)
{
s_ItemToItemGUI[marker] = gui;
}
public static TimelineClipGUI GetGuiForClip(TimelineClip clip)
{
return GetGuiForItem(clip) as TimelineClipGUI;
}
public static TimelineMarkerGUI GetGuiForMarker(IMarker marker)
{
return GetGuiForItem(marker) as TimelineMarkerGUI;
}
static TimelineItemGUI GetGuiForItem(object item)
{
if (item == null)
return null;
TimelineItemGUI gui;
s_ItemToItemGUI.TryGetValue(item, out gui);
return gui;
}
}
abstract class TimelineItemGUI : ISelectable
{
protected readonly DirectorStyles m_Styles;
public abstract ITimelineItem item { get; }
public abstract double start { get; }
public abstract double end { get; }
public abstract void Draw(Rect rect, bool rectChanged, WindowState state);
public abstract Rect RectToTimeline(Rect trackRect, WindowState state);
public virtual void Select() {}
public virtual bool IsSelected() { return false; }
public virtual void Deselect() {}
public virtual void StartDrag() {}
public virtual void StopDrag() {}
public LayerZOrder zOrder { get; set; }
public bool visible { get; set; }
public bool isInvalid { get; set; }
public IRowGUI parent { get; }
public Rect rect
{
get { return parent.ToWindowSpace(treeViewRect); }
}
public Rect treeViewRect
{
get { return m_TreeViewRect; }
protected set
{
m_TreeViewRect = value;
if (value.width < 0.0f)
m_TreeViewRect.width = 1.0f;
}
}
Rect m_TreeViewRect;
protected TimelineItemGUI(IRowGUI parent)
{
this.parent = parent;
m_Styles = DirectorStyles.Instance;
}
}
}