feat(gui): Migrate _render_history_window to imgui_window scope

This commit is contained in:
2026-05-11 23:17:59 -04:00
parent f1ca3751c8
commit 1e47ed9013
+25 -27
View File
@@ -789,35 +789,33 @@ class App:
if not self.show_windows.get('Undo/Redo History', False): if not self.show_windows.get('Undo/Redo History', False):
return return
exp, opened = imgui.begin("Undo/Redo History", self.show_windows['Undo/Redo History']) with imgui_window("Undo/Redo History", self.show_windows['Undo/Redo History']) as (exp, opened):
self.show_windows['Undo/Redo History'] = bool(opened) self.show_windows['Undo/Redo History'] = bool(opened)
if exp: if exp:
if imgui.button("Undo") and self.history.can_undo: if imgui.button("Undo") and self.history.can_undo:
self._handle_undo() self._handle_undo()
imgui.same_line() imgui.same_line()
if imgui.button("Redo") and self.history.can_redo: if imgui.button("Redo") and self.history.can_redo:
self._handle_redo() self._handle_redo()
imgui.separator() imgui.separator()
imgui.begin_child("history_list", imgui.ImVec2(0, 0), True) imgui.begin_child("history_list", imgui.ImVec2(0, 0), True)
history = self.history.get_history() history = self.history.get_history()
if not history: if not history:
imgui.text("No history available.") imgui.text("No history available.")
else: else:
for i, entry in enumerate(reversed(history)): for i, entry in enumerate(reversed(history)):
# Actual index in undo stack actual_idx = len(history) - 1 - i
actual_idx = len(history) - 1 - i desc = entry.get("description", "UI Change")
desc = entry.get("description", "UI Change") ts = entry.get("timestamp", 0.0)
ts = entry.get("timestamp", 0.0) import datetime
import datetime ts_str = datetime.datetime.fromtimestamp(ts).strftime("%H:%M:%S")
ts_str = datetime.datetime.fromtimestamp(ts).strftime("%H:%M:%S")
label = f"[{ts_str}] {desc}##{actual_idx}" label = f"[{ts_str}] {desc}##{actual_idx}"
_, selected = imgui.selectable(label, False) _, selected = imgui.selectable(label, False)
if selected: if selected:
self._handle_jump_to_history(actual_idx) self._handle_jump_to_history(actual_idx)
imgui.end_child() imgui.end_child()
imgui.end()
def _gui_func(self) -> None: def _gui_func(self) -> None:
self._render_custom_title_bar() self._render_custom_title_bar()