Ejemplo n.º 1
0
        public void Init(FObject obj, FTimelineEditor timelineEditor)
        {
            _timelineEditor = timelineEditor;
            Init(obj);
#if UNITY_4_6
            _offsetAnim.valueChanged.AddListener(SequenceEditor.Repaint);
#endif
        }
Ejemplo n.º 2
0
        public void StopTimelineDrag()
        {
            Rect timelineRect = _sequenceRect;

            timelineRect.y      = -_scrollPos.y;
            timelineRect.height = 0;

            int newPos = -1;

            for (int i = 0; i != _timelineEditors.Count; ++i)
            {
                timelineRect.yMin   = timelineRect.yMax;
                timelineRect.height = _timelineEditorHeights[i];

                if (Event.current.mousePosition.y > timelineRect.yMin && Event.current.mousePosition.y < timelineRect.yMax)
                {
                    newPos = i;
                    break;
                }
            }

            string undoMoveTimelineStr = "move Timeline";

            if (newPos == -1)              // moved it to the end of the list
            {
                Undo.SetTransformParent(_timelineDragged._timeline.transform, _sequence.TimelineContainer, undoMoveTimelineStr);
                _timelineDragged._timeline.transform.SetAsLastSibling();

                _timelineEditors.RemoveAt(_timelineDragged.GetRuntimeObject().GetId());
                _timelineEditors.Add(_timelineDragged);
            }
            else
            {
                if (newPos != _timelineDragged._timeline.GetId())
                {
                    Undo.SetTransformParent(_timelineDragged._timeline.transform, _sequence.TimelineContainer, undoMoveTimelineStr);
                    _timelineDragged._timeline.transform.SetSiblingIndex(newPos);

                    _timelineEditors[_timelineDragged.GetRuntimeObject().GetId()] = null;
                    _timelineEditors.Insert(newPos, _timelineDragged);
                    _timelineEditors.Remove(null);
                }
            }

            _timelineDragged = null;

//			_sequence.Rebuild();

            // move where?
            for (int i = 0; i != _timelineEditors.Count; ++i)
            {
                _timelineEditors[i].SetOffset(Vector2.zero, true);
            }
        }
Ejemplo n.º 3
0
        private void SelectTimeline(FTimelineEditor timelineEditor)
        {
            if (timelineEditor == null || timelineEditor.IsSelected())
            {
                return;
            }

            Undo.RecordObject(timelineEditor, "select Timeline");

            timelineEditor.OnSelect();
        }
Ejemplo n.º 4
0
        private Rect GetDragSelectionRect(Vector2 rawStartPos, Vector2 rawEndPos, out FrameRange selectedRange, out bool isSelectingTimelines)
        {
            int startFrame = GetFrameForX(rawStartPos.x);
            int endFrame   = GetFrameForX(rawEndPos.x);

            if (startFrame > endFrame)
            {
                int temp = startFrame;
                startFrame = endFrame;
                endFrame   = temp;
            }

            selectedRange = new FrameRange(startFrame, endFrame);

            Rect rect = new Rect();

            Vector2 startPos = new Vector2(GetXForFrame(startFrame), rawStartPos.y);
            Vector2 endPos   = new Vector2(GetXForFrame(endFrame), rawEndPos.y);

            bool isStartOnHeader;
            bool isEndOnHeader;

            FTimelineEditor startTimeline = GetTimeline(startPos, out isStartOnHeader);

            isSelectingTimelines = isStartOnHeader;

            if (startTimeline != null)
            {
                FTrackEditor startTrack = GetTrack(startPos);
                FTrackEditor endTrack;

                FTimelineEditor endTimeline = GetTimeline(endPos, out isEndOnHeader);
                if (endTimeline == null)
                {
                    endTimeline   = startTimeline;
                    isEndOnHeader = isStartOnHeader;
                    endTrack      = startTrack;
                }
                else
                {
                    endTrack = GetTrack(endPos);
                }

                float xStart = Mathf.Min(startPos.x, endPos.x);
                float width  = Mathf.Abs(startPos.x - endPos.x);
                float yStart;
                float height;


                if (startPos.y <= endPos.y)
                {
                    yStart = isStartOnHeader ? startTimeline.GetRect().yMin : startTrack.GetRect().yMin;
                    height = (isStartOnHeader ? endTimeline.GetRect().yMax : (isEndOnHeader ? endTimeline.GetRect().yMin + FTimelineEditor.HEADER_HEIGHT : endTrack.GetRect().yMax)) - yStart;
                    //					yStart = isStartOnHeader ? startTimeline.GetRect().yMin : startTrack.GetRect().yMin;
                    //					height = (isEndOnHeader ? endTimeline._trackEditors[endTimeline._trackEditors.Count-1].GetRect().yMax : endTrack.GetRect().yMax) - yStart;
                }
                else
                {
                    yStart = isStartOnHeader || isEndOnHeader?endTimeline.GetRect().yMin : endTrack.GetRect().yMin;

                    height = (isStartOnHeader ? startTimeline.GetRect().yMax : startTrack.GetRect().yMax) - yStart;
                    //					yStart = isEndOnHeader ? endTimeline.GetRect().yMin : endTrack.GetRect().yMin;
                    //					height = Mathf.Max( (isStartOnHeader ? startTimeline._trackEditors[startTimeline._trackEditors.Count-1].GetRect().yMax : startTrack.GetRect().yMax),
                    //					                   (isEndOnHeader ? endTimeline._trackEditors[endTimeline._trackEditors.Count-1].GetRect().yMax : endTrack.GetRect().yMax) ) - yStart;
                }

                rect.x      = xStart;
                rect.y      = yStart;
                rect.width  = width;
                rect.height = height;
            }

            return(rect);
        }
Ejemplo n.º 5
0
 public void CancelTimelineDrag()
 {
     _timelineDragged = null;
 }
Ejemplo n.º 6
0
 public void StartTimelineDrag(FTimelineEditor timelineEditor)
 {
     _timelineDragged = timelineEditor;
 }
Ejemplo n.º 7
0
        public void OpenSequence(GTimelineEditor sequence)
        {
#if FLUX_DEBUG
            Debug.Log("Opening sequence: " + sequence);
#endif
            if (sequence == null)
            {
                Debug.LogError("sequence == null");
                if (!object.Equals(sequence, null))
                {
                    sequence = (GTimelineEditor)EditorUtility.InstanceIDToObject(sequence.GetInstanceID());
                }
            }

            bool sequenceChanged = _sequence != sequence && (object.Equals(_sequence, null) || object.Equals(sequence, null) || _sequence.GetInstanceID() != sequence.GetInstanceID());

//			Debug.Log ("selected sequence! Changed? " + sequenceChanged );

            if (sequenceChanged)
            {
                if (_sequence != null)
                {
                    Stop();
                }
                _editorCache.Clear();
                _selectedEvents.Clear();
                _selectedTracks.Clear();
            }
            else
            {
                _editorCache.Refresh();
            }


            if (sequence != null)
            {
//				_sequenceInstanceID = sequence.GetInstanceID();
                if (_viewRange.Length == 0)
                {
                    _viewRange = new FrameRange(0, sequence.Length);
                }

                if (!EditorApplication.isPlaying)
                {
                    sequence.Rebuild();
                }

                List <FTimeline> timelines = sequence.GetTimelines();

                _timelineEditors.Clear();

                for (int i = 0; i < timelines.Count; ++i)
                {
                    FTimeline       timeline       = timelines[i];
                    FTimelineEditor timelineEditor = GetEditor <FTimelineEditor>(timeline);
                    timelineEditor.Init(timeline, this);
                    _timelineEditors.Add(timelineEditor);
                }

                if (_viewRange.Length == 0)
                {
                    _viewRange = new FrameRange(0, sequence.Length);
                }
            }
            else
            {
//				_sequenceInstanceID = int.MinValue;
            }

            _sequence = sequence;

            Repaint();
        }