fix(gui): Ensure all tools are visible in Tool Preset Manager
This commit is contained in:
35
src/gui_2.py
35
src/gui_2.py
@@ -997,7 +997,7 @@ class App:
|
||||
try:
|
||||
if imgui.button("New Tool Preset", imgui.ImVec2(-1, 0)):
|
||||
self._editing_tool_preset_name = ""
|
||||
self._editing_tool_preset_categories = {}
|
||||
self._editing_tool_preset_categories = {cat: {} for cat in models.DEFAULT_TOOL_CATEGORIES}
|
||||
self._editing_tool_preset_scope = "project"
|
||||
self._selected_tool_preset_idx = -1
|
||||
if imgui.is_item_hovered():
|
||||
@@ -1011,7 +1011,9 @@ class App:
|
||||
self._selected_tool_preset_idx = i
|
||||
self._editing_tool_preset_name = name
|
||||
preset = self.controller.tool_presets[name]
|
||||
self._editing_tool_preset_categories = copy.deepcopy(preset.categories)
|
||||
self._editing_tool_preset_categories = {cat: {} for cat in models.DEFAULT_TOOL_CATEGORIES}
|
||||
for cat, tools in preset.categories.items():
|
||||
self._editing_tool_preset_categories[cat] = copy.deepcopy(tools)
|
||||
finally:
|
||||
imgui.end_child()
|
||||
|
||||
@@ -1040,22 +1042,31 @@ class App:
|
||||
imgui.text("Categories & Tools:")
|
||||
imgui.begin_child("tp_categories_scroll", imgui.ImVec2(0, -40), True)
|
||||
try:
|
||||
for cat_name, tools in self._editing_tool_preset_categories.items():
|
||||
for cat_name, default_tools in models.DEFAULT_TOOL_CATEGORIES.items():
|
||||
if imgui.tree_node(cat_name):
|
||||
for tool_name, config in tools.items():
|
||||
# config can be a string ("auto", "ask") or a dict {"mode": "auto"}
|
||||
if isinstance(config, dict):
|
||||
mode = config.get("mode", "auto")
|
||||
if cat_name not in self._editing_tool_preset_categories:
|
||||
self._editing_tool_preset_categories[cat_name] = {}
|
||||
current_cat_tools = self._editing_tool_preset_categories[cat_name]
|
||||
for tool_name in default_tools:
|
||||
# Determine current mode: disabled (not present), auto, or ask
|
||||
if tool_name not in current_cat_tools:
|
||||
mode = "disabled"
|
||||
else:
|
||||
mode = str(config)
|
||||
config = current_cat_tools[tool_name]
|
||||
if isinstance(config, dict):
|
||||
mode = config.get("mode", "auto")
|
||||
else:
|
||||
mode = str(config)
|
||||
|
||||
if imgui.radio_button(f"Disabled##{cat_name}_{tool_name}", mode == "disabled"):
|
||||
if tool_name in current_cat_tools:
|
||||
del current_cat_tools[tool_name]
|
||||
imgui.same_line()
|
||||
if imgui.radio_button(f"Auto##{cat_name}_{tool_name}", mode == "auto"):
|
||||
if isinstance(config, dict): config["mode"] = "auto"
|
||||
else: tools[tool_name] = "auto"
|
||||
current_cat_tools[tool_name] = "auto"
|
||||
imgui.same_line()
|
||||
if imgui.radio_button(f"Ask##{cat_name}_{tool_name}", mode == "ask"):
|
||||
if isinstance(config, dict): config["mode"] = "ask"
|
||||
else: tools[tool_name] = "ask"
|
||||
current_cat_tools[tool_name] = "ask"
|
||||
imgui.same_line()
|
||||
imgui.text(tool_name)
|
||||
imgui.tree_pop()
|
||||
|
||||
Reference in New Issue
Block a user