diff --git a/src/gui_2.py b/src/gui_2.py index c272f1b..8598a12 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -788,36 +788,34 @@ class App: def _render_history_window(self) -> None: if not self.show_windows.get('Undo/Redo History', False): return - - exp, opened = imgui.begin("Undo/Redo History", self.show_windows['Undo/Redo History']) - self.show_windows['Undo/Redo History'] = bool(opened) - if exp: - if imgui.button("Undo") and self.history.can_undo: - self._handle_undo() - imgui.same_line() - if imgui.button("Redo") and self.history.can_redo: - self._handle_redo() - - imgui.separator() - imgui.begin_child("history_list", imgui.ImVec2(0, 0), True) - history = self.history.get_history() - if not history: - imgui.text("No history available.") - else: - for i, entry in enumerate(reversed(history)): - # Actual index in undo stack - actual_idx = len(history) - 1 - i - desc = entry.get("description", "UI Change") - ts = entry.get("timestamp", 0.0) - import datetime - ts_str = datetime.datetime.fromtimestamp(ts).strftime("%H:%M:%S") - - label = f"[{ts_str}] {desc}##{actual_idx}" - _, selected = imgui.selectable(label, False) - if selected: - self._handle_jump_to_history(actual_idx) - imgui.end_child() - imgui.end() + + with imgui_window("Undo/Redo History", self.show_windows['Undo/Redo History']) as (exp, opened): + self.show_windows['Undo/Redo History'] = bool(opened) + if exp: + if imgui.button("Undo") and self.history.can_undo: + self._handle_undo() + imgui.same_line() + if imgui.button("Redo") and self.history.can_redo: + self._handle_redo() + + imgui.separator() + imgui.begin_child("history_list", imgui.ImVec2(0, 0), True) + history = self.history.get_history() + if not history: + imgui.text("No history available.") + else: + for i, entry in enumerate(reversed(history)): + actual_idx = len(history) - 1 - i + desc = entry.get("description", "UI Change") + ts = entry.get("timestamp", 0.0) + import datetime + ts_str = datetime.datetime.fromtimestamp(ts).strftime("%H:%M:%S") + + label = f"[{ts_str}] {desc}##{actual_idx}" + _, selected = imgui.selectable(label, False) + if selected: + self._handle_jump_to_history(actual_idx) + imgui.end_child() def _gui_func(self) -> None: self._render_custom_title_bar()