Example #1
0
        public DragAndDropVisualMode HandleTrackDrop(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
        {
            ((TimelineTreeView)this.m_Window.treeView.gui).showInsertionMarker = false;
            TimelineDragging.TimelineDragData timelineDragData = (TimelineDragging.TimelineDragData)DragAndDrop.GetGenericData("TimelineDragging");
            DragAndDropVisualMode             result;

            if (!TimelineDragging.ValidDrag(targetItem, timelineDragData.draggedItems))
            {
                result = 0;
            }
            else
            {
                TimelineGroupGUI timelineGroupGUI = targetItem as TimelineGroupGUI;
                if (timelineGroupGUI != null && timelineGroupGUI.track != null)
                {
                    ((TimelineTreeView)this.m_Window.treeView.gui).showInsertionMarker = true;
                }
                if (dropPos == null)
                {
                    TimelineGroupGUI timelineGroupGUI2 = targetItem as TimelineGroupGUI;
                    if (timelineGroupGUI2 != null)
                    {
                        timelineGroupGUI2.isDropTarget = true;
                    }
                }
                if (perform)
                {
                    List <TrackAsset> draggedActors = (from x in timelineDragData.draggedItems.OfType <TimelineGroupGUI>()
                                                       select x.track).ToList <TrackAsset>();
                    if (draggedActors.Count == 0)
                    {
                        result = 0;
                        return(result);
                    }
                    PlayableAsset    playableAsset     = this.m_Timeline;
                    TimelineGroupGUI timelineGroupGUI3 = parentItem as TimelineGroupGUI;
                    if (timelineGroupGUI3 != null && timelineGroupGUI3.track != null)
                    {
                        playableAsset = timelineGroupGUI3.track;
                    }
                    TrackAsset trackAsset = (timelineGroupGUI == null) ? null : timelineGroupGUI.track;
                    if (playableAsset == this.m_Timeline && dropPos == 1 && trackAsset == null)
                    {
                        trackAsset = this.m_Timeline.tracks.LastOrDefault((TrackAsset x) => !draggedActors.Contains(x));
                    }
                    if (TrackExtensions.ReparentTracks(draggedActors, playableAsset, trackAsset, dropPos == 2))
                    {
                        this.m_Window.state.Refresh(true);
                    }
                }
                result = 16;
            }
            return(result);
        }
Example #2
0
        public TimelineTreeViewGUI(TimelineWindow sequencerWindow, TimelineAsset timeline, Rect rect)
        {
            this.m_Timeline = timeline;
            this.m_Window   = sequencerWindow;
            TreeViewState treeViewState = new TreeViewState();

            this.m_TreeView = new TreeViewController(sequencerWindow, treeViewState);
            this.m_TreeView.set_horizontalScrollbarStyle(GUIStyle.get_none());
            this.m_TimelineTreeView = new TimelineTreeView(sequencerWindow, this.m_TreeView);
            TimelineDragging timelineDragging = new TimelineDragging(this.m_TreeView, this.m_Window, this.m_Timeline);

            this.m_DataSource = new TimelineDataSource(this, this.m_TreeView, sequencerWindow);
            TimelineDataSource expr_7B = this.m_DataSource;

            expr_7B.onVisibleRowsChanged = (Action)Delegate.Combine(expr_7B.onVisibleRowsChanged, new Action(this.m_TimelineTreeView.CalculateRowRects));
            this.m_TreeView.Init(rect, this.m_DataSource, this.m_TimelineTreeView, timelineDragging);
            TreeViewController expr_C0 = this.m_TreeView;

            expr_C0.set_dragEndedCallback((Action <int[], bool>) Delegate.Combine(expr_C0.get_dragEndedCallback(), new Action <int[], bool>(delegate(int[] ids, bool value)
            {
                SelectionManager.Clear();
            })));
            this.m_DataSource.ExpandItems(this.m_DataSource.get_root());
        }
Example #3
0
        public DragAndDropVisualMode HandleObjectDrop(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
        {
            DragAndDropVisualMode result;

            if (!perform)
            {
                List <Object> list = new List <Object>();
                if (DragAndDrop.get_objectReferences().Any <Object>())
                {
                    list.AddRange(DragAndDrop.get_objectReferences());
                    using (List <Object> .Enumerator enumerator = list.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Object      o = enumerator.Current;
                            TrackType[] trackTypeHandle = TimelineHelpers.GetTrackTypeHandle(o.GetType());
                            if (!trackTypeHandle.Any <TrackType>() || trackTypeHandle.Any((TrackType t) => !TimelineDragging.ValidateObjectDrop(o)))
                            {
                                result = 0;
                                return(result);
                            }
                        }
                    }
                    result = 1;
                }
                else if (DragAndDrop.get_paths().Any <string>())
                {
                    TimelineGroupGUI timelineGroupGUI = targetItem as TimelineGroupGUI;
                    if (timelineGroupGUI == null)
                    {
                        result = 1;
                    }
                    else if (timelineGroupGUI.track == null)
                    {
                        result = 0;
                    }
                    else
                    {
                        TrackType tt    = TimelineHelpers.TrackTypeFromType(timelineGroupGUI.track.GetType());
                        string[]  paths = DragAndDrop.get_paths();
                        for (int i = 0; i < paths.Length; i++)
                        {
                            string text = paths[i];
                            list.AddRange(AssetDatabase.LoadAllAssetsAtPath(text));
                        }
                        bool flag = (from o in list
                                     where o != null
                                     select o).Any((Object o) => TimelineHelpers.IsTypeSupportedByTrack(tt, o.GetType()));
                        result = ((!flag) ? 0 : 1);
                    }
                }
                else
                {
                    result = 0;
                }
            }
            else
            {
                List <Object> list2 = new List <Object>();
                list2.AddRange(DragAndDrop.get_objectReferences());
                TrackAsset       trackAsset        = null;
                TimelineGroupGUI timelineGroupGUI2 = (TimelineGroupGUI)targetItem;
                if (targetItem != null && timelineGroupGUI2.track != null)
                {
                    trackAsset = timelineGroupGUI2.track;
                }
                Vector2 mousePosition = Event.get_current().get_mousePosition();
                foreach (Object current in list2)
                {
                    if (!(current == null))
                    {
                        if (current is TimelineAsset)
                        {
                            if (TimelineHelpers.IsCircularRef(this.m_Timeline, current as TimelineAsset))
                            {
                                Debug.LogError("Cannot add " + current.get_name() + " to the sequence because it would cause a circular reference");
                                continue;
                            }
                            TimelineAsset timelineAsset = current as TimelineAsset;
                            foreach (TrackAsset current2 in timelineAsset.tracks)
                            {
                                if (current2.mediaType == TimelineAsset.MediaType.Group)
                                {
                                    this.m_Timeline.AddTrackInternal(current2);
                                }
                            }
                            this.m_Window.state.Refresh();
                            EditorUtility.SetDirty(this.m_Timeline);
                        }
                        else if (current is TrackAsset)
                        {
                            this.m_Timeline.AddTrackInternal((TrackAsset)current);
                        }
                        else
                        {
                            TrackType   trackType        = null;
                            TrackAsset  trackAsset2      = null;
                            TrackType[] trackTypeHandle2 = TimelineHelpers.GetTrackTypeHandle(current.GetType());
                            if (trackAsset != null)
                            {
                                TrackType[] array = trackTypeHandle2;
                                for (int j = 0; j < array.Length; j++)
                                {
                                    TrackType trackType2 = array[j];
                                    if (trackAsset.GetType() == trackType2.trackType)
                                    {
                                        trackType = trackType2;
                                        break;
                                    }
                                }
                            }
                            if (trackType == null)
                            {
                                if (trackTypeHandle2.Length == 1)
                                {
                                    trackType = trackTypeHandle2[0];
                                }
                                else if (trackTypeHandle2.Length > 1)
                                {
                                    trackType = this.ResolveTypeAmbiguity(trackTypeHandle2);
                                }
                            }
                            if (trackType == null)
                            {
                                continue;
                            }
                            if (!TimelineDragging.ValidateObjectDrop(current))
                            {
                                continue;
                            }
                            if (trackAsset != null && trackAsset.GetType() == trackType.trackType)
                            {
                                trackAsset2 = trackAsset;
                            }
                            if (trackAsset2 == null)
                            {
                                trackAsset2 = this.m_Window.AddTrack(trackType.trackType, null, string.Empty);
                            }
                            if (trackAsset2 == null)
                            {
                                result = 0;
                                return(result);
                            }
                            Object @object = TimelineDragging.TransformObjectBeingDroppedAccordingToTrackRules(trackAsset2, current);
                            if (@object == null)
                            {
                                continue;
                            }
                            TimelineUndo.PushUndo(trackAsset2, "Create Clip");
                            AnimationTrack animationTrack = trackAsset2 as AnimationTrack;
                            if (animationTrack != null)
                            {
                                animationTrack.ConvertToClipMode();
                            }
                            TimelineClip timelineClip = TimelineHelpers.CreateClipOnTrack(@object, trackAsset2, this.m_Window.state, mousePosition);
                            if (timelineClip != null)
                            {
                                float num = this.m_Window.state.TimeToPixel(1.0) - this.m_Window.state.TimeToPixel(0.0);
                                mousePosition.x += (float)timelineClip.duration * num;
                                if (timelineClip.asset is ScriptableObject)
                                {
                                    string assetPath = AssetDatabase.GetAssetPath(timelineClip.asset);
                                    if (assetPath.Length == 0)
                                    {
                                        TimelineCreateUtilities.SaveAssetIntoObject(timelineClip.asset, trackAsset2);
                                    }
                                }
                                TimelineDragging.FrameClips(this.m_Window.state);
                                trackAsset2.SetCollapsed(false);
                            }
                        }
                        this.m_Window.state.Refresh();
                        EditorUtility.SetDirty(this.m_Timeline);
                    }
                }
                result = 1;
            }
            return(result);
        }