beginning curation of gui_2.py using imscopes
This commit is contained in:
+37
-38
@@ -1,6 +1,7 @@
|
|||||||
# gui_2.py
|
# gui_2.py
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import tomli_w
|
import tomli_w
|
||||||
|
import datetime
|
||||||
import time
|
import time
|
||||||
import math
|
import math
|
||||||
import json
|
import json
|
||||||
@@ -32,6 +33,8 @@ from src import aggregate
|
|||||||
from src import markdown_helper
|
from src import markdown_helper
|
||||||
from src import bg_shader
|
from src import bg_shader
|
||||||
from src import thinking_parser
|
from src import thinking_parser
|
||||||
|
from src import history
|
||||||
|
import typing
|
||||||
import re
|
import re
|
||||||
import difflib
|
import difflib
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -45,7 +48,7 @@ else:
|
|||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from imgui_bundle import imgui, hello_imgui, immapp, imgui_node_editor as ed, imgui_color_text_edit as ced
|
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
|
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_.child_bg, vec4(40, 35, 25, 180))
|
||||||
imgui.push_style_color(imgui.Col_.text, vec4(200, 200, 150))
|
imgui.push_style_color(imgui.Col_.text, vec4(200, 200, 150))
|
||||||
imgui.indent()
|
imgui.indent()
|
||||||
|
|
||||||
show_content = True
|
show_content = True
|
||||||
if not is_standalone:
|
if not is_standalone:
|
||||||
header_label = f"Monologue ({len(segments)} traces)###thinking_header_{entry_index}"
|
header_label = f"Monologue ({len(segments)} traces)###thinking_header_{entry_index}"
|
||||||
@@ -610,21 +614,19 @@ class App:
|
|||||||
|
|
||||||
if show_content:
|
if show_content:
|
||||||
h = 150 if is_standalone else 100
|
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):
|
for idx, seg in enumerate(segments):
|
||||||
content = seg.get("content", "")
|
content = seg.get("content", "")
|
||||||
marker = seg.get("marker", "thinking")
|
marker = seg.get("marker", "thinking")
|
||||||
imgui.push_id(f"think_{entry_index}_{idx}")
|
imscope.id(f"think_{entry_index}_{idx}")
|
||||||
imgui.text_colored(vec4(180, 150, 80), f"[{marker}]")
|
imgui.text_colored(vec4(180, 150, 80), f"[{marker}]")
|
||||||
if self.ui_word_wrap:
|
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.text_colored(vec4(200, 200, 150), content)
|
||||||
imgui.pop_text_wrap_pos()
|
|
||||||
else:
|
else:
|
||||||
imgui.text_colored(vec4(200, 200, 150), content)
|
imgui.text_colored(vec4(200, 200, 150), content)
|
||||||
imgui.pop_id()
|
|
||||||
imgui.separator()
|
imgui.separator()
|
||||||
imgui.end_child()
|
|
||||||
imgui.unindent()
|
imgui.unindent()
|
||||||
imgui.pop_style_color(2)
|
imgui.pop_style_color(2)
|
||||||
|
|
||||||
@@ -779,38 +781,35 @@ class App:
|
|||||||
[C: tests/test_shader_live_editor.py:test_shader_live_editor_renders]
|
[C: tests/test_shader_live_editor.py:test_shader_live_editor_renders]
|
||||||
"""
|
"""
|
||||||
if self.show_windows.get('Shader Editor', False):
|
if self.show_windows.get('Shader Editor', False):
|
||||||
_, opened = imgui_begin('Shader Editor', self.show_windows['Shader Editor'])
|
with imscope.window('Shader Editor', self.show_windows['Shader Editor']) as (exp, opened):
|
||||||
self.show_windows['Shader Editor'] = bool(opened)
|
self.show_windows['Shader Editor'] = bool(opened)
|
||||||
if opened:
|
if exp:
|
||||||
changed_crt, self.shader_uniforms['crt'] = imgui.slider_float('CRT Curvature', self.shader_uniforms['crt'], 0.0, 2.0)
|
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_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)
|
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:
|
def _render_history_window(self) -> None:
|
||||||
if not self.show_windows.get('Undo/Redo History', False):
|
if not self.show_windows.get('Undo/Redo History', False):
|
||||||
return
|
return
|
||||||
|
def iterate_history(history: typing.List[typing.Dict[str, typing.Any]]):
|
||||||
with imgui_begin("Undo/Redo History", self.show_windows['Undo/Redo History']) as (exp, opened):
|
for i, entry in enumerate(reversed(history)):
|
||||||
self.show_windows['Undo/Redo History'] = bool(opened)
|
actual_idx = len(history) - 1 - i
|
||||||
if exp:
|
desc = entry.get("description", "UI Change")
|
||||||
if imgui.button("Undo") and self.history.can_undo: self._handle_undo(); imgui.same_line()
|
ts = entry.get("timestamp", 0.0)
|
||||||
if imgui.button("Redo") and self.history.can_redo: self._handle_redo()
|
ts_str = datetime.datetime.fromtimestamp(ts).strftime("%H:%M:%S")
|
||||||
imgui.separator()
|
label = f"[{ts_str}] {desc}##{actual_idx}"
|
||||||
with imgui_begin_child("history_list", imgui.ImVec2(0, 0), True):
|
_, selected = imgui.selectable(label, False)
|
||||||
history = self.history.get_history()
|
if selected: self._handle_jump_to_history(actual_idx)
|
||||||
if not history: imgui.text("No history available.")
|
with imscope.window("Undo/Redo History", self.show_windows['Undo/Redo History']) as (exp, opened):
|
||||||
else:
|
self.show_windows['Undo/Redo History'] = bool(opened)
|
||||||
for i, entry in enumerate(reversed(history)):
|
if exp:
|
||||||
actual_idx = len(history) - 1 - i
|
if imgui.button("Undo") and self.history.can_undo: self._handle_undo(); imgui.same_line()
|
||||||
desc = entry.get("description", "UI Change")
|
if imgui.button("Redo") and self.history.can_redo: self._handle_redo()
|
||||||
ts = entry.get("timestamp", 0.0)
|
imgui.separator()
|
||||||
import datetime
|
with imscope.child("history_list", imgui.ImVec2(0, 0), True):
|
||||||
ts_str = datetime.datetime.fromtimestamp(ts).strftime("%H:%M:%S")
|
history = self.history.get_history()
|
||||||
|
if not history: imgui.text("No history available.")
|
||||||
label = f"[{ts_str}] {desc}##{actual_idx}"
|
else: iterate_history()
|
||||||
_, selected = imgui.selectable(label, False)
|
|
||||||
if selected:
|
|
||||||
self._handle_jump_to_history(actual_idx)
|
|
||||||
|
|
||||||
def _gui_func(self) -> None:
|
def _gui_func(self) -> None:
|
||||||
self._render_custom_title_bar()
|
self._render_custom_title_bar()
|
||||||
@@ -913,7 +912,7 @@ class App:
|
|||||||
|
|
||||||
#region: Project Settings
|
#region: Project Settings
|
||||||
if self.show_windows.get("Project Settings", False):
|
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)
|
self.show_windows["Project Settings"] = bool(opened)
|
||||||
if exp:
|
if exp:
|
||||||
if imgui.begin_tab_bar('context_hub_tabs'):
|
if imgui.begin_tab_bar('context_hub_tabs'):
|
||||||
@@ -1048,7 +1047,7 @@ class App:
|
|||||||
|
|
||||||
#region: AI Settings
|
#region: AI Settings
|
||||||
if self.show_windows.get("AI Settings", False):
|
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)
|
self.show_windows["AI Settings"] = bool(opened)
|
||||||
if exp:
|
if exp:
|
||||||
self._render_persona_selector_panel()
|
self._render_persona_selector_panel()
|
||||||
|
|||||||
+38
-69
@@ -2,146 +2,115 @@ from __future__ import annotations
|
|||||||
from imgui_bundle import imgui
|
from imgui_bundle import imgui
|
||||||
from imgui_bundle import imgui_node_editor
|
from imgui_bundle import imgui_node_editor
|
||||||
|
|
||||||
|
def window(name: str, visible: bool = True, flags: int = 0): return _ScopeWindow(name, visible, flags)
|
||||||
def imgui_begin(name: str, visible: bool = True, flags: int = 0):
|
class _ScopeWindow:
|
||||||
return _ImguiBegin(name, visible, flags)
|
|
||||||
|
|
||||||
|
|
||||||
class _ImguiBegin:
|
|
||||||
def __init__(self, name: str, visible: bool, flags: int):
|
def __init__(self, name: str, visible: bool, flags: int):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._visible = visible
|
self._visible = visible
|
||||||
self._flags = flags
|
self._flags = flags
|
||||||
self._result = None
|
self._result = None
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
self._result = imgui.begin(self._name, self._visible, self._flags)
|
self._result = imgui.begin(self._name, self._visible, self._flags)
|
||||||
return self._result
|
return self._result
|
||||||
|
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
imgui.end()
|
imgui.end()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def child(id_str: str, size_x: float = 0, size_y: float = 0, flags: int = 0): return _ScopeChild(id_str, size_x, size_y, flags)
|
||||||
def imgui_begin_child(id_str: str, size_x: float = 0, size_y: float = 0, flags: int = 0):
|
class _ScopeChild:
|
||||||
return _ImguiBeginChild(id_str, size_x, size_y, flags)
|
|
||||||
|
|
||||||
|
|
||||||
class _ImguiBeginChild:
|
|
||||||
def __init__(self, id_str: str, size_x: float, size_y: float, flags: int):
|
def __init__(self, id_str: str, size_x: float, size_y: float, flags: int):
|
||||||
self._id = id_str
|
self._id = id_str
|
||||||
self._sx = size_x
|
self._sx = size_x
|
||||||
self._sy = size_y
|
self._sy = size_y
|
||||||
self._flags = flags
|
self._flags = flags
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return imgui.begin_child(self._id, self._sx, self._sy, self._flags)
|
return imgui.begin_child(self._id, self._sx, self._sy, self._flags)
|
||||||
|
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
imgui.end_child()
|
imgui.end_child()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def table(name: str, columns: int, flags: int = 0): return _ScopeTable(name, columns, flags)
|
||||||
def imgui_begin_table(name: str, columns: int, flags: int = 0):
|
class _ScopeTable:
|
||||||
return _ImguiBeginTable(name, columns, flags)
|
|
||||||
|
|
||||||
|
|
||||||
class _ImguiBeginTable:
|
|
||||||
def __init__(self, name: str, columns: int, flags: int):
|
def __init__(self, name: str, columns: int, flags: int):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._columns = columns
|
self._columns = columns
|
||||||
self._flags = flags
|
self._flags = flags
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return imgui.begin_table(self._name, self._columns, self._flags)
|
return imgui.begin_table(self._name, self._columns, self._flags)
|
||||||
|
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
imgui.end_table()
|
imgui.end_table()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def menu_bar(): return _ScopeMenuBar()
|
||||||
def imgui_begin_menu_bar():
|
class _ScopeMenuBar:
|
||||||
return _ImguiBeginMenuBar()
|
|
||||||
|
|
||||||
|
|
||||||
class _ImguiBeginMenuBar:
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return imgui.begin_menu_bar()
|
return imgui.begin_menu_bar()
|
||||||
|
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
imgui.end_menu_bar()
|
imgui.end_menu_bar()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def menu(label: str): return _ScopeMenu(label)
|
||||||
def imgui_begin_menu(label: str):
|
class _ScopeMenu:
|
||||||
return _ImguiBeginMenu(label)
|
|
||||||
|
|
||||||
|
|
||||||
class _ImguiBeginMenu:
|
|
||||||
def __init__(self, label: str):
|
def __init__(self, label: str):
|
||||||
self._label = label
|
self._label = label
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return imgui.begin_menu(self._label)
|
return imgui.begin_menu(self._label)
|
||||||
|
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
imgui.end_menu()
|
imgui.end_menu()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def popup(id_str: str): return _ScopePopup(id_str)
|
||||||
def imgui_begin_popup(id_str: str):
|
class _ScopePopup:
|
||||||
return _ImguiBeginPopup(id_str)
|
|
||||||
|
|
||||||
|
|
||||||
class _ImguiBeginPopup:
|
|
||||||
def __init__(self, id_str: str):
|
def __init__(self, id_str: str):
|
||||||
self._id = id_str
|
self._id = id_str
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return imgui.begin_popup(self._id)
|
return imgui.begin_popup(self._id)
|
||||||
|
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
imgui.end_popup()
|
imgui.end_popup()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def tooltip(): return _ScopeTooltip()
|
||||||
def imgui_begin_tooltip():
|
class _ScopeTooltip:
|
||||||
return _ImguiBeginTooltip()
|
|
||||||
|
|
||||||
|
|
||||||
class _ImguiBeginTooltip:
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return imgui.begin_tooltip()
|
return imgui.begin_tooltip()
|
||||||
|
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
imgui.end_tooltip()
|
imgui.end_tooltip()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def group(): return _ScopeGroup()
|
||||||
def imgui_begin_group():
|
class _ScopeGroup:
|
||||||
return _ImguiBeginGroup()
|
|
||||||
|
|
||||||
|
|
||||||
class _ImguiBeginGroup:
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return imgui.begin_group()
|
return imgui.begin_group()
|
||||||
|
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
imgui.end_group()
|
imgui.end_group()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def node(name: str): return _ScopeNode(name)
|
||||||
def node_begin(name: str):
|
class _ScopeNode:
|
||||||
return _NodeBegin(name)
|
|
||||||
|
|
||||||
|
|
||||||
class _NodeBegin:
|
|
||||||
def __init__(self, name: str):
|
def __init__(self, name: str):
|
||||||
self._name = name
|
self._name = name
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return imgui_node_editor.begin(self._name)
|
return imgui_node_editor.begin(self._name)
|
||||||
|
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
imgui_node_editor.end()
|
imgui_node_editor.end()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def text_wrap(wrap_pos: float = 0.0): return _ScopeTextWrap(wrap_pos)
|
||||||
|
class _ScopeTextWrap:
|
||||||
|
def __init__(self, wrap_pos: float):
|
||||||
|
self._wrap_pos = wrap_pos
|
||||||
|
def __enter__(self):
|
||||||
|
imgui.push_text_wrap_pos(self._wrap_pos)
|
||||||
|
def __exit__(self, *args):
|
||||||
|
imgui.pop_text_wrap_pos()
|
||||||
|
return False
|
||||||
|
|
||||||
|
def id(str_id: str): return _ScopeId(str_id)
|
||||||
|
class _ScopeId:
|
||||||
|
def __init__(self, str_id: str):
|
||||||
|
self._id = str_id
|
||||||
|
def __enter__(self):
|
||||||
|
imgui.push_id(self._id)
|
||||||
|
def __exit__(self, *args):
|
||||||
|
imgui.pop_id()
|
||||||
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user