public virtual void Draw(Rect rect, WindowState state) { if (m_Items.Count <= 0) { return; } Sort(); // buffer to prevent flickering of markers at boundaries var onePixelTime = state.PixelDeltaToDeltaTime(kVisibilityBufferInPixels); var visibleTime = state.timeAreaShownRange + new Vector2(-onePixelTime, onePixelTime); var layerViewStateHasChanged = GetLayerViewStateChanged(rect, state); foreach (var item in m_Items) { item.visible = item.end > visibleTime.x && item.start < visibleTime.y; if (!item.visible) { continue; } item.Draw(rect, layerViewStateHasChanged, state); } }
public static void FrameItems(WindowState state, IEnumerable <ITimelineItem> items) { if (items == null || !items.Any() || state == null) { return; } // if this is called before a repaint, the timeArea can be null var window = state.editorWindow as TimelineWindow; if (window == null || window.timeArea == null) { return; } var start = (float)items.Min(x => x.start); var end = (float)items.Max(x => x.end); var timeRange = state.timeAreaShownRange; // nothing to do if (timeRange.x <= start && timeRange.y >= end) { return; } var ds = start - timeRange.x; var de = end - timeRange.y; var padding = state.PixelDeltaToDeltaTime(15); var d = Math.Abs(ds) < Math.Abs(de) ? ds - padding : de + padding; state.SetTimeAreaShownRange(timeRange.x + d, timeRange.y + d); }
// get the start and end times of what an added recording clip at a given time would be internal static void GetAddedRecordingClipRange(TrackAsset track, WindowState state, double atTime, out double start, out double end) { // size to make the clip in pixels. Reasonably big so that both handles are easily manipulated, // and the full title is normally visible double defaultDuration = state.PixelDeltaToDeltaTime(100); start = atTime; end = atTime + defaultDuration; double gapStart = 0; double gapEnd = 0; // no gap, pick are reasonable amount if (!track.GetGapAtTime(atTime, out gapStart, out gapEnd)) { start = atTime; return; } if (!double.IsInfinity(gapEnd)) { end = gapEnd; } start = TimeReferenceUtility.SnapToFrameIfRequired(start); end = TimeReferenceUtility.SnapToFrameIfRequired(end); }
protected override bool MouseDrag(Event evt, WindowState state) { if (!m_IsCaptured) { return(false); } if (!m_UndoSaved) { var uiClip = m_EaseClipHandler.clipGUI; string undoName = m_Edges == ManipulateEdges.Left ? EaseInClipText : EaseOutClipText; UndoExtensions.RegisterClip(uiClip.clip, undoName); m_UndoSaved = true; } double d = state.PixelDeltaToDeltaTime(evt.delta.x); var duration = m_Clip.duration; var easeInDurationLimit = duration - m_Clip.easeOutDuration; var easeOutDurationLimit = duration - m_Clip.easeInDuration; if (m_Edges == ManipulateEdges.Left) { m_Clip.easeInDuration = Math.Min(easeInDurationLimit, Math.Max(0, m_Clip.easeInDuration + d)); } else if (m_Edges == ManipulateEdges.Right) { m_Clip.easeOutDuration = Math.Min(easeOutDurationLimit, Math.Max(0, m_Clip.easeOutDuration - d)); } RefreshOverlayStrings(m_EaseClipHandler, state); return(true); }
protected override bool MouseDrag(Event evt, WindowState state) { if (!m_IsCaptured) { return(false); } if (!m_UndoSaved) { var uiClip = m_EaseClipHandler.clipGUI; string undoName = m_Edges == ManipulateEdges.Left ? EaseInClipText : EaseOutClipText; TimelineUndo.PushUndo(uiClip.clip.parentTrack, undoName); m_UndoSaved = true; } double d = state.PixelDeltaToDeltaTime(evt.delta.x); if (m_Edges == ManipulateEdges.Left) { m_Clip.easeInDuration = Math.Max(0, m_Clip.easeInDuration + d); } else if (m_Edges == ManipulateEdges.Right) { m_Clip.easeOutDuration = Math.Max(0, m_Clip.easeOutDuration - d); } RefreshOverlayStrings(m_EaseClipHandler, state); return(true); }
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); }
public static void Frame(WindowState state, double start, double end) { var timeRange = state.timeAreaShownRange; // nothing to do if (timeRange.x <= start && timeRange.y >= end) { return; } var ds = (float)start - timeRange.x; var de = (float)end - timeRange.y; var padding = state.PixelDeltaToDeltaTime(15); var d = Math.Abs(ds) < Math.Abs(de) ? ds - padding : de + padding; state.SetTimeAreaShownRange(timeRange.x + d, timeRange.y + d); }
static void DoPanScroll(WindowState state) { if (!state.playing) { return; } var paddingDeltaTime = state.PixelDeltaToDeltaTime(WindowConstants.autoPanPaddingInPixels); var showRange = state.timeAreaShownRange; var rightBoundForPan = showRange.y - paddingDeltaTime; if (state.editSequence.time > rightBoundForPan) { var leftBoundForPan = showRange.x + paddingDeltaTime; var delta = rightBoundForPan - leftBoundForPan; state.SetTimeAreaShownRange(showRange.x + delta, showRange.y + delta); } }