public int[] getKeyFramesInGhostSelection(AMTakeData take, int startFrame, int endFrame, int track_id) { List <int> key_frames = new List <int>(); if (track_id <= -1) { return(key_frames.ToArray()); } foreach (AMKey key in take.getTrack(track_id).keys) { if (key.frame + ghost_selection_total_offset < startFrame) { continue; } if (key.frame + ghost_selection_total_offset > endFrame) { break; } if (isFrameInContextSelection(key.frame)) { key_frames.Add(key.frame + ghost_selection_total_offset); } } return(key_frames.ToArray()); }
public AMKey[] removeSelectedKeysFromTrack(AMTakeData take, AMITarget itarget, int track_id) { List <AMKey> dkeys = new List <AMKey>(); bool didDeleteKeys = false; AMTrack track = take.getTrack(track_id); for (int i = 0; i < track.keys.Count; i++) { if (!isFrameInContextSelection(track.keys[i].frame)) { continue; } dkeys.Add(track.keys[i]); track.keys.Remove(track.keys[i]); i--; didDeleteKeys = true; } if (didDeleteKeys) { track.updateCache(itarget); } return(dkeys.ToArray()); }
/*public AMKey[] getContextSelectionKeys() { * List<AMKey> keys = new List<AMKey>(); * foreach(AMKey key in getSelectedTrack().keys) { * for(int i=0;i<contextSelection.Count;i+=2) { * // if selection start frame > frame, break out of sorted list * if(contextSelection[i] > key.frame) break; * if(contextSelection[i] <= key.frame && contextSelection[i+1] >= key.frame) keys.Add(key); * } * } * return keys.ToArray(); * }*/ // offset context selection frames by an amount. can be positive or negative //returns keys that are to be deleted public AMKey[] offsetContextSelectionFramesBy(AMTakeData take, AMITarget itarget, int offset) { if (offset == 0) { return(new AMKey[0]); } if (contextSelection.Count <= 0) { return(new AMKey[0]); } List <AMKey> rkeys = new List <AMKey>(); List <AMKey> keysToDelete = new List <AMKey>(); foreach (int track_id in contextSelectionTracks) { bool shouldUpdateCache = false; AMTrack _track = take.getTrack(track_id); foreach (AMKey key in _track.keys) { for (int i = 0; i < contextSelection.Count; i += 2) { // move context selection if (contextSelection[i] <= key.frame && contextSelection[i + 1] >= key.frame) { // if there is already a key in the new frame position, mark for deletion bool keyToOverwriteInContextSelection = false; if (_track.hasKeyOnFrame(key.frame + offset)) { // check if the key is in the selection for (int j = 0; j < contextSelection.Count; j += 2) { if (contextSelection[j] <= (key.frame + offset) && contextSelection[j + 1] >= (key.frame + offset)) { keyToOverwriteInContextSelection = true; break; } } // if not key is not in selection, mark for deletion if (!keyToOverwriteInContextSelection) { keysToDelete.Add(_track.getKeyOnFrame(key.frame + offset)); } } key.frame += offset; if (!shouldUpdateCache) { shouldUpdateCache = true; } break; } } } // delete keys that were overwritten foreach (AMKey key in keysToDelete) { _track.keys.Remove(key); rkeys.Add(key); } keysToDelete.Clear(); // update cache if (shouldUpdateCache) { _track.updateCache(itarget); } } // update context selection for (int i = 0; i < contextSelection.Count; i++) { // move context selection contextSelection[i] += offset; } // clear ghost selection ghostSelection = new List <int>(); return(rkeys.ToArray()); }