private bool IsParentHierarchyExpanded(NoteList noteList, int maxDepth) { if (maxDepth == 0) { return(true); } bool isExpanded = false; for (int depth = 0; depth < maxDepth; depth++) { if (pathExpansionStates.TryGetValue(noteList.FoldoutInfos[depth].Hash, out isExpanded)) { if (!isExpanded) { return(false); } } else { pathExpansionStates[noteList.FoldoutInfos[depth].Hash] = defaultExpansionState; return(defaultExpansionState); } } return(isExpanded); }
private void DrawHighlightButton(NoteList noteList) { if (GUILayout.Button(highlightButtonContent, SmallButtonStyle, smallButtonWidth, smallButtonHeight)) { EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath <TextAsset>( string.Format("Assets/{0}", noteList.RelativePath))); } }
private void Parse(string filePath) { filePath = filePath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); string relativePath = GetRelativePath(filePath); if (File.Exists(filePath)) { noteLists.SetOrAddSorted(noteList => noteList.RelativePath == relativePath, NoteList.Parse(filePath, relativePath, tagList.Tags)); } else { noteLists.TryRemove(noteList => noteList.RelativePath == relativePath); } }
private void DrawNoteLists() { using (new ScrollViewScope(ref mainAreaScrollPosition)) { NoteList previousNoteList = null; foreach (NoteList noteList in noteLists) { if (noteList.Notes.Count == 0) { continue; } DrawNoteList(noteList, previousNoteList); previousNoteList = noteList; } } }
public void Draw(NoteList noteList, Tag tag) { if (!tag.IsEnabled) { return; } using (new LayoutGroup.Scope(LayoutGroup.Direction.Horizontal, GUI.skin.box)) { if (GUILayout.Button(lineButtonContent, lineButtonWidth)) { noteList.OpenScript(line); } tag.Draw(); GUILayout.Label(text, TextStyle); } }
private int GetMinHierarchyDepth(NoteList noteList, NoteList previousNoteList) { if (previousNoteList == null) { return(0); } int minHierarchyDepth = 0; for (int i = 0; i < noteList.FoldoutInfos.Length; i++) { if (previousNoteList.FoldoutInfos.Length <= i || noteList.FoldoutInfos[i].Hash != previousNoteList.FoldoutInfos[i].Hash) { break; } minHierarchyDepth++; } return(minHierarchyDepth); }
private bool DrawFoldout(NoteList noteList, int depth) { bool isExpanded; if (!pathExpansionStates.TryGetValue(noteList.FoldoutInfos[depth].Hash, out isExpanded)) { isExpanded = defaultExpansionState; } using (new EditorGUILayout.HorizontalScope()) { GUILayout.Space(indentWith * depth); GUIContent label = noteList.GetLabel(isExpanded, depth); isExpanded = EditorGUILayout.Foldout(isExpanded, label, true); if (depth == noteList.FoldoutInfos.Length - 1) { DrawHighlightButton(noteList); } DrawFilterButton(label); } pathExpansionStates[noteList.FoldoutInfos[depth].Hash] = isExpanded; return(isExpanded); }
private void DrawNoteList(NoteList noteList, NoteList previousNoteList) { int depth = GetMinHierarchyDepth(noteList, previousNoteList); bool isExpanded = IsParentHierarchyExpanded(noteList, depth); if (!isExpanded) { return; } for (int i = depth; i < noteList.FoldoutInfos.Length; i++) { isExpanded = DrawFoldout(noteList, i); if (!isExpanded) { break; } } if (isExpanded) { noteList.Draw(menuBar.SearchField.LowerText, noteList.FoldoutInfos.Length, tagList); } }