예제 #1
0
        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);
        }
예제 #2
0
 private void DrawHighlightButton(NoteList noteList)
 {
     if (GUILayout.Button(highlightButtonContent, SmallButtonStyle, smallButtonWidth, smallButtonHeight))
     {
         EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath <TextAsset>(
                                         string.Format("Assets/{0}", noteList.RelativePath)));
     }
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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;
                }
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
            }
        }