From 1de61c16d0804e3759b2409234433a9069be9a83 Mon Sep 17 00:00:00 2001 From: gh-underfoot581 <313842205+gh-underfoot581@users.noreply.github.com> Date: Mon, 31 Aug 2026 21:40:43 +1000 Subject: [PATCH] fix: keep the file dialog at the size the user left it set_next_window_size ran on every frame, so the dialog snapped back to 750x400 the moment a drag-resize ended. Apply the size once per open, and save it to app settings on close so it survives the next open and the next session. The save sits on the shared close path rather than on each individual one, so closing by picking a file counts the same as pressing Cancel. --- application/classes/file_dialog.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/application/classes/file_dialog.py b/application/classes/file_dialog.py index 99f6b8a5..56713778 100644 --- a/application/classes/file_dialog.py +++ b/application/classes/file_dialog.py @@ -62,6 +62,11 @@ def __init__(self, app_logic_instance) -> None: self.overwrite_file_path: str = "" self.video_extensions = ['.mp4', '.mkv', '.avi', '.mov', '.wmv', '.flv', '.webm'] + # Dialog size, restored on open and saved on close + self._window_width: int = 750 + self._window_height: int = 400 + self._size_initialized: bool = False + # Cached directory listing and metadata to avoid per-frame filesystem hits self._current_dir_cached: str = "" self._cached_directories: list[str] = [] @@ -151,9 +156,19 @@ def show( if initial_path and os.path.isdir(initial_path): self.current_dir = initial_path + self._window_width = self.app.app_settings.get("file_dialog_width", 750) + self._window_height = self.app.app_settings.get("file_dialog_height", 400) + self._size_initialized = False + # Invalidate caches on open self._invalidate_listing_cache() + def _save_window_size(self) -> None: + """Remembers the dialog size so the next open matches this one.""" + width, height = imgui.get_window_size() + self.app.app_settings.set("file_dialog_width", int(width)) + self.app.app_settings.set("file_dialog_height", int(height)) + def _invalidate_listing_cache(self) -> None: self._current_dir_cached = "" self._cached_directories = [] @@ -311,10 +326,13 @@ def draw(self) -> None: if not self.open: return - imgui.set_next_window_size(750, 400) + if not self._size_initialized: + imgui.set_next_window_size(self._window_width, self._window_height) + self._size_initialized = True is_open_current_frame, self.open = imgui.begin(self.title, self.open) if not self.open: + self._save_window_size() imgui.end() return @@ -336,6 +354,8 @@ def draw(self) -> None: self._draw_overwrite_confirm() finally: imgui.columns(1) + if not self.open: + self._save_window_size() imgui.end() def _draw_directory_navigation(self) -> None: