protected virtual void OnMouseUp(Event evt, TimelineWindow.TimelineState state, TimelineClipHandle handle) { this.m_UndoSaved = false; this.m_MagnetEngine = null; state.captured.Clear(); this.m_Ripple = null; }
private void AddMagnet(double magnetTime, Rect visibleRect, TimelineWindow.TimelineState state) { if (MagnetEngine.IsMagnetVisibleInRect(magnetTime, visibleRect, state)) { this.m_Magnets.Add(new MagnetEngine.MagnetInfo { time = magnetTime }); } }
protected virtual void OnMouseDown(Event evt, TimelineWindow.TimelineState state, TimelineClipHandle handle) { if (!state.captured.Contains(handle)) { state.captured.Add(handle); } this.m_IsCaptured = true; this.m_UndoSaved = false; SelectionManager.Add(handle.clip.clip); if (state.edgeSnaps) { this.m_MagnetEngine = new MagnetEngine(handle.clip, new DragClipHandle.DragClipAttractionHandler(this.m_FrameSnap), state); } this.m_OriginalDuration = handle.clip.clip.duration; this.m_OriginalTimeScale = handle.clip.clip.timeScale; this.m_FrameSnap.Reset(); }
public void Draw(double beginTime, double endTime, MagnetEngine magnetEngine) { TimelineWindow.TimelineState state = TimelineWindow.instance.state; Rect timeAreaBounds = TimelineWindow.instance.timeAreaBounds; timeAreaBounds.set_xMin(Mathf.Max(TimelineWindow.instance.timeAreaBounds.get_xMin(), state.TimeToTimeAreaPixel(beginTime))); timeAreaBounds.set_xMax(state.TimeToTimeAreaPixel(endTime)); Rect position = TimelineWindow.instance.get_position(); using (new GUIViewportScope(TimelineWindow.instance.timeAreaBounds)) { Color textColor = DirectorStyles.Instance.selectedStyle.get_focused().get_textColor(); textColor.a = 0.12f; EditorGUI.DrawRect(timeAreaBounds, textColor); this.m_BeginSelectionTooltip.text = state.TimeAsString(beginTime, "F2"); this.m_EndSelectionTooltip.text = state.TimeAsString(endTime, "F2"); Rect bounds = this.m_BeginSelectionTooltip.bounds; bounds.set_xMin(timeAreaBounds.get_xMin() - bounds.get_width() / 2f); bounds.set_y(timeAreaBounds.get_y()); this.m_BeginSelectionTooltip.bounds = bounds; bounds = this.m_EndSelectionTooltip.bounds; bounds.set_xMin(timeAreaBounds.get_xMax() - bounds.get_width() / 2f); bounds.set_y(timeAreaBounds.get_y()); this.m_EndSelectionTooltip.bounds = bounds; if (beginTime >= 0.0) { this.m_BeginSelectionTooltip.Draw(); } this.m_EndSelectionTooltip.Draw(); } if (beginTime >= 0.0) { if (magnetEngine == null || !magnetEngine.IsSnappedAtTime((double)state.PixelToTime(timeAreaBounds.get_xMin()))) { Graphics.DrawDottedLine(new Vector3(timeAreaBounds.get_xMin(), timeAreaBounds.get_yMax(), 0f), new Vector3(timeAreaBounds.get_xMin(), timeAreaBounds.get_yMax() + position.get_height()), 4f, Color.get_black()); } if (magnetEngine == null || !magnetEngine.IsSnappedAtTime((double)state.PixelToTime(timeAreaBounds.get_xMax()))) { Graphics.DrawDottedLine(new Vector3(timeAreaBounds.get_xMax(), timeAreaBounds.get_yMax(), 0f), new Vector3(timeAreaBounds.get_xMax(), timeAreaBounds.get_yMax() + position.get_height()), 4f, Color.get_black()); } } }
public override void Init(IControl parent) { parent.MouseDown += delegate(object target, Event evt, TimelineWindow.TimelineState state) { this.m_UndoSet = false; this.m_IsCaptured = (this.m_CaptureOnNextMouseDrag = false); bool result; if (evt.get_modifiers() == 4 || evt.get_button() == 2 || evt.get_button() == 1) { result = base.IgnoreEvent(); } else if (!SelectionManager.IsMouseHoveringOnItem()) { result = base.IgnoreEvent(); } else { TimelineClipGUI timelineClipGUI = (TimelineClipGUI)target; if (!SelectionManager.Contains(timelineClipGUI.clip)) { result = base.IgnoreEvent(); } else { this.m_FrameSnap.Reset(); this.m_CaptureOnNextMouseDrag = true; this.m_MouseDownPosition = evt.get_mousePosition(); this.m_HasValidDropTarget = false; result = base.ConsumeEvent(); } } return(result); }; parent.MouseUp += delegate(object target, Event evt, TimelineWindow.TimelineState state) { bool result; if (!this.m_IsCaptured) { result = base.IgnoreEvent(); } else { this.m_MagnetEngine = null; if (this.m_IsVerticalDrag) { state.captured.Clear(); this.m_IsVerticalDrag = false; state.isDragging = false; if (this.m_HasValidDropTarget && this.m_DropTarget != null) { TimelineClipGUI timelineClipGUI = (TimelineClipGUI)target; if (TrackExtensions.MoveClipToTrack(timelineClipGUI.clip, this.m_DropTarget.track)) { timelineClipGUI.clip.start = (double)state.PixelToTime(this.m_PreviewRect.get_x()); timelineClipGUI.parentTrackGUI.SortClipsByStartTime(); this.m_DropTarget.SortClipsByStartTime(); state.Refresh(); } } } state.Evaluate(); state.captured.Remove(target as IControl); this.m_IsCaptured = false; this.m_IsDragDriver = false; result = base.ConsumeEvent(); } return(result); }; parent.DragExited += delegate(object target, Event evt, TimelineWindow.TimelineState state) { this.m_IsVerticalDrag = false; return(base.IgnoreEvent()); }; parent.MouseDrag += delegate(object target, Event evt, TimelineWindow.TimelineState state) { if (!this.m_IsCaptured && this.m_CaptureOnNextMouseDrag) { state.captured.Add(target as IControl); this.m_IsCaptured = true; this.m_CaptureOnNextMouseDrag = false; TimelineClipGUI timelineClipGUI = (TimelineClipGUI)target; this.m_IsDragDriver = MoveItemUtilities.IsDriver(timelineClipGUI, evt, state); if (this.m_IsDragDriver) { this.m_DragPixelOffset = Vector2.get_zero(); this.m_IsDragDriverActive = false; if (!SelectionManager.IsMultiSelect() && state.edgeSnaps) { this.m_MagnetEngine = new MagnetEngine(timelineClipGUI, new MoveClipAttractionHandler(), state); } } } bool result; if (!this.m_IsCaptured) { result = base.IgnoreEvent(); } else { TimelineClipGUI timelineClipGUI2 = (TimelineClipGUI)target; if (SelectionManager.Count() == 1) { TimelineClipGUI timelineClipGUI3 = SelectionManager.SelectedClipGUI().FirstOrDefault <TimelineClipGUI>(); if (timelineClipGUI3 != null) { TimelineTrackGUI dropTargetAt = MoveClip.GetDropTargetAt(state, evt.get_mousePosition()); if (dropTargetAt != null) { bool flag = dropTargetAt != timelineClipGUI3.parentTrackGUI; if (flag && !this.m_IsVerticalDrag) { state.isDragging = true; this.m_HasValidDropTarget = false; this.m_DropTarget = null; this.m_MouseDownPosition.x = evt.get_mousePosition().x; this.m_PreviewOffset = this.m_MouseDownPosition - timelineClipGUI2.bounds.get_position(); } else if (this.m_IsVerticalDrag && !flag) { state.isDragging = false; this.m_HasValidDropTarget = false; this.m_DropTarget = null; this.m_DragPixelOffset = evt.get_mousePosition() - this.m_MouseDownPosition - evt.get_delta(); } this.m_IsVerticalDrag = flag; } } } if (this.m_IsVerticalDrag) { this.m_PreviewRect = new Rect(evt.get_mousePosition().x, evt.get_mousePosition().y, timelineClipGUI2.bounds.get_width(), timelineClipGUI2.bounds.get_height()); this.m_PreviewRect.set_position(this.m_PreviewRect.get_position() - this.m_PreviewOffset); this.UpdateDragTarget(timelineClipGUI2, evt.get_mousePosition(), state); result = base.ConsumeEvent(); } else { if (this.m_IsDragDriver) { this.m_DragPixelOffset += evt.get_delta(); this.m_IsDragDriverActive |= (Math.Abs(this.m_DragPixelOffset.x) > MoveClip.kDragBufferInPixels); if (this.m_IsDragDriverActive) { float delta = this.m_DragPixelOffset.x / state.timeAreaScale.x; this.m_DragPixelOffset = Vector3.get_zero(); this.SetUndo(); if (SelectionManager.IsMultiSelect()) { double currentValue = (from x in SelectionManager.SelectedItems <TimelineClip>() select x.start).DefaultIfEmpty(timelineClipGUI2.clip.start).Min(); this.m_FrameSnap.ApplyOffset(currentValue, delta, state); foreach (TimelineClip current in from x in SelectionManager.SelectedItems <TimelineClip>() orderby x.start select x) { if (current.start + this.m_FrameSnap.lastOffsetApplied < 0.0) { break; } current.start += this.m_FrameSnap.lastOffsetApplied; } } else { timelineClipGUI2.clip.start = this.m_FrameSnap.ApplyOffset(timelineClipGUI2.clip.start, delta, state); } if (this.m_MagnetEngine != null) { this.m_MagnetEngine.Snap(evt.get_delta().x); } timelineClipGUI2.InvalidateEditor(); timelineClipGUI2.parentTrackGUI.SortClipsByStartTime(); state.Evaluate(); } } result = base.ConsumeEvent(); } } return(result); }; parent.Overlay += delegate(object target, Event evt, TimelineWindow.TimelineState state) { if (this.m_MagnetEngine != null) { this.m_MagnetEngine.OnGUI(); } bool result; if (this.m_IsVerticalDrag) { TimelineClipGUI timelineClipGUI = (TimelineClipGUI)target; Color color = (!this.m_HasValidDropTarget) ? DirectorStyles.Instance.customSkin.colorInvalidDropTarget : DirectorStyles.Instance.customSkin.colorValidDropTarget; timelineClipGUI.DrawDragPreview(this.m_PreviewRect, color); result = base.ConsumeEvent(); } else if (this.m_IsDragDriver) { IEnumerable <TimelineClip> enumerable = SelectionManager.SelectedItems <TimelineClip>(); double num = 1.7976931348623157E+308; double num2 = -1.7976931348623157E+308; foreach (TimelineClip current in enumerable) { if (current.start < num) { num = current.start; } if (current.end > num2) { num2 = current.end; } } this.m_SelectionIndicator.Draw(num, num2, this.m_MagnetEngine); result = base.ConsumeEvent(); } else { result = base.IgnoreEvent(); } return(result); }; }
public override void Init(IControl parent) { bool isCaptured = false; MagnetEngine magnetEngine = null; parent.MouseDown += delegate(object target, Event evt, TimelineWindow.TimelineState state) { this.m_UndoSet = false; bool result; if (evt.get_modifiers() == 4 || evt.get_button() == 2 || evt.get_button() == 1) { result = this.IgnoreEvent(); } else if (!SelectionManager.IsMouseHoveringOnItem()) { result = this.IgnoreEvent(); } else { TimelineMarkerGUI timelineMarkerGUI = target as TimelineMarkerGUI; if (!SelectionManager.Contains(timelineMarkerGUI.timelineMarker)) { result = this.IgnoreEvent(); } else { this.m_IsDragDriver = MoveItemUtilities.IsDriver(timelineMarkerGUI, evt, state); this.m_FrameSnap.Reset(); state.captured.Add(target as IControl); isCaptured = true; if (this.m_IsDragDriver) { this.m_DragPixelOffset = Vector2.get_zero(); this.m_IsDragDriverActive = false; if (SelectionManager.Count() <= 1 && state.edgeSnaps) { magnetEngine = new MagnetEngine(timelineMarkerGUI, new MoveEventAttractionHandler(), state); } } result = this.ConsumeEvent(); } } return(result); }; parent.MouseUp += delegate(object target, Event evt, TimelineWindow.TimelineState state) { bool result; if (!isCaptured) { result = this.IgnoreEvent(); } else { magnetEngine = null; if (this.m_HasMoved) { state.rebuildGraph = true; this.m_HasMoved = false; } state.Evaluate(); state.captured.Remove(target as IControl); isCaptured = false; this.m_IsDragDriver = false; result = this.ConsumeEvent(); } return(result); }; parent.DragExited += ((object target, Event evt, TimelineWindow.TimelineState state) => this.IgnoreEvent()); parent.MouseDrag += delegate(object target, Event evt, TimelineWindow.TimelineState state) { bool result; if (!isCaptured) { result = this.IgnoreEvent(); } else { TimelineMarkerGUI timelineMarkerGUI = (TimelineMarkerGUI)target; if (this.m_IsDragDriver) { this.m_DragPixelOffset += evt.get_delta(); this.m_IsDragDriverActive |= (Math.Abs(this.m_DragPixelOffset.x) > MoveEvent.kDragBufferInPixels); if (this.m_IsDragDriverActive) { float delta = this.m_DragPixelOffset.x / state.timeAreaScale.x; this.m_DragPixelOffset = Vector3.get_zero(); this.SetUndo(state); if (SelectionManager.Count() > 1) { double currentValue = (from x in SelectionManager.SelectedItems <TimelineMarker>() select x.time).DefaultIfEmpty(timelineMarkerGUI.timelineMarker.time).Min(); this.m_FrameSnap.ApplyOffset(currentValue, delta, state); foreach (TimelineMarker current in from x in SelectionManager.SelectedItems <TimelineMarker>() orderby x.time select x) { if (current.time + this.m_FrameSnap.lastOffsetApplied < 0.0) { break; } current.time += this.m_FrameSnap.lastOffsetApplied; } } else { double num = this.m_FrameSnap.ApplyOffset(timelineMarkerGUI.timelineMarker.time, delta, state); if (num < 0.0) { num = 0.0; } timelineMarkerGUI.timelineMarker.time = num; } if (magnetEngine != null) { magnetEngine.Snap(evt.get_delta().x); } this.m_HasMoved = true; state.Evaluate(); } } result = this.ConsumeEvent(); } return(result); }; parent.Overlay += delegate(object target, Event evt, TimelineWindow.TimelineState state) { if (magnetEngine != null) { magnetEngine.OnGUI(); } bool result; if (this.m_IsDragDriver) { IEnumerable <TimelineMarker> enumerable = SelectionManager.SelectedItems <TimelineMarker>(); double num = 1.7976931348623157E+308; double num2 = -1.7976931348623157E+308; foreach (TimelineMarker current in enumerable) { if (current.time < num) { num = current.time; } if (current.time > num2) { num2 = current.time; } } this.m_SelectionIndicator.Draw(num, num2, magnetEngine); result = this.ConsumeEvent(); } else { result = this.IgnoreEvent(); } return(result); }; }
public override void Init(IControl parent) { this.m_IsCaptured = false; this.m_Ripple = null; this.m_OriginalDuration = 0.0; this.m_OriginalTimeScale = 0.0; this.m_UndoSaved = false; this.m_MagnetEngine = null; this.m_FrameSnap = new FrameSnap(); parent.MouseDown += delegate(object target, Event evt, TimelineWindow.TimelineState state) { TimelineClipHandle timelineClipHandle = target as TimelineClipHandle; bool result; if (timelineClipHandle == null) { result = base.IgnoreEvent(); } else { this.OnMouseDown(evt, state, timelineClipHandle); result = base.ConsumeEvent(); } return(result); }; parent.MouseUp += delegate(object target, Event evt, TimelineWindow.TimelineState state) { TimelineClipHandle timelineClipHandle = target as TimelineClipHandle; bool result; if (!this.m_IsCaptured || timelineClipHandle == null) { result = base.IgnoreEvent(); } else { this.OnMouseUp(evt, state, timelineClipHandle); result = base.ConsumeEvent(); } return(result); }; parent.MouseDrag += delegate(object target, Event evt, TimelineWindow.TimelineState state) { this.m_OverlayText = ""; this.m_OverlayStrings.Clear(); TimelineClipHandle timelineClipHandle = target as TimelineClipHandle; bool result; if (!this.m_IsCaptured || timelineClipHandle == null) { result = base.IgnoreEvent(); } else { this.OnMouseDrag(evt, state, timelineClipHandle); this.RefreshOverlayStrings(timelineClipHandle, state); if (Selection.get_activeObject() != null) { EditorUtility.SetDirty(Selection.get_activeObject()); } state.UpdateRootPlayableDuration(state.duration); result = base.ConsumeEvent(); } return(result); }; parent.Overlay += delegate(object target, Event evt, TimelineWindow.TimelineState state) { TimelineClipHandle timelineClipHandle = target as TimelineClipHandle; bool result; if (timelineClipHandle == null) { result = base.IgnoreEvent(); } else { this.OnOverlay(evt, timelineClipHandle); result = base.ConsumeEvent(); } return(result); }; }