Ejemplo n.º 1
0
        private void GenerateContextMenu
        (
            Event current,
            Rect rowRect,
            string fullPath,
            IErrorDetails error,
            string projectRelativePath,
            ErrorTypeGUI errorTypeGUI
        )
        {
            var menuOpenClick = current.type == EventType.ContextClick ||
                                current.type == EventType.MouseDown;

            if (menuOpenClick && rowRect.Contains(current.mousePosition))
            {
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent($"Reveal in {GUIUtil.FileManagerName}"), false, ShowInFileManager, fullPath);
                menu.AddItem(new GUIContent("Highlight in project"), false, HighlightInEditor, projectRelativePath);
                menu.AddItem(new GUIContent("Copy path to clipboard/Repository relative"), false, CopyFilenameToClipboard, error.FilePosixPath);
                menu.AddItem(new GUIContent("Copy path to clipboard/Project relative"), false, CopyFilenameToClipboard, projectRelativePath);
                menu.AddItem(new GUIContent("Copy path to clipboard/Full"), false, CopyFilenameToClipboard, fullPath);
                menu.AddItem(new GUIContent($"How to fix..."), false, LearnMoreAboutError, errorTypeGUI.HelpUri);
                menu.ShowAsContext();

                current.Use();
            }
        }
Ejemplo n.º 2
0
        public void Generate
        (
            IErrorDetails error,
            ErrorTypeGUI errorTypeGUI,
            bool isOdd
        )
        {
            var backgroundStyle = isOdd
                ? _oddStyle.Get
                : _evenStyle.Get;

            EditorGUILayout.BeginHorizontal(backgroundStyle);

            var fullPath            = GetFullPathForError(error);
            var projectRelativePath = GetProjectPathForError(error, fullPath);

            GeneratePathGUI(projectRelativePath, _prevErrorProjectPath);
            GUILayout.FlexibleSpace();
            errorTypeGUI.Generate();

            EditorGUILayout.EndHorizontal();

            var rowRect      = GUILayoutUtility.GetLastRect();
            var currentEvent = Event.current;

            GenerateHoverHighlight(currentEvent, rowRect);

            GenerateContextMenu(
                currentEvent,
                rowRect,
                fullPath,
                error,
                projectRelativePath,
                errorTypeGUI
                );

            _prevErrorProjectPath = projectRelativePath;
        }