Exemplo n.º 1
0
    static void Init()
    {
        // Get existing open window or if none, make a new one:
        DocBrowser window = (DocBrowser)EditorWindow.GetWindow(typeof(DocBrowser));

        window.minSize = new Vector2(700, 400);
    }
Exemplo n.º 2
0
    void ToolbarGUI()
    {
        GUILayout.Space(3);
        EditorGUILayout.BeginHorizontal(GUILayout.Height(23));

        GUILayout.Space(1);

        var oldFilter = filter;

        filter = (MemberFilter)EditorGUILayout.EnumPopup(filter, GUILayout.ExpandWidth(false));
        if (oldFilter != filter)
        {
            DocBrowser.LoadFilteredList(m_Browser.docProject, this, filter, search);
        }

        EditorGUILayout.BeginVertical();
        GUILayout.Space(4);
        EditorGUILayout.BeginHorizontal();
        var oldFilterSearch = search;

        search = EditorGUILayout.TextField(search, DocBrowser.styles.searchField, GUILayout.ExpandWidth(true));
        if (GUILayout.Button(string.Empty, DocBrowser.styles.searchFieldCancelButton))
        {
            search = string.Empty;
            EditorGUIUtility.keyboardControl = 0;
        }
        if (oldFilterSearch != search)
        {
            DocBrowser.LoadFilteredList(m_Browser.docProject, this, filter, search);
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        EditorGUILayout.EndHorizontal();
    }
Exemplo n.º 3
0
        private void DocList_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selected = DocList.SelectedItems[0];

            if (selected == null)
            {
                return;
            }

            DocBrowser.Navigate(Settings.HelpDirectory + selected + ".html");
        }
Exemplo n.º 4
0
    void SignatureGUI(MemberSession member, int sectionIndex, List <string> signatureList, int signatureIndex, bool readOnly)
    {
        string         sig      = signatureList[signatureIndex];
        SignatureEntry sigEntry = member.Member.GetSignature(sig, true);

        bool edit = !readOnly && !m_Browser.translating && member.Member.MultipleSignaturesPossible;

        EditorGUI.BeginChangeCheck();

        GUILayout.BeginHorizontal();

        if (edit)
        {
            GUILayout.Space(4);
            Rect rect = GUILayoutUtility.GetRect(14, 14, GUILayout.ExpandWidth(false));
            rect.y += 4;

            DocBrowser.DragHandle(rect, typeof(SignatureEntry), signatureList, signatureIndex, DocBrowser.styles.dragHandle);

            if (!sigEntry.InAsm || sigEntry.Asm.Private)
            {
                GUILayout.Space(4);
                rect    = GUILayoutUtility.GetRect(14, 14, GUILayout.ExpandWidth(false));
                rect.y += 4;
                if (MiniButton(rect, DocBrowser.styles.iconRemove))
                {
                    signatureList.RemoveAt(signatureIndex);
                }
            }
        }

        string sigString = m_Browser.ShowRawNames ? sigEntry.Name : sigEntry.FormattedHTML;

        if (sigEntry.InAsm && sigEntry.Asm.Private)
        {
            sigString = "<b><color=red>private</color></b> " + sigString;
        }

        GUILayout.Label(sigString, DocBrowser.styles.signature);

        GUILayout.EndHorizontal();

        // Handle dragging
        Rect dragTargetRect = GUILayoutUtility.GetRect(10, 0);

        dragTargetRect.y     -= 3;
        dragTargetRect.height = 14;
        DocBrowser.DragTarget(dragTargetRect, typeof(SignatureEntry), signatureList, signatureIndex + 1);

        if (EditorGUI.EndChangeCheck())
        {
            member.OnModelEdited(true);
        }
    }
