fix(gui): equal space allocation for Files & Media sections

- Calculate available space from get_content_region_avail().y
- Divide by number of open sections (1 or 2)
- Each section gets equal height (section_h)
- Content scrolls internally if it exceeds allocated space
- When both collapsed, shows minimal placeholder
This commit is contained in:
2026-05-10 17:35:12 -04:00
parent 28146f96cc
commit feeb318209
+74 -4
View File
@@ -873,10 +873,80 @@ class App:
exp, opened = imgui.begin("Files & Media", self.show_windows["Files & Media"]) exp, opened = imgui.begin("Files & Media", self.show_windows["Files & Media"])
self.show_windows["Files & Media"] = bool(opened) self.show_windows["Files & Media"] = bool(opened)
if exp: if exp:
if imgui.collapsing_header("Files"): avail = imgui.get_content_region_avail().y
self._render_files_panel() files_open = imgui.collapsing_header("Files")
if imgui.collapsing_header("Screenshots"): shots_open = imgui.collapsing_header("Screenshots")
self._render_screenshots_panel() num_open = (1 if files_open else 0) + (1 if shots_open else 0)
if num_open == 0: num_open = 1
section_h = avail / num_open
if files_open:
imgui.text("Paths | Base Dir:"); imgui.same_line()
imgui.set_next_item_width(-100)
ch, self.ui_files_base_dir = imgui.input_text("##f_base", self.ui_files_base_dir)
imgui.same_line()
if imgui.button("Browse##fb"):
r = hide_tk_root(); d = filedialog.askdirectory(); r.destroy()
if d: self.ui_files_base_dir = d
imgui.separator()
if imgui.begin_child("f_paths", imgui.ImVec2(0, section_h - 80), True):
if imgui.begin_table("files_table", 4, imgui.TableFlags_.resizable | imgui.TableFlags_.borders):
imgui.table_setup_column("Actions", imgui.TableColumnFlags_.width_fixed, 40)
imgui.table_setup_column("File Path", imgui.TableColumnFlags_.width_stretch)
imgui.table_setup_column("Flags", imgui.TableColumnFlags_.width_fixed, 150)
imgui.table_setup_column("Cache", imgui.TableColumnFlags_.width_fixed, 40)
imgui.table_headers_row()
for i, f_item in enumerate(self.files):
imgui.table_next_row()
imgui.table_set_column_index(0)
if imgui.button(f"x##f{i}"): self.files.pop(i); break
imgui.table_set_column_index(1)
imgui.text(f_item.path if hasattr(f_item, "path") else str(f_item))
imgui.table_set_column_index(2)
if hasattr(f_item, "auto_aggregate"):
changed_agg, f_item.auto_aggregate = imgui.checkbox(f"Agg##a{i}", f_item.auto_aggregate)
imgui.same_line()
changed_full, f_item.force_full = imgui.checkbox(f"Full##f{i}", f_item.force_full)
imgui.table_set_column_index(3)
path = f_item.path if hasattr(f_item, "path") else str(f_item)
is_cached = any(path in c for c in getattr(self, "_cached_files", []))
if is_cached: imgui.text_colored("", imgui.ImVec4(0, 1, 0, 1))
else: imgui.text_disabled("")
imgui.end_table()
imgui.end_child()
if imgui.button("Add File(s)"):
r = hide_tk_root(); paths = filedialog.askopenfilenames(); r.destroy()
for p in paths:
if p not in [f.path if hasattr(f, "path") else f for f in self.files]: self.files.append(models.FileItem(path=p))
imgui.same_line()
if imgui.button("Add Wildcard"):
r = hide_tk_root(); d = filedialog.askdirectory(); r.destroy()
if d: self.files.append(models.FileItem(path=str(Path(d) / "**" / "*")))
imgui.separator()
from src import summarize
stats = summarize._summary_cache.get_stats()
imgui.text_disabled(f"Summary Cache: {stats['entries']} entries ({stats['size_bytes']} bytes)")
imgui.same_line()
if imgui.button("Clear##fsc"): self.controller._cb_clear_summary_cache()
if shots_open:
imgui.text("Paths | Base Dir:"); imgui.same_line()
imgui.set_next_item_width(-100)
ch, self.ui_shots_base_dir = imgui.input_text("##s_base", self.ui_shots_base_dir)
imgui.same_line()
if imgui.button("Browse##sb"):
r = hide_tk_root(); d = filedialog.askdirectory(); r.destroy()
if d: self.ui_shots_base_dir = d
imgui.separator()
if imgui.begin_child("s_paths", imgui.ImVec2(0, section_h - 80), True):
for i, s in enumerate(self.screenshots):
if imgui.button(f"x##s{i}"): self.screenshots.pop(i); break
imgui.same_line(); imgui.text(s)
imgui.end_child()
if imgui.button("Add Screenshot(s)"):
r = hide_tk_root()
paths = filedialog.askopenfilenames(title="Select Screenshots", filetypes=[("Images", "*.png *.jpg *.jpeg *.gif *.bmp *.webp"), ("All", "*.*")])
r.destroy()
for p in paths:
if p not in self.screenshots: self.screenshots.append(p)
imgui.end() imgui.end()
if self.show_windows.get("AI Settings", False): if self.show_windows.get("AI Settings", False):
exp, opened = imgui.begin("AI Settings", self.show_windows["AI Settings"]) exp, opened = imgui.begin("AI Settings", self.show_windows["AI Settings"])