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(); }
protected override bool MouseWheel(Event evt, WindowState state) { if (Math.Abs(evt.delta.x) < 1e-5 || Math.Abs(evt.delta.x) <= Math.Abs(evt.delta.y)) { return(false); } TimelineZoomManipulator.InvalidateWheelZoom(); var panEvent = new Event(evt); panEvent.delta = new Vector2(panEvent.delta.x * k_MaxPanSpeed * -1.0f, 0.0f); return(Pan(panEvent, state)); }
public override void Init(IControl parent) { parent.MouseDown += delegate(object target, Event evt, TimelineWindow.TimelineState state) { TimelineZoomManipulator.s_LastMouseDownPosition = evt.get_mousePosition().x; TimelineZoomManipulator.s_LastMouseDownTime = state.PixelToTime(TimelineZoomManipulator.s_LastMouseDownPosition); return(base.IgnoreEvent()); }; parent.MouseWheel += delegate(object target, Event evt, TimelineWindow.TimelineState state) { bool result; if (evt.get_delta().y == 0f) { result = base.IgnoreEvent(); } else { if (this.m_LastMouseMoveX < 0f || Mathf.Abs(this.m_LastMouseMoveX - evt.get_mousePosition().x) > 1f) { this.m_LastMouseMoveX = evt.get_mousePosition().x; this.m_FocalTime = state.PixelToTime(this.m_LastMouseMoveX); } float num = Event.get_current().get_delta().x + Event.get_current().get_delta().y; num = -num; TimelineZoomManipulator.DoZoom(num, state, this.m_FocalTime, evt.get_mousePosition().x); result = base.ConsumeEvent(); } return(result); }; parent.MouseDrag += delegate(object target, Event evt, TimelineWindow.TimelineState state) { bool result; if (evt.get_modifiers() == 4 && evt.get_button() == 1) { float num = Event.get_current().get_delta().x + Event.get_current().get_delta().y; num = -num; TimelineZoomManipulator.DoZoom(num, state, TimelineZoomManipulator.s_LastMouseDownTime, TimelineZoomManipulator.s_LastMouseDownPosition); result = base.ConsumeEvent(); } else { result = base.IgnoreEvent(); } return(result); }; }
public static void FrameRange(float startTime, float endTime) { if (startTime > endTime) { return; } var halfDuration = endTime - Math.Max(0.0f, startTime); if (halfDuration > 0.0f) { TimelineEditor.visibleTimeRange = new Vector2(Mathf.Max(0.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 = TimelineEditor.visibleTimeRange.y - TimelineEditor.visibleTimeRange.x; TimelineEditor.visibleTimeRange = new Vector2(startTime - currentRange / 2, startTime + currentRange / 2); } TimelineZoomManipulator.InvalidateWheelZoom(); TimelineEditor.Refresh(RefreshReason.SceneNeedsUpdate); }
public override bool Execute(TimelineWindow.TimelineState state) { TimelineZoomManipulator.DoZoom(-2f, state); return(true); }
internal static void DoZoom(float zoomFactor, TimelineWindow.TimelineState state) { TimelineZoomManipulator.DoZoom(zoomFactor, state, TimelineZoomManipulator.s_LastMouseDownTime, TimelineZoomManipulator.s_LastMouseDownPosition); }