void RefreshOverlayStrings(TimelineClipHandle handle, WindowState state) { m_OverlayText.Length = 0; m_OverlayText.Append(m_Edges == ManipulateEdges.Left ? EaseInText : EaseOutText); double easeDuration = m_Edges == ManipulateEdges.Left ? m_Clip.easeInDuration : m_Clip.easeOutDuration; double deltaDuration = easeDuration - m_OriginalValue; bool hasDurationDelta = Math.Abs(deltaDuration) > double.Epsilon; if (state.timeInFrames) { easeDuration *= state.editSequence.frameRate; deltaDuration *= state.editSequence.frameRate; m_OverlayText.AppendFormat(DurationFrameText, easeDuration); if (hasDurationDelta) { m_OverlayText.AppendFormat(DeltaFrameText, deltaDuration); } } else { m_OverlayText.AppendFormat(DurationSecText, easeDuration); if (hasDurationDelta) { m_OverlayText.AppendFormat(DeltaSecText, deltaDuration); } } }
protected override bool MouseDown(Event evt, WindowState state) { var handle = PickerUtils.PickedLayerableOfType <TimelineClipHandle>(); if (handle == null) { return(false); } if (handle.clipGUI.clip.parentTrack != null && handle.clipGUI.clip.parentTrack.lockedInHierarchy) { return(false); } if (ItemSelection.CanClearSelection(evt)) { SelectionManager.Clear(); } if (!SelectionManager.Contains(handle.clipGUI.clip)) { SelectionManager.Add(handle.clipGUI.clip); } m_TrimClipHandler = handle; m_IsCaptured = true; state.AddCaptured(this); m_UndoSaved = false; var clip = m_TrimClipHandler.clipGUI.clip; m_OriginalDuration = clip.duration; m_OriginalTimeScale = clip.timeScale; m_OriginalEaseInDuration = clip.easeInDuration; m_OriginalEaseOutDuration = clip.easeOutDuration; RefreshOverlayStrings(m_TrimClipHandler, state); // in ripple trim, the right edge moves and needs to snap var edges = ManipulateEdges.Right; if (EditMode.editType != EditMode.EditType.Ripple && m_TrimClipHandler.trimDirection == TrimEdge.Start) { edges = ManipulateEdges.Left; } m_SnapEngine = new SnapEngine(m_TrimClipHandler.clipGUI, new TrimClipAttractionHandler(), edges, state, evt.mousePosition); EditMode.BeginTrim(ItemsUtils.ToItem(clip), m_TrimClipHandler.trimDirection); return(true); }
private static void ManipulateBlending(TimelineClipHandle handle, Event evt, float scale) { if (handle.direction == TimelineClipHandle.DragDirection.Right) { float num = evt.get_delta().x / scale; handle.clip.clip.easeOutDuration -= (double)num; } else { float num2 = evt.get_delta().x / scale; handle.clip.clip.easeInDuration += (double)num2; } }
protected void RefreshOverlayStrings(TimelineClipHandle handle, TimelineWindow.TimelineState state) { double num = (this.m_OriginalTimeScale - handle.clip.clip.timeScale) * 100.0; double num2 = handle.clip.clip.duration - this.m_OriginalDuration; this.m_OverlayText = ""; if (Math.Abs(num) > DragClipHandle.kEpsilon) { this.m_OverlayText = "speed: " + (handle.clip.clip.timeScale * 100.0).ToString("f2") + "%"; this.m_OverlayText += " ("; if (num > 0.0) { this.m_OverlayText += "+"; } this.m_OverlayText = this.m_OverlayText + num.ToString("f2") + "%"; this.m_OverlayText += ")"; this.m_OverlayStrings.Add(this.m_OverlayText); } this.m_OverlayText = ""; if (Math.Abs(num2) > DragClipHandle.kEpsilon) { if (!state.timeInFrames) { this.m_OverlayText = this.m_OverlayText + " duration: " + handle.clip.clip.duration.ToString("f2") + "s"; this.m_OverlayText += " ("; if (num2 > 0.0) { this.m_OverlayText += "+"; } this.m_OverlayText = this.m_OverlayText + num2.ToString("f2") + "s"; this.m_OverlayText += ")"; this.m_OverlayStrings.Add(this.m_OverlayText); } else { double num3 = handle.clip.clip.duration * (double)state.frameRate; this.m_OverlayText = this.m_OverlayText + " duration: " + num3.ToString("f2") + "frames"; this.m_OverlayText += " ("; if (num2 > 0.0) { this.m_OverlayText += "+"; } double num4 = num2 * (double)state.frameRate; this.m_OverlayText = this.m_OverlayText + num4.ToString("f2") + "frames"; this.m_OverlayText += ")"; this.m_OverlayStrings.Add(this.m_OverlayText); } } }
public TimelineClipGUI(TimelineClip clip, IRowGUI parent, IZOrderProvider provider) : base(parent) { zOrderProvider = provider; zOrder = provider.Next(); m_EditorItem = EditorClipFactory.GetEditorClip(clip); m_ClipEditor = CustomTimelineEditorCache.GetClipEditor(clip); supportResize = true; leftHandle = new TimelineClipHandle(this, TrimEdge.Start); rightHandle = new TimelineClipHandle(this, TrimEdge.End); ItemToItemGui.Add(clip, this); }
public TimelineClipGUI(TimelineClip clip, IRowGUI parent, IZOrderProvider provider) : base(parent) { zOrderProvider = provider; zOrder = provider.Next(); m_EditorItem = EditorClipFactory.GetEditorClip(clip); clip.dirtyHash = 0; supportResize = true; m_LeftHandle = new TimelineClipHandle(this, TrimEdge.Start); m_RightHandle = new TimelineClipHandle(this, TrimEdge.End); ItemToItemGui.Add(clip, this); }
protected override bool MouseUp(Event evt, WindowState state) { if (!m_IsCaptured) { return(false); } m_IsCaptured = false; m_TrimClipHandler = null; m_UndoSaved = false; m_SnapEngine = null; EditMode.FinishTrim(); state.captured.Clear(); return(true); }
void RefreshOverlayStrings(TimelineClipHandle handle, WindowState state) { m_OverlayText.Length = 0; m_OverlayText.Append(m_Edges == ManipulateEdges.Left ? EaseInText : EaseOutText); var easeDuration = m_Edges == ManipulateEdges.Left ? m_Clip.easeInDuration : m_Clip.easeOutDuration; var deltaDuration = easeDuration - m_OriginalValue; // round to frame so we don't show partial time codes due to no frame snapping if (state.timeFormat == TimeFormat.Timecode) { easeDuration = TimeUtility.RoundToFrame(easeDuration, state.referenceSequence.frameRate); deltaDuration = TimeUtility.RoundToFrame(deltaDuration, state.referenceSequence.frameRate); } m_OverlayText.Append(DurationText); m_OverlayText.Append(state.timeFormat.ToTimeStringWithDelta(easeDuration, state.referenceSequence.frameRate, deltaDuration)); }
void RefreshOverlayStrings(TimelineClipHandle handle, WindowState state) { m_OverlayStrings.Clear(); var differenceDuration = handle.clipGUI.clip.duration - m_OriginalDuration; m_OverlayStrings.Add($"{kDurationText} {state.timeFormat.ToTimeStringWithDelta(handle.clipGUI.clip.duration, state.referenceSequence.frameRate, differenceDuration)}"); var differenceSpeed = m_OriginalTimeScale - handle.clipGUI.clip.timeScale; if (Math.Abs(differenceSpeed) > kEpsilon) { var sign = differenceSpeed > 0 ? "+" : ""; var timeScale = handle.clipGUI.clip.timeScale.ToString("f2"); var deltaSpeed = differenceSpeed.ToString("p2"); m_OverlayStrings.Add($"{kSpeedText} {timeScale} ({sign}{deltaSpeed}) "); } }
protected virtual void OnOverlay(Event evt, TimelineClipHandle handle) { if (this.m_OverlayStrings.Count > 0) { Vector2 vector = TimelineWindow.styles.tinyFont.CalcSize(new GUIContent(this.m_OverlayStrings[0])); Rect rect = new Rect(evt.get_mousePosition().x - vector.x / 2f, handle.clip.parentTrackGUI.boundingRect.get_y() + handle.clip.parentTrackGUI.boundingRect.get_height() + 42f, vector.x, 40f); GUILayout.BeginArea(rect); GUILayout.BeginVertical(new GUILayoutOption[0]); GUI.Label(rect, GUIContent.none, TimelineWindow.styles.displayBackground); foreach (string current in this.m_OverlayStrings) { GUILayout.Label(current, TimelineWindow.styles.tinyFont, new GUILayoutOption[0]); } GUILayout.EndVertical(); GUILayout.EndArea(); } if (this.m_MagnetEngine != null) { this.m_MagnetEngine.OnGUI(); } }
protected bool MouseDownInternal(Event evt, WindowState state, TimelineClipHandle handle) { if (handle == null) { return(false); } if (handle.clipGUI.clip != null && !handle.clipGUI.clip.clipCaps.HasAny(ClipCaps.Blending)) { return(false); } m_Edges = ManipulateEdges.Right; if (handle.trimDirection == TrimEdge.Start) { m_Edges = ManipulateEdges.Left; } if (m_Edges == ManipulateEdges.Left && handle.clipGUI.clip.hasBlendIn || m_Edges == ManipulateEdges.Right && handle.clipGUI.clip.hasBlendOut) { return(false); } m_IsCaptured = true; m_UndoSaved = false; m_EaseClipHandler = handle; m_Clip = handle.clipGUI.clip; m_OriginalValue = m_Edges == ManipulateEdges.Left ? m_Clip.easeInDuration : m_Clip.easeOutDuration; // Change cursor only when OnGUI Process (not in test) if (GUIUtility.guiDepth > 0) { TimelineCursors.SetCursor(m_Edges == ManipulateEdges.Left ? TimelineCursors.CursorType.MixRight : TimelineCursors.CursorType.MixLeft); } state.AddCaptured(this); return(true); }
void RefreshOverlayStrings(TimelineClipHandle handle, WindowState state) { m_OverlayStrings.Clear(); m_OverlayText.Length = 0; var differenceDuration = handle.clipGUI.clip.duration - m_OriginalDuration; bool hasDurationDelta = Math.Abs(differenceDuration) > kEpsilon; if (state.timeInFrames) { var durationInFrame = handle.clipGUI.clip.duration * state.referenceSequence.frameRate; m_OverlayText.Append("duration: ").Append(durationInFrame.ToString("f2")).Append(" frames"); if (hasDurationDelta) { m_OverlayText.Append(" ("); if (differenceDuration > 0.0) { m_OverlayText.Append("+"); } var valueInFrame = differenceDuration * state.referenceSequence.frameRate; m_OverlayText.Append(valueInFrame.ToString("f2")).Append(" frames)"); } } else { m_OverlayText.Append("duration: ").Append(handle.clipGUI.clip.duration.ToString("f2")).Append("s"); if (hasDurationDelta) { m_OverlayText.Append(" ("); if (differenceDuration > 0.0) { m_OverlayText.Append("+"); } m_OverlayText.Append(differenceDuration.ToString("f2")).Append("s)"); } } m_OverlayStrings.Add(m_OverlayText.ToString()); m_OverlayText.Length = 0; var differenceSpeed = m_OriginalTimeScale - handle.clipGUI.clip.timeScale; if (Math.Abs(differenceSpeed) > kEpsilon) { m_OverlayText.Append("speed: ").Append(handle.clipGUI.clip.timeScale.ToString("p2")); m_OverlayText.Append(" ("); if (differenceSpeed > 0.0) { m_OverlayText.Append("+"); } m_OverlayText.Append(differenceSpeed.ToString("p2")).Append(")"); m_OverlayStrings.Add(m_OverlayText.ToString()); } }
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(); }
protected virtual void OnMouseDrag(Event evt, TimelineWindow.TimelineState state, TimelineClipHandle handle) { if (evt.get_modifiers() == 2) { DragClipHandle.ManipulateBlending(handle, evt, state.timeAreaScale.x); } else { if (!this.m_UndoSaved) { TimelineUndo.PushUndo(handle.clip.parentTrackGUI.track, "Trim Clip"); this.m_UndoSaved = true; } float num = evt.get_delta().x / state.timeAreaScale.x; if (this.m_Ripple != null) { this.m_Ripple.Run(num, state); } ManipulateEdges edges; if (handle.direction == TimelineClipHandle.DragDirection.Right) { double val = this.m_FrameSnap.ApplyOffset(handle.clip.clip.duration, num, state); handle.clip.clip.duration = Math.Max(val, TimelineClip.kMinDuration); if (handle.clip.clip.SupportsSpeedMultiplier() && evt.get_modifiers() == 1) { double num2 = this.m_OriginalDuration / handle.clip.clip.duration; handle.clip.clip.timeScale = this.m_OriginalTimeScale * num2; } edges = ManipulateEdges.Right; } else { double num3 = handle.clip.clip.clipIn / handle.clip.clip.timeScale; if (num3 > 0.0 && num3 + (double)num < 0.0) { num = (float)(-(float)num3); } if (this.m_MagnetEngine == null || !this.m_MagnetEngine.isSnapped) { double newValue = this.m_FrameSnap.ApplyOffset(num3, num, state) * handle.clip.clip.timeScale; DragClipHandle.SetClipIn(handle.clip.clip, newValue, this.m_FrameSnap.lastOffsetApplied); } edges = ManipulateEdges.Left; } if (this.m_MagnetEngine != null && evt.get_modifiers() != 1) { this.m_MagnetEngine.Snap(evt.get_delta().x, edges); } handle.clip.clip.duration = Math.Max(handle.clip.clip.duration, TimelineClip.kMinDuration); } }
protected override void OnMouseDrag(Event evt, TimelineWindow.TimelineState state, TimelineClipHandle handle) { ManipulateEdges edges = ManipulateEdges.Both; float delta = evt.get_delta().x / state.timeAreaScale.x; TimelineUndo.PushUndo(handle.clip.clip.parentTrack, "Trim Clip"); TimelineClipHandle.DragDirection direction = handle.direction; if (direction != TimelineClipHandle.DragDirection.Right) { if (direction == TimelineClipHandle.DragDirection.Left) { double num = this.m_FrameSnap.ApplyOffset(handle.clip.clip.start, delta, state); if (num > 0.0) { double num2 = num - handle.clip.clip.start; handle.clip.clip.start = num; if (handle.clip.clip.duration - num2 > TimelineClip.kMinDuration) { handle.clip.clip.duration -= num2; } } edges = ManipulateEdges.Left; } } else { double val = this.m_FrameSnap.ApplyOffset(handle.clip.clip.duration, delta, state); handle.clip.clip.duration = Math.Max(val, TimelineClip.kMinDuration); edges = ManipulateEdges.Right; } if (this.m_MagnetEngine != null && evt.get_modifiers() != 1) { this.m_MagnetEngine.Snap(evt.get_delta().x, edges); } }
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); }; }
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; }