Example #1
0
        private void OnGUIDirectory(DirectoryView directoryView)
        {
            this.indentLevel++;

            EditorGUILayout.BeginHorizontal();

            ////===========  Foldout Toggle (change label/field width + wacky indent/spacing  ======================
            this.ManualGUIIndent();

            GUIStyle g = new GUIStyle(EditorStyles.foldout);

            g.fixedWidth = 16.0f;

            var previousFieldWidth = EditorGUIUtility.fieldWidth;

            EditorGUIUtility.fieldWidth = 16.0f;
            directoryView.IsExpanded    = EditorGUILayout.Foldout(directoryView.IsExpanded, string.Empty, g);
            EditorGUIUtility.fieldWidth = previousFieldWidth;

            EditorGUI.showMixedValue = directoryView.IsPartiallySelected;
            var isDirectoryIgnored  = directoryView.IsSelected;
            var wantsToIgnoreFolder = EditorGUILayout.ToggleLeft(directoryView.Label, isDirectoryIgnored);

            if (wantsToIgnoreFolder != isDirectoryIgnored)
            {
                directoryView.ToggleSelectAll();
            }

            EditorGUI.showMixedValue = false;

            ////====================================================

            EditorGUILayout.EndHorizontal();

            if (directoryView.IsExpanded)
            {
                foreach (var subDirectory in directoryView.SubDirectories)
                {
                    this.OnGUIDirectory(subDirectory);
                }

                this.indentLevel += 2;
                foreach (var file in directoryView.Files)
                {
                    EditorGUILayout.BeginHorizontal();
                    this.ManualGUIIndent();
                    var labelStyle = new GUIStyle(EditorStyles.label);
                    file.IsSelected = EditorGUILayout.ToggleLeft(file.Label, file.IsSelected, labelStyle);
                    EditorGUILayout.EndHorizontal();
                }

                this.indentLevel -= 2;
            }

            this.indentLevel--;
        }
        //// ====================================================================================================================

        /// <summary>
        /// Initializes a new instance of the <see cref="FileTreeView"/> class., starting from the supplied path
        /// </summary>
        /// <param name="rootPath">A UniversalPath to the root of the FileTreeView to be created</param>
        internal FileTreeView(UniversalPath rootPath)
        {
            this.root            = new DirectoryView(rootPath);
            this.root.IsExpanded = true;
        }