Exemplo n.º 5
0
    private static void CancelAcceptButtons(DocBrowser browser, MemberEditor editor)
    {
        if (GUILayout.Button("Cancel", EditorStyles.toolbarButton))
        {
            browser.ShowMatchList = false;
        }

        EditorGUI.BeginDisabledGroup(editor == null || editor.m_OrphanDocItem == editor.m_Item || editor.m_OrphanDocItem == null);
        if (GUILayout.Button("Save Match", EditorStyles.toolbarButton))
        {
            editor.Save();
        }
        EditorGUI.EndDisabledGroup();
    }
Exemplo n.º 6
0
    void ParametersAndReturnGUI(MemberSession member, int sectionIndex, bool readOnly)
    {
        MemberSubSection section = member.Model.SubSections[sectionIndex];

        // Parameters
        if (section.Parameters.Count > 0)
        {
            GUILayout.Label("Parameters", DocBrowser.styles.docSectionHeader);

            // Handle dragging parameter into first slot
            Rect dragTargetRect = GUILayoutUtility.GetRect(10, 0);
            dragTargetRect.y     -= 6;
            dragTargetRect.height = 14;
            DocBrowser.DragTarget(dragTargetRect, typeof(ParameterWithDoc), section.Parameters, 0);

            ParameterWithDoc paramToRemove = null;
            for (int i = 0; i < section.Parameters.Count; i++)
            {
                ParameterWithDoc p     = section.Parameters[i];
                string           label = "<b>" + p.Name + " : </b>" + (p.HasAsm ? Extensions.GetNiceName(p.TypeString) : "?");
                bool             remove;
                p.Doc = ParamOrReturnGUI(p.HasAsm, p.HasDoc, label, p.Doc, member.Language, readOnly, out remove, section.Parameters, i);
                if (remove)
                {
                    paramToRemove = p;
                }
            }
            if (paramToRemove != null)
            {
                section.Parameters.Remove(paramToRemove);
            }
        }

        // Returns
        if (section.ReturnDoc != null)
        {
            GUILayout.Label("Returns", DocBrowser.styles.docSectionHeader);
            ReturnWithDoc p     = section.ReturnDoc;
            string        label = (p.HasAsm ? Extensions.GetNiceName(p.ReturnType) : "?");
            bool          remove;
            p.Doc = ParamOrReturnGUI(p.HasAsm, p.HasDoc, label, p.Doc, member.Language, readOnly, out remove);
            if (remove)
            {
                section.ReturnDoc = null;
            }
        }

        EditorGUILayout.Space();
    }
