files & media ux improvemetn with directory folding and file name vis

This commit is contained in:
ed
2026-06-14 23:29:43 -04:00
parent ae8d01d0f7
commit 74e02485a1
+42 -36
View File
@@ -3475,47 +3475,53 @@ def render_files_and_media(app: App) -> None:
""" """
if imgui.collapsing_header("Files", imgui.TreeNodeFlags_.default_open): if imgui.collapsing_header("Files", imgui.TreeNodeFlags_.default_open):
with imscope.group(): with imscope.group():
if imgui.begin_table("files_table", 3, imgui.TableFlags_.resizable | imgui.TableFlags_.borders | imgui.TableFlags_.row_bg):
imgui.table_setup_column("Act", imgui.TableColumnFlags_.width_fixed, 60)
imgui.table_setup_column("Path", imgui.TableColumnFlags_.width_stretch)
imgui.table_setup_column("Status", imgui.TableColumnFlags_.width_fixed, 70)
imgui.table_headers_row()
to_remove_idx = -1 to_remove_idx = -1
app.files.sort(key=lambda f: f.path.lower() if hasattr(f, 'path') else str(f).lower()) app.files.sort(key=lambda f: f.path.lower() if hasattr(f, 'path') else str(f).lower())
file_indices = {id(f): idx for idx, f in enumerate(app.files)} file_indices = {id(f): idx for idx, f in enumerate(app.files)}
grouped = aggregate.group_files_by_dir(app.files) grouped = aggregate.group_files_by_dir(app.files)
if imgui.begin_table("files_table", 3, imgui.TableFlags_.resizable | imgui.TableFlags_.borders | imgui.TableFlags_.row_bg):
imgui.table_setup_column("Act", imgui.TableColumnFlags_.width_fixed, 60)
imgui.table_setup_column("Path", imgui.TableColumnFlags_.width_stretch)
imgui.table_setup_column("Status", imgui.TableColumnFlags_.width_fixed, 70)
imgui.table_headers_row()
imgui.end_table()
for dir_name, g_files in sorted(grouped.items()): for dir_name, g_files in sorted(grouped.items()):
with imscope.tree_node_ex(f"{dir_name}##files_dir", imgui.TreeNodeFlags_.default_open) as dir_open: with imscope.tree_node_ex(f"{dir_name}##files_dir", imgui.TreeNodeFlags_.default_open) as dir_open:
if dir_open: if imgui.begin_table("files_table", 3, imgui.TableFlags_.resizable | imgui.TableFlags_.borders | imgui.TableFlags_.row_bg):
for f_item in g_files: imgui.table_setup_column("Act", imgui.TableColumnFlags_.width_fixed, 60)
i = file_indices[id(f_item)] imgui.table_setup_column("Path", imgui.TableColumnFlags_.width_stretch)
imgui.table_next_row() imgui.table_setup_column("Status", imgui.TableColumnFlags_.width_fixed, 70)
imgui.table_set_column_index(0) # imgui.table_headers_row()
fpath = f_item.path if hasattr(f_item, 'path') else str(f_item) if dir_open:
in_context = any((cf.path if hasattr(cf, 'path') else str(cf)) == fpath for cf in app.context_files) for f_item in g_files:
is_cached = any(fpath in c for c in getattr(app, '_cached_files', [])) i = file_indices[id(f_item)]
imgui.table_next_row()
if imgui.button(f"+##add_f_{i}"): imgui.table_set_column_index(0)
if not in_context: fpath = f_item.path if hasattr(f_item, 'path') else str(f_item)
from src import models display_name = os.path.basename(fpath)
new_item = models.FileItem(path=fpath) in_context = any((cf.path if hasattr(cf, 'path') else str(cf)) == fpath for cf in app.context_files)
app.context_files.append(new_item) is_cached = any(fpath in c for c in getattr(app, '_cached_files', []))
app._populate_auto_slices(new_item)
if imgui.button(f"+##add_f_{i}"):
imgui.same_line() if not in_context:
if imgui.button(f"x##rem_f_{i}"): from src import models
to_remove_idx = i new_item = models.FileItem(path=fpath)
app.context_files.append(new_item)
imgui.table_set_column_index(1) app._populate_auto_slices(new_item)
imgui.text(fpath)
if imgui.is_item_hovered(): imgui.set_tooltip(fpath) imgui.same_line()
if imgui.button(f"x##rem_f_{i}"):
imgui.table_set_column_index(2) to_remove_idx = i
if in_context: imgui.text_colored(theme.get_color("status_success"), "Active")
elif is_cached: imgui.text_colored(theme.get_color("status_info"), "Cached") imgui.table_set_column_index(1)
else: imgui.text_disabled(" - ") imgui.text(display_name)
imgui.end_table() if imgui.is_item_hovered(): imgui.set_tooltip(fpath)
imgui.table_set_column_index(2)
if in_context: imgui.text_colored(theme.get_color("status_success"), "Active")
elif is_cached: imgui.text_colored(theme.get_color("status_info"), "Cached")
else: imgui.text_disabled(" - ")
imgui.end_table()
if to_remove_idx != -1: app.files.pop(to_remove_idx) if to_remove_idx != -1: app.files.pop(to_remove_idx)
imgui.dummy(imgui.ImVec2(0, 5)) imgui.dummy(imgui.ImVec2(0, 5))