public static void FrameRange(float startTime, float endTime, WindowState state) { if (startTime > endTime) { return; } var halfDuration = endTime - Math.Max(0.0f, startTime); if (halfDuration > 0.0f) { state.SetTimeAreaShownRange(Mathf.Max(-10.0f, startTime - (halfDuration * 0.1f)), endTime + (halfDuration * 0.1f)); } else { // start == end // keep the zoom level constant, only pan the time area to center the item var currentRange = state.timeAreaShownRange.y - state.timeAreaShownRange.x; state.SetTimeAreaShownRange(startTime - currentRange / 2, startTime + currentRange / 2); } TimelineZoomManipulator.InvalidateWheelZoom(); state.Evaluate(); }
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); }
protected override bool OnFinish(Event evt, WindowState state, Rect rect) { var x = state.PixelToTime(rect.xMin); var y = state.PixelToTime(rect.xMax); state.SetTimeAreaShownRange(x, y); return(true); }
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); } }
static void DoZoom(float zoomFactor, WindowState state, Vector2 refRange, float focalTime) { const float kMinRange = 0.05f; // matches zoomable area. var s = zoomFactor; var t = focalTime; if (s <= 0) { return; } var x = (refRange.x + t * (s - 1)) / s; var y = (refRange.y + t * (s - 1)) / s; // don't set it if we reach the limit or panning happens if (Math.Abs(x - y) > kMinRange) { // Zoomable area does not protect 100% against crazy values state.SetTimeAreaShownRange(Math.Max(x, 0), Math.Min(y, WindowState.kMaxShownTime)); } }