diff --git a/src/gui_2.py b/src/gui_2.py index 085773e..463d095 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -873,15 +873,22 @@ class App: if self.show_windows.get("Files & Media", False): exp, opened = imgui.begin("Files & Media", self.show_windows["Files & Media"]) self.show_windows["Files & Media"] = bool(opened) - if exp: - # BEGIN Files section - if imgui.collapsing_header("Files"): - self._render_files_panel() - # END Files section - # BEGIN Screenshots section - if imgui.collapsing_header("Screenshots"): - self._render_screenshots_panel() - # END Screenshots section + if opened: + if exp: + avail = imgui.get_content_region_avail().y + # Determine how many sections will render + files_hdr = imgui.collapsing_header("Files") + shots_hdr = imgui.collapsing_header("Screenshots") + num_open = (1 if files_hdr else 0) + (1 if shots_hdr else 0) + section_h = avail / max(num_open, 1) + # BEGIN Files section + if files_hdr: + self._render_files_panel(section_h - 80) + # END Files section + # BEGIN Screenshots section + if shots_hdr: + self._render_screenshots_panel(section_h - 80) + # END Screenshots section imgui.end() # END Files & Media window if self.show_windows.get("AI Settings", False): @@ -2912,7 +2919,7 @@ def hello(): markdown_helper.render(md) - def _render_files_panel(self) -> None: + def _render_files_panel(self, height_override: float = 0) -> None: if self.perf_profiling_enabled: self.perf_monitor.start_component("_render_files_panel") imgui.text("Paths") imgui.same_line() @@ -2927,9 +2934,12 @@ def hello(): r.destroy() if d: self.ui_files_base_dir = d imgui.separator() - # Calculate content-based height: row_count * 28px + header, max 300px - row_count = max(len(self.files), 1) - child_h = min(row_count * 28 + 40, 300) + # Calculate content-based height: use override if provided, else content-based + if height_override > 0: + child_h = height_override + else: + row_count = max(len(self.files), 1) + child_h = min(row_count * 28 + 40, 300) # BEGIN f_paths child window imgui.begin_child("f_paths", imgui.ImVec2(0, child_h), True) if imgui.begin_table("files_table", 4, imgui.TableFlags_.resizable | imgui.TableFlags_.borders): @@ -2989,7 +2999,7 @@ def hello(): if self.perf_profiling_enabled: self.perf_monitor.end_component("_render_files_panel") - def _render_screenshots_panel(self) -> None: + def _render_screenshots_panel(self, height_override: float = 0) -> None: if self.perf_profiling_enabled: self.perf_monitor.start_component("_render_screenshots_panel") imgui.text("Paths") imgui.same_line() @@ -3004,9 +3014,12 @@ def hello(): r.destroy() if d: self.ui_shots_base_dir = d imgui.separator() - # Calculate content-based height: row_count * 28px + header, max 200px - shot_count = max(len(self.screenshots), 1) - shot_h = min(shot_count * 28 + 40, 200) + # Calculate content-based height: use override if provided, else content-based + if height_override > 0: + shot_h = height_override + else: + shot_count = max(len(self.screenshots), 1) + shot_h = min(shot_count * 28 + 40, 200) # BEGIN s_paths child window imgui.begin_child("s_paths", imgui.ImVec2(0, shot_h), True) for i, s in enumerate(self.screenshots):