Ejemplo n.º 1
0
    static void OnProjectWindowItemOnGUI(string guid, Rect selectionRect)
    {
        string noteId = guid;

        bool isHoldingRequiredKeys = (Event.current.modifiers & EditorNotesSettings.MODIFIER_KEY) != EventModifiers.None;

        if (isHoldingRequiredKeys)                                   // user pressed the correct key
        {
            if (selectionRect.Contains(Event.current.mousePosition)) // we're drawing the item that the user is pointing on
            {
                // _________________________________________ Begin / End note _________________________________________ //
                if (!EditorNotesViewData.IsEditingNote)
                {
                    s_noteId.Set(noteId);

                    if (s_noteId.ClearDirty())
                    {
                        if (!string.IsNullOrEmpty(s_noteId.GetPrevious()))
                        {
                            OnEndNote(s_noteId.GetPrevious());
                        }

                        OnBeginNote(s_noteId.Get());
                    }
                }


                s_lastDrawTime = EditorApplication.timeSinceStartup;
            }
        }
        else if (CanEndNoteAndClose())
        {
            EndNoteAndClose();
        }


        // _________________________________________ Draw _________________________________________ //
        if (s_noteId.Get() == noteId)
        {
            EditorNotesDrawer.DrawNote(selectionRect);
            EditorNotesDrawer.DrawSelectionBorder(selectionRect);

            if (!EditorNotesViewData.IsEditingNote)
            {
                EditorNotesDrawer.DrawEditNoteButton(selectionRect);
            }
        }

        if (EditorNotesDatabase.Instance.ContainsNote(noteId))
        {
            EditorNotesDrawer.DrawNoteIcon(selectionRect);
        }



        s_requestRepaint = isHoldingRequiredKeys || EditorNotesViewData.IsEditingNote; // needed for responsive UI
    }