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); } }
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); }
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); } } }