summaryrefslogtreecommitdiff
path: root/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items
diff options
context:
space:
mode:
Diffstat (limited to 'Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items')
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ClipItem.cs143
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ClipItem.cs.meta11
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ITimelineItem.cs39
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ITimelineItem.cs.meta11
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsGroup.cs63
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsGroup.cs.meta11
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsPerTrack.cs45
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsPerTrack.cs.meta11
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsUtils.cs116
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsUtils.cs.meta11
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/MarkerItem.cs106
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/MarkerItem.cs.meta11
12 files changed, 578 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ClipItem.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ClipItem.cs
new file mode 100644
index 0000000..d500257
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ClipItem.cs
@@ -0,0 +1,143 @@
+using System;
+using UnityEngine.Timeline;
+
+namespace UnityEditor.Timeline
+{
+ class ClipItem : IBlendable, ITrimmable
+ {
+ readonly TimelineClip m_Clip;
+
+ public TimelineClip clip
+ {
+ get { return m_Clip; }
+ }
+
+ public ClipItem(TimelineClip clip)
+ {
+ m_Clip = clip;
+ }
+
+ public TrackAsset parentTrack
+ {
+ get { return m_Clip.parentTrack; }
+ set { m_Clip.parentTrack = value; }
+ }
+
+ public double start
+ {
+ get { return m_Clip.start; }
+ set { m_Clip.start = value; }
+ }
+
+ public double end
+ {
+ get { return m_Clip.end; }
+ }
+
+ public double duration
+ {
+ get { return m_Clip.duration; }
+ }
+
+ public bool IsCompatibleWithTrack(TrackAsset track)
+ {
+ return track.IsCompatibleWithClip(m_Clip);
+ }
+
+ public void PushUndo(string operation)
+ {
+ TimelineUndo.PushUndo(m_Clip.parentTrack, operation);
+ }
+
+ public TimelineItemGUI gui
+ {
+ get { return ItemToItemGui.GetGuiForClip(m_Clip); }
+ }
+
+ public bool supportsBlending
+ {
+ get { return m_Clip.SupportsBlending(); }
+ }
+
+ public bool hasLeftBlend
+ {
+ get { return m_Clip.hasBlendIn; }
+ }
+
+ public bool hasRightBlend
+ {
+ get { return m_Clip.hasBlendOut; }
+ }
+
+ public double leftBlendDuration
+ {
+ get { return m_Clip.hasBlendIn ? m_Clip.blendInDuration : m_Clip.easeInDuration; }
+ }
+
+ public double rightBlendDuration
+ {
+ get { return m_Clip.hasBlendOut ? m_Clip.blendOutDuration : m_Clip.easeOutDuration; }
+ }
+
+ public void SetStart(double time)
+ {
+ ClipModifier.SetStart(m_Clip, time);
+ }
+
+ public void SetEnd(double time, bool affectTimeScale)
+ {
+ ClipModifier.SetEnd(m_Clip, time, affectTimeScale);
+ }
+
+ public void Delete()
+ {
+ EditorClipFactory.RemoveEditorClip(m_Clip);
+ ClipModifier.Delete(m_Clip.parentTrack.timelineAsset, m_Clip);
+ }
+
+ public void TrimStart(double time)
+ {
+ ClipModifier.TrimStart(m_Clip, time);
+ }
+
+ public void TrimEnd(double time)
+ {
+ ClipModifier.TrimEnd(m_Clip, time);
+ }
+
+ public ITimelineItem CloneTo(TrackAsset parent, double time)
+ {
+ return new ClipItem(TimelineHelpers.Clone(m_Clip, TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector, time, parent));
+ }
+
+ public override string ToString()
+ {
+ return m_Clip.ToString();
+ }
+
+ public bool Equals(ClipItem otherClip)
+ {
+ if (ReferenceEquals(null, otherClip)) return false;
+ if (ReferenceEquals(this, otherClip)) return true;
+ return Equals(m_Clip, otherClip.m_Clip);
+ }
+
+ public override int GetHashCode()
+ {
+ return (m_Clip != null ? m_Clip.GetHashCode() : 0);
+ }
+
+ public bool Equals(ITimelineItem other)
+ {
+ return Equals((object)other);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ var other = obj as ClipItem;
+ return other != null && Equals(other);
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ClipItem.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ClipItem.cs.meta
new file mode 100644
index 0000000..df97840
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ClipItem.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d143f3edd0494bc4c98a421bd59564fa
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ITimelineItem.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ITimelineItem.cs
new file mode 100644
index 0000000..092c2b0
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ITimelineItem.cs
@@ -0,0 +1,39 @@
+using System;
+using UnityEngine.Timeline;
+
+namespace UnityEditor.Timeline
+{
+ interface ITimelineItem : IEquatable<ITimelineItem>
+ {
+ double start { get; set; }
+ double end { get; }
+ double duration { get; }
+
+ TrackAsset parentTrack { get; set; }
+ bool IsCompatibleWithTrack(TrackAsset track);
+
+ void Delete();
+ ITimelineItem CloneTo(TrackAsset parent, double time);
+ void PushUndo(string operation);
+
+ TimelineItemGUI gui { get; }
+ }
+
+ interface ITrimmable : ITimelineItem
+ {
+ void SetStart(double time);
+ void SetEnd(double time, bool affectTimeScale);
+ void TrimStart(double time);
+ void TrimEnd(double time);
+ }
+
+ interface IBlendable : ITimelineItem
+ {
+ bool supportsBlending { get; }
+ bool hasLeftBlend { get; }
+ bool hasRightBlend { get; }
+
+ double leftBlendDuration { get; }
+ double rightBlendDuration { get; }
+ }
+}
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ITimelineItem.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ITimelineItem.cs.meta
new file mode 100644
index 0000000..a23827c
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ITimelineItem.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2c87ec8c97244cd47945ec90a99abe35
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsGroup.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsGroup.cs
new file mode 100644
index 0000000..41ff657
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsGroup.cs
@@ -0,0 +1,63 @@
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+
+namespace UnityEditor.Timeline
+{
+ class ItemsGroup
+ {
+ readonly ITimelineItem[] m_Items;
+ readonly ITimelineItem m_LeftMostItem;
+ readonly ITimelineItem m_RightMostItem;
+
+ public ITimelineItem[] items
+ {
+ get { return m_Items; }
+ }
+
+ public double start
+ {
+ get { return m_LeftMostItem.start; }
+ set
+ {
+ var offset = value - m_LeftMostItem.start;
+
+ foreach (var clip in m_Items)
+ clip.start += offset;
+ }
+ }
+
+ public double end
+ {
+ get { return m_RightMostItem.end; }
+ }
+
+ public ITimelineItem leftMostItem
+ {
+ get { return m_LeftMostItem; }
+ }
+
+ public ITimelineItem rightMostItem
+ {
+ get { return m_RightMostItem; }
+ }
+
+ public ItemsGroup(IEnumerable<ITimelineItem> items)
+ {
+ Debug.Assert(items != null && items.Any());
+
+ m_Items = items.ToArray();
+ m_LeftMostItem = null;
+ m_RightMostItem = null;
+
+ foreach (var item in m_Items)
+ {
+ if (m_LeftMostItem == null || item.start < m_LeftMostItem.start)
+ m_LeftMostItem = item;
+
+ if (m_RightMostItem == null || item.end > m_RightMostItem.end)
+ m_RightMostItem = item;
+ }
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsGroup.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsGroup.cs.meta
new file mode 100644
index 0000000..1da6246
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsGroup.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1ec4b8ec4b34f4344bac53c19288eaa2
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsPerTrack.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsPerTrack.cs
new file mode 100644
index 0000000..78a86ef
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsPerTrack.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine.Timeline;
+
+namespace UnityEditor.Timeline
+{
+ class ItemsPerTrack
+ {
+ public virtual TrackAsset targetTrack { get; }
+
+ public IEnumerable<ITimelineItem> items
+ {
+ get { return m_ItemsGroup.items; }
+ }
+
+ public IEnumerable<TimelineClip> clips
+ {
+ get { return m_ItemsGroup.items.OfType<ClipItem>().Select(i => i.clip); }
+ }
+
+ public IEnumerable<IMarker> markers
+ {
+ get { return m_ItemsGroup.items.OfType<MarkerItem>().Select(i => i.marker); }
+ }
+
+ public ITimelineItem leftMostItem
+ {
+ get { return m_ItemsGroup.leftMostItem; }
+ }
+
+ public ITimelineItem rightMostItem
+ {
+ get { return m_ItemsGroup.rightMostItem; }
+ }
+
+ protected readonly ItemsGroup m_ItemsGroup;
+
+ public ItemsPerTrack(TrackAsset targetTrack, IEnumerable<ITimelineItem> items)
+ {
+ this.targetTrack = targetTrack;
+ m_ItemsGroup = new ItemsGroup(items);
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsPerTrack.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsPerTrack.cs.meta
new file mode 100644
index 0000000..77da4ae
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsPerTrack.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 647e1bbd3809b30459d946b4a1ddf22b
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsUtils.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsUtils.cs
new file mode 100644
index 0000000..90e7985
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsUtils.cs
@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine.Timeline;
+
+namespace UnityEditor.Timeline
+{
+ static class ItemsUtils
+ {
+ static readonly Dictionary<TimelineClip, ClipItem> s_ClipCache = new Dictionary<TimelineClip, ClipItem>();
+ static readonly Dictionary<IMarker, MarkerItem> s_MarkerCache = new Dictionary<IMarker, MarkerItem>();
+
+ public static IEnumerable<ItemsPerTrack> ToItemsPerTrack(this IEnumerable<ITimelineItem> items)
+ {
+ var groupedItems = items.GroupBy(c => c.parentTrack);
+ foreach (var group in groupedItems)
+ {
+ yield return new ItemsPerTrack(group.Key, group.ToArray());
+ }
+ }
+
+ public static ITimelineItem ToItem(this TimelineClip clip)
+ {
+ if (s_ClipCache.ContainsKey(clip))
+ return s_ClipCache[clip];
+
+ var ret = new ClipItem(clip);
+ s_ClipCache.Add(clip, ret);
+ return ret;
+ }
+
+ public static ITimelineItem ToItem(this IMarker marker)
+ {
+ if (s_MarkerCache.ContainsKey(marker))
+ return s_MarkerCache[marker];
+
+ var ret = new MarkerItem(marker);
+ s_MarkerCache.Add(marker, ret);
+ return ret;
+ }
+
+ public static IEnumerable<ITimelineItem> ToItems(this IEnumerable<TimelineClip> clips)
+ {
+ return clips.Select(ToItem);
+ }
+
+ public static IEnumerable<ITimelineItem> ToItems(this IEnumerable<IMarker> markers)
+ {
+ return markers.Select(ToItem);
+ }
+
+ public static IEnumerable<ITimelineItem> GetItems(this TrackAsset track)
+ {
+ var list = track.clips.Select(clip => (ITimelineItem) new ClipItem(clip)).ToList();
+ list.AddRange(track.GetMarkers().Select(marker => (ITimelineItem) new MarkerItem(marker)));
+
+ list = list.OrderBy(x => x.start).ThenBy(x => x.end).ToList();
+ return list;
+ }
+
+ public static void GetItemRange(this TrackAsset track, out double start, out double end)
+ {
+ start = 0;
+ end = 0;
+ var items = track.GetItems().ToList();
+ if (items.Any())
+ {
+ start = items.Min(p => p.start);
+ end = items.Max(p => p.end);
+ }
+ }
+
+ public static IEnumerable<ITimelineItem> GetItemsExcept(this TrackAsset track, IEnumerable<ITimelineItem> items)
+ {
+ return GetItems(track).Except(items);
+ }
+
+ public static IEnumerable<Type> GetItemTypes(IEnumerable<ITimelineItem> items)
+ {
+ var types = new List<Type>();
+ if (items.OfType<ClipItem>().Any())
+ types.Add(typeof(ClipItem));
+ if (items.OfType<MarkerItem>().Any())
+ types.Add(typeof(MarkerItem));
+
+ return types;
+ }
+
+ public static IEnumerable<Type> GetItemTypes(IEnumerable<ItemsPerTrack> itemsGroups)
+ {
+ return GetItemTypes(itemsGroups.SelectMany(i => i.items)).Distinct();
+ }
+
+ public static void SetItemsStartTime(IEnumerable<ItemsPerTrack> newItems, double time)
+ {
+ var startTimes = newItems.Select(d => d.items.Min(x => x.start)).ToList();
+ var min = startTimes.Min();
+ startTimes = startTimes.Select(x => x - min + time).ToList();
+
+ for (int i = 0; i < newItems.Count(); ++i)
+ EditModeUtils.SetStart(newItems.ElementAt(i).items, startTimes[i]);
+ }
+
+ public static double TimeGapBetweenItems(ITimelineItem leftItem, ITimelineItem rightItem, WindowState state)
+ {
+ if (leftItem is MarkerItem && rightItem is MarkerItem)
+ {
+ var markerType = ((MarkerItem)leftItem).marker.GetType();
+ var gap = state.PixelDeltaToDeltaTime(StyleManager.UssStyleForType(markerType).fixedWidth);
+ return gap;
+ }
+
+ return 0.0;
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsUtils.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsUtils.cs.meta
new file mode 100644
index 0000000..65dca1e
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/ItemsUtils.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5653477a5039f674da8f856adcf47172
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/MarkerItem.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/MarkerItem.cs
new file mode 100644
index 0000000..e62c348
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/MarkerItem.cs
@@ -0,0 +1,106 @@
+using System;
+using UnityEngine.Timeline;
+using Object = UnityEngine.Object;
+
+namespace UnityEditor.Timeline
+{
+ class MarkerItem : ITimelineItem
+ {
+ readonly IMarker m_Marker;
+
+ public IMarker marker
+ {
+ get { return m_Marker; }
+ }
+
+ public MarkerItem(IMarker marker)
+ {
+ m_Marker = marker;
+ }
+
+ public TrackAsset parentTrack
+ {
+ get { return m_Marker.parent; }
+ set {}
+ }
+
+ public double start
+ {
+ get { return m_Marker.time; }
+ set { m_Marker.time = value; }
+ }
+
+ public double end
+ {
+ get { return m_Marker.time; }
+ }
+
+ public double duration
+ {
+ get { return 0.0; }
+ }
+
+ public bool IsCompatibleWithTrack(TrackAsset track)
+ {
+ return true;
+ }
+
+ public void PushUndo(string operation)
+ {
+ var m = m_Marker as Object;
+ if (m != null)
+ {
+ TimelineUndo.PushUndo(m, operation);
+ }
+ else
+ {
+ TimelineUndo.PushUndo(m_Marker.parent, operation);
+ }
+ }
+
+ public TimelineItemGUI gui
+ {
+ get { return ItemToItemGui.GetGuiForMarker(m_Marker); }
+ }
+
+ public void Delete()
+ {
+ MarkerModifier.DeleteMarker(m_Marker);
+ }
+
+ public ITimelineItem CloneTo(TrackAsset parent, double time)
+ {
+ var item = new MarkerItem(MarkerModifier.CloneMarkerToParent(m_Marker, parent));
+ item.start = time;
+ return item;
+ }
+
+ protected bool Equals(MarkerItem otherMarker)
+ {
+ return Equals(m_Marker, otherMarker.m_Marker);
+ }
+
+ public override int GetHashCode()
+ {
+ return (m_Marker != null ? m_Marker.GetHashCode() : 0);
+ }
+
+ public override string ToString()
+ {
+ return m_Marker.ToString();
+ }
+
+ public bool Equals(ITimelineItem other)
+ {
+ return Equals((object)other);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ var other = obj as MarkerItem;
+ return other != null && Equals(other);
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/MarkerItem.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/MarkerItem.cs.meta
new file mode 100644
index 0000000..8d20ad8
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Items/MarkerItem.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 452534715106564439d2240d82999d88
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: