fix(gui): Files & Media - content-based heights + scope annotations
- Files: child_h = min(max(len(files),1) * 28 + 40, 300) - Screenshots: shot_h = min(max(len(shots),1) * 28 + 40, 200) - Added # BEGIN/END comments for all window/section scopes - Keeps original working structure (no restructuring)
This commit is contained in:
+16
-76
@@ -869,85 +869,21 @@ class App:
|
|||||||
imgui.end_tab_item()
|
imgui.end_tab_item()
|
||||||
imgui.end_tab_bar()
|
imgui.end_tab_bar()
|
||||||
imgui.end()
|
imgui.end()
|
||||||
|
# BEGIN Files & Media window
|
||||||
if self.show_windows.get("Files & Media", False):
|
if self.show_windows.get("Files & Media", False):
|
||||||
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:
|
||||||
avail = imgui.get_content_region_avail().y
|
# BEGIN Files section
|
||||||
files_open = imgui.collapsing_header("Files")
|
if imgui.collapsing_header("Files"):
|
||||||
shots_open = imgui.collapsing_header("Screenshots")
|
self._render_files_panel()
|
||||||
num_open = (1 if files_open else 0) + (1 if shots_open else 0)
|
# END Files section
|
||||||
if num_open == 0: num_open = 1
|
# BEGIN Screenshots section
|
||||||
section_h = avail / num_open
|
if imgui.collapsing_header("Screenshots"):
|
||||||
if files_open:
|
self._render_screenshots_panel()
|
||||||
imgui.text("Paths | Base Dir:"); imgui.same_line()
|
# END Screenshots section
|
||||||
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()
|
||||||
|
# END Files & Media window
|
||||||
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"])
|
||||||
self.show_windows["AI Settings"] = bool(opened)
|
self.show_windows["AI Settings"] = bool(opened)
|
||||||
@@ -2991,8 +2927,10 @@ def hello():
|
|||||||
r.destroy()
|
r.destroy()
|
||||||
if d: self.ui_files_base_dir = d
|
if d: self.ui_files_base_dir = d
|
||||||
imgui.separator()
|
imgui.separator()
|
||||||
|
# Calculate content-based height: row_count * 28px + header, max 300px
|
||||||
row_count = max(len(self.files), 1)
|
row_count = max(len(self.files), 1)
|
||||||
child_h = min(row_count * 28 + 40, 350)
|
child_h = min(row_count * 28 + 40, 300)
|
||||||
|
# BEGIN f_paths child window
|
||||||
imgui.begin_child("f_paths", imgui.ImVec2(0, child_h), True)
|
imgui.begin_child("f_paths", imgui.ImVec2(0, child_h), True)
|
||||||
if imgui.begin_table("files_table", 4, imgui.TableFlags_.resizable | imgui.TableFlags_.borders):
|
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("Actions", imgui.TableColumnFlags_.width_fixed, 40)
|
||||||
@@ -3066,8 +3004,10 @@ def hello():
|
|||||||
r.destroy()
|
r.destroy()
|
||||||
if d: self.ui_shots_base_dir = d
|
if d: self.ui_shots_base_dir = d
|
||||||
imgui.separator()
|
imgui.separator()
|
||||||
|
# Calculate content-based height: row_count * 28px + header, max 200px
|
||||||
shot_count = max(len(self.screenshots), 1)
|
shot_count = max(len(self.screenshots), 1)
|
||||||
shot_h = min(shot_count * 28 + 40, 250)
|
shot_h = min(shot_count * 28 + 40, 200)
|
||||||
|
# BEGIN s_paths child window
|
||||||
imgui.begin_child("s_paths", imgui.ImVec2(0, shot_h), True)
|
imgui.begin_child("s_paths", imgui.ImVec2(0, shot_h), True)
|
||||||
for i, s in enumerate(self.screenshots):
|
for i, s in enumerate(self.screenshots):
|
||||||
if imgui.button(f"x##s{i}"):
|
if imgui.button(f"x##s{i}"):
|
||||||
|
|||||||
Reference in New Issue
Block a user