コード例 #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
ファイル: Note.cs プロジェクト: RobertClassen/NoteFinder
        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);
            }
        }