feat(gui): Add imgui_scopes with per-type context managers for begin/end pairs
This commit is contained in:
+28
-32
@@ -45,7 +45,7 @@ else:
|
||||
|
||||
from pydantic import BaseModel
|
||||
from imgui_bundle import imgui, hello_imgui, immapp, imgui_node_editor as ed, imgui_color_text_edit as ced
|
||||
from src.imgui_scopes import imgui_window
|
||||
from src.imgui_scopes import imgui_begin, imgui_begin_child, imgui_begin_table, imgui_begin_menu_bar, imgui_begin_menu, imgui_begin_popup, imgui_begin_tooltip, imgui_begin_group, node_begin
|
||||
|
||||
COMMS_CLAMP_CHARS: int = 300
|
||||
|
||||
@@ -779,43 +779,38 @@ class App:
|
||||
[C: tests/test_shader_live_editor.py:test_shader_live_editor_renders]
|
||||
"""
|
||||
if self.show_windows.get('Shader Editor', False):
|
||||
with imgui_window('Shader Editor', self.show_windows['Shader Editor']) as window_result:
|
||||
if window_result:
|
||||
changed_crt, self.shader_uniforms['crt'] = imgui.slider_float('CRT Curvature', self.shader_uniforms['crt'], 0.0, 2.0)
|
||||
changed_scan, self.shader_uniforms['scanline'] = imgui.slider_float('Scanline Intensity', self.shader_uniforms['scanline'], 0.0, 1.0)
|
||||
changed_bloom, self.shader_uniforms['bloom'] = imgui.slider_float('Bloom Threshold', self.shader_uniforms['bloom'], 0.0, 1.0)
|
||||
_, opened = imgui_begin('Shader Editor', self.show_windows['Shader Editor'])
|
||||
self.show_windows['Shader Editor'] = bool(opened)
|
||||
if opened:
|
||||
changed_crt, self.shader_uniforms['crt'] = imgui.slider_float('CRT Curvature', self.shader_uniforms['crt'], 0.0, 2.0)
|
||||
changed_scan, self.shader_uniforms['scanline'] = imgui.slider_float('Scanline Intensity', self.shader_uniforms['scanline'], 0.0, 1.0)
|
||||
changed_bloom, self.shader_uniforms['bloom'] = imgui.slider_float('Bloom Threshold', self.shader_uniforms['bloom'], 0.0, 1.0)
|
||||
|
||||
def _render_history_window(self) -> None:
|
||||
if not self.show_windows.get('Undo/Redo History', False):
|
||||
return
|
||||
|
||||
with imgui_window("Undo/Redo History", self.show_windows['Undo/Redo History']) as (exp, opened):
|
||||
with imgui_begin("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()
|
||||
|
||||
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()
|
||||
with 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)
|
||||
|
||||
def _gui_func(self) -> None:
|
||||
self._render_custom_title_bar()
|
||||
@@ -918,7 +913,7 @@ class App:
|
||||
|
||||
#region: Project Settings
|
||||
if self.show_windows.get("Project Settings", False):
|
||||
with imgui_window("Project Settings", self.show_windows["Project Settings"]) as (exp, opened):
|
||||
with imgui_begin("Project Settings", self.show_windows["Project Settings"]) as (exp, opened):
|
||||
self.show_windows["Project Settings"] = bool(opened)
|
||||
if exp:
|
||||
if imgui.begin_tab_bar('context_hub_tabs'):
|
||||
@@ -1053,7 +1048,7 @@ class App:
|
||||
|
||||
#region: AI Settings
|
||||
if self.show_windows.get("AI Settings", False):
|
||||
with imgui_window("AI Settings", self.show_windows["AI Settings"]) as (exp, opened):
|
||||
with imgui_begin("AI Settings", self.show_windows["AI Settings"]) as (exp, opened):
|
||||
self.show_windows["AI Settings"] = bool(opened)
|
||||
if exp:
|
||||
self._render_persona_selector_panel()
|
||||
@@ -1064,6 +1059,7 @@ class App:
|
||||
if imgui.collapsing_header("RAG Settings"):
|
||||
self._render_rag_panel()
|
||||
self._render_agent_tools_panel()
|
||||
|
||||
if self.ui_separate_usage_analytics and self.show_windows.get("Usage Analytics", False):
|
||||
exp, opened = imgui.begin("Usage Analytics", self.show_windows["Usage Analytics"])
|
||||
self.show_windows["Usage Analytics"] = bool(opened)
|
||||
|
||||
Reference in New Issue
Block a user