From 2a7b2d9554ccf0bed1ab616b71550d1e7395e3fe Mon Sep 17 00:00:00 2001 From: Sj-Si Date: Fri, 31 May 2024 09:32:34 -0400 Subject: [PATCH] Update setting for tree expansion depth with more intuitive options. --- modules/shared_options.py | 2 +- modules/ui_extra_networks.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/shared_options.py b/modules/shared_options.py index 389a52326..67d5bed45 100644 --- a/modules/shared_options.py +++ b/modules/shared_options.py @@ -253,7 +253,7 @@ options_templates.update(options_section(('extra_networks', "Extra Networks", "s "extra_networks_show_hidden_directories_buttons": OptionInfo(False, "Show buttons for hidden directories in the directory and tree views.").info("a directory is hidden if its name starts with a period (\".\").").needs_reload_ui(), "extra_networks_show_hidden_models_cards": OptionInfo("Never", "Show cards for models in hidden directories", gr.Radio, {"choices": ["Always", "When searched", "Never"]}).info("\"When searched\" will only show cards when the search string has 4 characters or more and the search string matches either the model name or the hidden directory name (or any of its subdirectories).").needs_reload_ui(), "extra_networks_show_hidden_models_in_tree_view": OptionInfo(False, "Show entries for models inside hidden directories in the tree view.").info("This option only applies if the \"Show buttons for hidden directories\" option is enabled.").needs_reload_ui(), - "extra_networks_tree_view_expand_depth_default": OptionInfo(1, "Expand the tree view to this folder depth by default.").needs_reload_ui(), + "extra_networks_tree_view_expand_depth_default": OptionInfo(0, "Expand all directories in the tree view up to this depth by default.").info("0 collapses all, -1 expands all.").needs_reload_ui(), "extra_networks_directory_filter_click_behavior": OptionInfo("Click", "Filter directory recursively left mouse button action.", gr.Radio, {"choices": ["Click", "Long Press"]}).info("Sets the default left mouse button action required to filter a directory recursively (show children in all subdirectories) vs filtering to only show direct children of the selected directory."), "extra_networks_default_multiplier": OptionInfo(1.0, "Default multiplier for extra networks", gr.Slider, {"minimum": 0.0, "maximum": 2.0, "step": 0.01}), "extra_networks_card_width": OptionInfo(0, "Card width for Extra Networks").info("in pixels"), diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index 6205195bc..2e548ec59 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -624,11 +624,17 @@ class ExtraNetworksPage: tree_item = TreeListItem(node.id, "") - if node.depth <= expand_depth: + if expand_depth < 0: tree_item.expanded = True - - if node.depth <= expand_depth + 1: tree_item.visible = True + else: + # Expand directories. + if node.depth + 1 <= expand_depth: + tree_item.expanded = True + + # Children of expanded depth need to be visible. + if node.depth + 1 <= expand_depth + 1: + tree_item.visible = True tree_item.node = node parent_id = None