예제 #1
0
        private void GenMenu(Event e)
        {
            GenericMenu gm    = new GenericMenu();
            var         marks = TypeUtilities.GetBelongMarks(AssetType.Marker);

            foreach (var mark in marks)
            {
                string str = mark.ToString();
                int    idx = str.LastIndexOf('.');
                str = str.Substring(idx + 1);
                var ct = EditorGUIUtility.TrTextContent("Add " + str);
                gm.AddItem(ct, false, AddRectMark, new MarkAction(mark, e.mousePosition.x));
            }
            gm.AddSeparator("");
            var m       = TrigerMark(e);
            var content = EditorGUIUtility.TrTextContent("Delete #d");

            if (m != null)
            {
                gm.AddItem(content, false, DeleteRectMark, m);
            }
            else
            {
                gm.AddDisabledItem(content, false);
            }
            gm.ShowAsContext();
            e.Use();
        }
예제 #2
0
        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();
        }