Update setting for tree expansion depth with more intuitive options.

This commit is contained in:
Sj-Si 2024-05-31 09:32:34 -04:00
parent 478c69573a
commit 2a7b2d9554
2 changed files with 10 additions and 4 deletions

View File

@ -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"),

View File

@ -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