beginning curation of gui_2.py using imscopes
This commit is contained in:
+37
-38
@@ -1,6 +1,7 @@
|
||||
# gui_2.py
|
||||
from __future__ import annotations
|
||||
import tomli_w
|
||||
import datetime
|
||||
import time
|
||||
import math
|
||||
import json
|
||||
@@ -32,6 +33,8 @@ from src import aggregate
|
||||
from src import markdown_helper
|
||||
from src import bg_shader
|
||||
from src import thinking_parser
|
||||
from src import history
|
||||
import typing
|
||||
import re
|
||||
import difflib
|
||||
import subprocess
|
||||
@@ -45,7 +48,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_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
|
||||
from src import imgui_scopes as imscope
|
||||
|
||||
COMMS_CLAMP_CHARS: int = 300
|
||||
|
||||
@@ -603,6 +606,7 @@ class App:
|
||||
imgui.push_style_color(imgui.Col_.child_bg, vec4(40, 35, 25, 180))
|
||||
imgui.push_style_color(imgui.Col_.text, vec4(200, 200, 150))
|
||||
imgui.indent()
|
||||
|
||||
show_content = True
|
||||
if not is_standalone:
|
||||
header_label = f"Monologue ({len(segments)} traces)###thinking_header_{entry_index}"
|
||||
@@ -610,21 +614,19 @@ class App:
|
||||
|
||||
if show_content:
|
||||
h = 150 if is_standalone else 100
|
||||
imgui.begin_child(f"thinking_content_{entry_index}", imgui.ImVec2(0, h), True)
|
||||
imscope.child(f"thinking_content_{entry_index}", imgui.ImVec2(0, h), True)
|
||||
for idx, seg in enumerate(segments):
|
||||
content = seg.get("content", "")
|
||||
marker = seg.get("marker", "thinking")
|
||||
imgui.push_id(f"think_{entry_index}_{idx}")
|
||||
marker = seg.get("marker", "thinking")
|
||||
imscope.id(f"think_{entry_index}_{idx}")
|
||||
imgui.text_colored(vec4(180, 150, 80), f"[{marker}]")
|
||||
if self.ui_word_wrap:
|
||||
imgui.push_text_wrap_pos(imgui.get_content_region_avail().x)
|
||||
imscope.text_wrap(imgui.get_content_region_avail().x)
|
||||
imgui.text_colored(vec4(200, 200, 150), content)
|
||||
imgui.pop_text_wrap_pos()
|
||||
else:
|
||||
imgui.text_colored(vec4(200, 200, 150), content)
|
||||
imgui.pop_id()
|
||||
imgui.separator()
|
||||
imgui.end_child()
|
||||
|
||||
imgui.unindent()
|
||||
imgui.pop_style_color(2)
|
||||
|
||||
@@ -779,38 +781,35 @@ class App:
|
||||
[C: tests/test_shader_live_editor.py:test_shader_live_editor_renders]
|
||||
"""
|
||||
if self.show_windows.get('Shader Editor', False):
|
||||
_, 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)
|
||||
with imscope.window('Shader Editor', self.show_windows['Shader Editor']) as (exp, opened):
|
||||
self.show_windows['Shader Editor'] = bool(opened)
|
||||
if exp:
|
||||
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_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()
|
||||
imgui.separator()
|
||||
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 iterate_history(history: typing.List[typing.Dict[str, typing.Any]]):
|
||||
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)
|
||||
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)
|
||||
with imscope.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()
|
||||
with imscope.child("history_list", imgui.ImVec2(0, 0), True):
|
||||
history = self.history.get_history()
|
||||
if not history: imgui.text("No history available.")
|
||||
else: iterate_history()
|
||||
|
||||
def _gui_func(self) -> None:
|
||||
self._render_custom_title_bar()
|
||||
@@ -913,7 +912,7 @@ class App:
|
||||
|
||||
#region: Project Settings
|
||||
if self.show_windows.get("Project Settings", False):
|
||||
with imgui_begin("Project Settings", self.show_windows["Project Settings"]) as (exp, opened):
|
||||
with imscope.window("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'):
|
||||
@@ -1048,7 +1047,7 @@ class App:
|
||||
|
||||
#region: AI Settings
|
||||
if self.show_windows.get("AI Settings", False):
|
||||
with imgui_begin("AI Settings", self.show_windows["AI Settings"]) as (exp, opened):
|
||||
with imscope.window("AI Settings", self.show_windows["AI Settings"]) as (exp, opened):
|
||||
self.show_windows["AI Settings"] = bool(opened)
|
||||
if exp:
|
||||
self._render_persona_selector_panel()
|
||||
|
||||
Reference in New Issue
Block a user