private void AddMark(object m) { MarkAction t = (MarkAction)m; float time = TimelineWindow.inst.PiexlToTime(t.posX); EditorFactory.MakeMarker(t.type, time, track); TimelineWindow.inst.timeline.RecalcuteDuration(); }
private void TrackContexMenu(Event e) { pm = new GenericMenu(); if (TimelineWindow.inst.tree.AnySelect()) { pm.AddItem(_unselect, false, UnSelectAll, false); pm.AddDisabledItem(_select); } else { pm.AddItem(_select, false, UnSelectAll, true); pm.AddDisabledItem(_unselect); } pm.AddSeparator(""); if (allowClip && !locked) { pm.AddItem(_addclip, false, AddClip, e.mousePosition); if (HitClip(e)) { pm.AddItem(delete, false, DeleteClip, e.mousePosition); } else { pm.AddDisabledItem(delete, false); } } else { pm.AddDisabledItem(_addclip, false); pm.AddDisabledItem(delete, false); } pm.AddItem(EditorGUIUtility.TrTextContent("Delete Track\t #t"), false, DeleteTrack); if (track.mute) { pm.AddItem(EditorGUIUtility.TrTextContent("UnMute Track \t "), false, () => SetTrackFlag(TrackMode.Mute, false)); } else { pm.AddItem(EditorGUIUtility.TrTextContent("Mute Track \t"), false, () => SetTrackFlag(TrackMode.Mute, true)); } if (locked) { pm.AddItem(EditorGUIUtility.TrTextContent("UnLock Track \t #l"), false, () => SetTrackFlag(TrackMode.Lock, false)); } else { pm.AddItem(EditorGUIUtility.TrTextContent("Lock Track \t #l"), false, () => SetTrackFlag(TrackMode.Lock, true)); } if (@select) { pm.AddItem(EditorGUIUtility.TrTextContent("UnSelect Track \t #s"), false, SelectTrack, false); } else { pm.AddItem(EditorGUIUtility.TrTextContent("Select Track \t #s"), false, SelectTrack, true); } if (track.cloneable) { pm.AddItem(copy, false, CopyTrack); } else { pm.AddDisabledItem(copy, false); } if (clipboardTrack != null) { pm.AddItem(paste, false, PasteTrack); } else { pm.AddDisabledItem(paste, false); } if (actions != null) { pm.AddSeparator(""); for (int i = 0; i < actions.Count; i++) { var at = actions[i]; if (!locked) { pm.AddItem(EditorGUIUtility.TrTextContent(at.desc), at.@on, at.fun, at.arg); } } } pm.AddSeparator(""); var marks = TypeUtilities.GetBelongMarks(track.AssetType); for (int i = 0; i < marks.Count; i++) { var mark = marks[i]; string str = mark.ToString(); int idx = str.LastIndexOf('.'); str = str.Substring(idx + 1); var ct = EditorGUIUtility.TrTextContent("Add " + str); MarkAction action = new MarkAction() { type = mark, posX = e.mousePosition.x }; if (!locked) { pm.AddItem(ct, false, AddMark, action); } } pm.ShowAsContext(); e.Use(); }