Exemplo n.º 7
0
    public static void NoEditorGUI(DocBrowser browser)
    {
        // Member header
        GUILayout.Label("No member selected", DocBrowser.styles.docHeader);

        EditorGUILayout.BeginVertical(DocBrowser.styles.frameWithMargin, GUILayout.ExpandWidth(true));

        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
        GUILayout.FlexibleSpace();
        if (browser.ShowMatchList)
        {
            CancelAcceptButtons(browser, null);
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.EndVertical();
    }
Exemplo n.º 8
0
 public MemberList(DocBrowser browser)
 {
     m_Browser = browser;
 }
Exemplo n.º 9
0
    string ParamOrReturnGUI(bool hasAsm, bool hasDoc, string label, string text, LanguageUtil.ELanguage language, bool readOnly, out bool remove, IList list = null, int index = -1)
    {
        remove = false;

        EditorGUILayout.BeginHorizontal();

        bool edit = !m_Browser.translating && !readOnly;

        bool hasSource, hasDest;

        if (m_Browser.translating)
        {
            hasSource = true;
            hasDest   = !text.StartsWith(sTodoText);
        }
        else
        {
            hasSource = hasAsm;
            hasDest   = hasDoc;
        }

        Rect labelRect = GUILayoutUtility.GetRect(160 + (edit ? 18 : 0), 16, GUILayout.ExpandWidth(false));

        labelRect.xMin += 4;
        labelRect.y    += 2;

        if (edit)
        {
            // Drag handle
            Rect dragRect = new Rect(labelRect.x, labelRect.y + 2, 14, 14);
            if (list != null)
            {
                DocBrowser.DragHandle(dragRect, typeof(ParameterWithDoc), list, index, DocBrowser.styles.dragHandle);
            }
            labelRect.xMin += 14 + 4;

            // remove button
            if (!hasSource)
            {
                Rect buttonRect = new Rect(labelRect.x, labelRect.y + 2, 14, 14);
                if (MiniButton(buttonRect, DocBrowser.styles.iconRemove))
                {
                    remove = true;
                }
                labelRect.xMin += 14;
            }
        }

        // Label
        GUI.Label(labelRect, label, DocBrowser.styles.paramLabel);

        // Text field
        if (!readOnly)
        {
            GUI.backgroundColor = GetColor(hasSource, hasDest);
        }
        text = TextArea(text, DocBrowser.styles.param, readOnly, language);
        GUI.backgroundColor = Color.white;

        EditorGUILayout.EndHorizontal();

        // Handle dragging
        if (list != null)
        {
            Rect dragTargetRect = GUILayoutUtility.GetRect(10, 0);
            dragTargetRect.y     -= 6;
            dragTargetRect.height = 14;
            DocBrowser.DragTarget(dragTargetRect, typeof(ParameterWithDoc), list, index + 1);
        }

        return(text);
    }
Exemplo n.º 10
0
 public MemberEditor(DocBrowser browser, MemberItem docItem, MemberItem asmItem)
 {
     this.m_Browser = browser;
     Init(docItem, asmItem);
 }
Exemplo n.º 11
0
    void SectionHeaderGUI(MemberSession member, int sectionIndex, bool readOnly)
    {
        MemberSubSection section = sectionIndex < 0 ? null : member.Model.SubSections[sectionIndex];

        string headerText;

        if (sectionIndex >= 0)
        {
            headerText = "Section " + (sectionIndex + 1) + " of " + member.Model.SubSections.Count;
        }
        else
        {
            headerText = "New Section";
        }

        EditorGUI.BeginChangeCheck();

        if (EditGrouping && !readOnly)
        {
            // Handle dragging of section
            Rect dragTargetRect = GUILayoutUtility.GetRect(10, 0);
            dragTargetRect.y     -= 4;
            dragTargetRect.height = 16;
            DocBrowser.DragTarget(dragTargetRect, typeof(MemberSubSection), member.Model.SubSections, sectionIndex >= 0 ? sectionIndex : member.Model.SubSections.Count);

            GUILayout.BeginHorizontal(GUILayout.Height(25));

            GUILayout.Space(4);
            Rect rect = GUILayoutUtility.GetRect(14, 14, GUILayout.ExpandWidth(false));
            rect.y += 11;

            if (sectionIndex >= 0)
            {
                if (member.Model.SubSections.Count > 1)
                {
                    DocBrowser.DragHandle(rect, typeof(MemberSubSection), member.Model.SubSections, sectionIndex, DocBrowser.styles.dragHandle);

                    if (section.SignatureList.Count == 0)
                    {
                        GUILayout.Space(4);
                        rect    = GUILayoutUtility.GetRect(14, 14, GUILayout.ExpandWidth(false));
                        rect.y += 11;
                        if (MiniButton(rect, DocBrowser.styles.iconRemove))
                        {
                            member.Model.SubSections.RemoveAt(sectionIndex);
                        }
                    }
                }
            }
            else
            {
                if (MiniButton(rect, DocBrowser.styles.iconAdd))
                {
                    member.Model.SubSections.Add(new MemberSubSection(sTodoText));
                }
            }

            GUILayout.Label(headerText, DocBrowser.styles.docSectionHeader);
            GUILayout.EndHorizontal();
        }
        else
        {
            GUILayout.Label(headerText, DocBrowser.styles.docSectionHeader);
        }

        if (sectionIndex >= 0)
        {
            // Handle dragging of signature
            Rect dragTargetRect = GUILayoutUtility.GetRect(10, 0);
            dragTargetRect.y     -= 3;
            dragTargetRect.height = 14;
            DocBrowser.DragTarget(dragTargetRect, typeof(SignatureEntry), section.SignatureList, 0);
        }

        if (EditorGUI.EndChangeCheck())
        {
            member.OnModelEdited(true);
        }

        if (EditGrouping && section != null && section.SignatureList.Count == 0 && member.Member.MultipleSignaturesPossible && member.Model.SubSections.Count > 1)
        {
            if ((string.IsNullOrEmpty(section.Summary) || section.Summary == sTodoText) && section.Parameters.Count == 0 && section.ReturnDoc == null)
            {
                GUILayout.Label("Section has no documentation. It can safely be deleted.", DocBrowser.styles.docSectionMessage);
            }
            else
            {
                GUILayout.Label("Section has documentation. (Exit 'Edit Grouping' mode to see it.) Deleting this section will delete its docs too.", DocBrowser.styles.docSectionMessageWarning);
            }
        }
        if (section != null && section.SignatureList.Count > 0)
        {
            IEnumerable <SignatureEntry> asmEntries = section.SignatureList.Select(e => member.Member.GetSignature(e, true));
            asmEntries = asmEntries.Where(e => e.InAsm);
            IEnumerable <string> returnTypes = asmEntries.Select(e => e.Asm.ReturnType);
            returnTypes = returnTypes.Distinct();
            if (returnTypes.Count() > 1)
            {
                GUILayout.Label("Section has signatures with multiple different return types: " + string.Join(", ", returnTypes.ToArray()) + ".", DocBrowser.styles.docSectionMessageWarning);
            }
        }
    }
Exemplo n.º 12
0
 public MemberEditor(DocBrowser browser, MemberItem item)
 {
     this.m_Browser = browser;
     Init(item);
 }
Exemplo n.º 13
0
    private void DocGUI()
    {
        // Member header
        string header = EditMember.Member.ItemName;

        if (m_Browser.ShowMatchList)
        {
            if (m_OrphanDocItem != null)
            {
                header = "Match Docs for " + m_OrphanDocItem.ItemName + " to API " + m_Item.ItemName + " ?";
            }
            else
            {
                header = "Match Docs for " + m_Item.ItemName + " to API [No API Item Selected] ?";
            }
        }
        GUILayout.Label(header, DocBrowser.styles.docHeader);

        EditorGUILayout.BeginVertical(DocBrowser.styles.frameWithMargin);

        // Doc toolbar
        ToolbarGUI();

        if (EditMember != null && EditMember.Loaded)
        {
            float width = m_Browser.position.width;
            if (m_Browser.m_ShowList)
            {
                width -= DocBrowser.kListWidth + DocBrowser.styles.dividerSpace + 1;
            }
            if (m_Browser.ShowMatchList)
            {
                width -= DocBrowser.kListWidth + DocBrowser.styles.dividerSpace + 1;
            }
            if (m_Browser.translating)
            {
                if (m_ShowMerge)
                {
                    width = (width - 2 * (DocBrowser.styles.dividerSpace + 1)) / 3;
                }
                else
                {
                    width = (width - (DocBrowser.styles.dividerSpace + 1)) / 2;
                }
            }

            EditorGUILayout.BeginHorizontal();

            // English Doc scrollview
            DocColumnGUI(m_EnglishMember, m_Browser.translating, ref m_DocScroll, width, "" + m_EnglishMember.Language);

            if (m_Browser.translating)
            {
                GUILayout.Space(DocBrowser.styles.dividerSpace + 1);

                // Translated Doc scrollview
                DocColumnGUI(m_TranslatedMember, false, ref m_TranslateScroll, width, m_TranslatedMember.Language + (m_ShowMerge ? " (Merged)" : ""));

                if (m_ShowMerge)
                {
                    GUILayout.Space(DocBrowser.styles.dividerSpace + 1);

                    // Translated Doc scrollview
                    DocColumnGUI(m_TranslatedMemberOld, true, ref m_TranslateOldScroll, width, "" + m_TranslatedMemberOld.Language + " (Old)");
                }
            }

            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.EndVertical();

        DocBrowser.DragEnd();
    }