fix(gui): shared height for Files & Media sections

- Calculate avail at window level, divide by num_open sections
- Pass height_override to _render_files_panel and _render_screenshots_panel
- When both open: each gets equal share of available space
- When one open: it gets full available space
This commit is contained in:
2026-05-10 17:45:32 -04:00
parent cf2f7c863f
commit 4940913e36
+21 -8
View File
@@ -873,14 +873,21 @@ class App:
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 opened:
if exp: 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 # BEGIN Files section
if imgui.collapsing_header("Files"): if files_hdr:
self._render_files_panel() self._render_files_panel(section_h - 80)
# END Files section # END Files section
# BEGIN Screenshots section # BEGIN Screenshots section
if imgui.collapsing_header("Screenshots"): if shots_hdr:
self._render_screenshots_panel() self._render_screenshots_panel(section_h - 80)
# END Screenshots section # END Screenshots section
imgui.end() imgui.end()
# END Files & Media window # END Files & Media window
@@ -2912,7 +2919,7 @@ def hello():
markdown_helper.render(md) 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") if self.perf_profiling_enabled: self.perf_monitor.start_component("_render_files_panel")
imgui.text("Paths") imgui.text("Paths")
imgui.same_line() imgui.same_line()
@@ -2927,7 +2934,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 # 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) row_count = max(len(self.files), 1)
child_h = min(row_count * 28 + 40, 300) child_h = min(row_count * 28 + 40, 300)
# BEGIN f_paths child window # BEGIN f_paths child window
@@ -2989,7 +2999,7 @@ def hello():
if self.perf_profiling_enabled: self.perf_monitor.end_component("_render_files_panel") 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") if self.perf_profiling_enabled: self.perf_monitor.start_component("_render_screenshots_panel")
imgui.text("Paths") imgui.text("Paths")
imgui.same_line() imgui.same_line()
@@ -3004,7 +3014,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 # 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_count = max(len(self.screenshots), 1)
shot_h = min(shot_count * 28 + 40, 200) shot_h = min(shot_count * 28 + 40, 200)
# BEGIN s_paths child window # BEGIN s_paths child window