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 bool HandleShortcut(WindowState state, Event evt, T item) { T[] items = { item }; foreach (ItemAction <T> action in actions) { var attr = action.GetType().GetCustomAttributes(typeof(ShortcutAttribute), true); foreach (ShortcutAttribute shortcut in attr) { if (shortcut.MatchesEvent(evt)) { if (s_ShowActionTriggeredByShortcut) { Debug.Log(action.GetType().Name); } if (!IsActionActiveInMode(action, TimelineWindow.instance.currentMode.mode)) { return(false); } var result = action.Execute(state, items); state.Refresh(); state.Evaluate(); return(result); } } } return(false); }
protected override bool MouseUp(Event evt, WindowState state) { if (!m_Dragged) { var item = PickerUtils.TopmostPickedItem() as ISelectable; if (item == null) { return(false); } if (!item.IsSelected()) { return(false); } // Re-selecting an item part of a multi-selection should only keep this item selected. if (SelectionManager.Count() > 1 && ItemSelection.CanClearSelection(evt)) { SelectionManager.Clear(); item.Select(); return(true); } if (m_CycleMarkersPending) { m_CycleMarkersPending = false; TimelineMarkerClusterGUI.CycleMarkers(); return(true); } return(false); } m_TimeAreaAutoPanner = null; DropItems(); m_SnapEngine = null; m_MoveItemHandler = null; state.Evaluate(); state.RemoveCaptured(this); m_Dragged = false; TimelineCursors.ClearCursor(); return(true); }
protected override bool MouseDrag(Event evt, WindowState state) { if (state.editSequence.isReadOnly) { return(false); } // case 1099285 - ctrl-click can cause no clips to be selected var selectedItemsGUI = SelectionManager.SelectedItems(); if (!selectedItemsGUI.Any()) { m_Dragged = false; return(false); } const float hDeadZone = 5.0f; const float vDeadZone = 5.0f; bool vDone = m_VerticalMovementDone || Math.Abs(evt.mousePosition.y - m_MouseDownPosition.y) > vDeadZone; bool hDone = m_HorizontalMovementDone || Math.Abs(evt.mousePosition.x - m_MouseDownPosition.x) > hDeadZone; m_CycleMarkersPending = false; if (!m_Dragged) { var canStartMove = vDone || hDone; if (canStartMove) { state.AddCaptured(this); m_Dragged = true; var referenceTrack = GetTrackDropTargetAt(state, m_MouseDownPosition); foreach (var item in selectedItemsGUI) { item.gui.StartDrag(); } m_MoveItemHandler = new MoveItemHandler(state); m_MoveItemHandler.Grab(selectedItemsGUI, referenceTrack, m_MouseDownPosition); m_SnapEngine = new SnapEngine(m_MoveItemHandler, m_MoveItemHandler, ManipulateEdges.Both, state, m_MouseDownPosition); m_TimeAreaAutoPanner = new TimeAreaAutoPanner(state); } } if (!m_VerticalMovementDone) { m_VerticalMovementDone = vDone; if (m_VerticalMovementDone) { m_MoveItemHandler.OnTrackDetach(); } } if (!m_HorizontalMovementDone) { m_HorizontalMovementDone = hDone; } if (m_Dragged) { if (m_HorizontalMovementDone) { m_SnapEngine.Snap(evt.mousePosition, evt.modifiers); } if (m_VerticalMovementDone) { var track = GetTrackDropTargetAt(state, evt.mousePosition); m_MoveItemHandler.UpdateTrackTarget(track); } state.Evaluate(); } return(true); }