Private
Public Access
0
0
Files
manual_slop/src/ui_shared.py
T
ed c4811f00c1 fix(gui): Final Phase 7 stabilization and polish
- Resolve ImportError by correctly prefixing 'src' in modular renderers.
- Fix ImGui access violation by ensuring push_id always receives string IDs.
- Restore visible role-based background tints using layered rendering (channels).
- Definitively fix horizontal Markdown table widths by forcing group expansion.
- Centralize color management in theme_2.py and ui_shared.py.
- Standardize Files & Media inventory layout and remove legacy controls.
- Update test mocks to support modular UI and theme-driven styling.
2026-06-02 13:27:38 -04:00

45 lines
2.1 KiB
Python

from __future__ import annotations
from imgui_bundle import imgui
from typing import TYPE_CHECKING, Any
from src import imgui_scopes as imscope
if TYPE_CHECKING:
from src.gui_2 import App
# Standard Color Constants (normalized to 0-1)
def vec4(r: float, g: float, b: float, a: float = 1.0) -> imgui.ImVec4:
return imgui.ImVec4(r/255.0, g/255.0, b/255.0, a)
C_OUT: imgui.ImVec4 = vec4(100, 200, 255)
C_IN: imgui.ImVec4 = vec4(140, 255, 160)
C_REQ: imgui.ImVec4 = vec4(255, 220, 100)
C_RES: imgui.ImVec4 = vec4(180, 255, 180)
C_TC: imgui.ImVec4 = vec4(255, 180, 80)
C_TR: imgui.ImVec4 = vec4(180, 220, 255)
C_TRS: imgui.ImVec4 = vec4(200, 180, 255)
C_LBL: imgui.ImVec4 = vec4(180, 180, 180)
C_VAL: imgui.ImVec4 = vec4(220, 220, 220)
C_KEY: imgui.ImVec4 = vec4(140, 200, 255)
C_NUM: imgui.ImVec4 = vec4(180, 255, 180)
C_TRM: imgui.ImVec4 = vec4(160, 160, 150) # Trimmed/Cruft
C_SUB: imgui.ImVec4 = vec4(220, 200, 120)
def render_text_viewer(app: 'App', label: str, content: str, text_type: str = 'text', force_open: bool = False, id_suffix: str = "") -> None:
if imgui.button(f"[+]##{id_suffix or str(id(content))}") or force_open:
app.text_viewer_type = text_type
app.show_windows["Text Viewer"] = True
app.text_viewer_title = label
app.text_viewer_content = content
def render_selectable_label(app: 'App', label: str, value: str, width: float = 0.0, multiline: bool = False, height: float = 0.0, color: Any = None) -> None:
with imscope.id(label + str(hash(value))):
with imscope.style_color(imgui.Col_.frame_bg, imgui.ImVec4(0, 0, 0, 0)), \
imscope.style_var(imgui.StyleVar_.frame_border_size, 0.0):
if color:
with imscope.style_color(imgui.Col_.text, color):
if multiline: _, _ = imgui.input_text_multiline(f"##{label}", value, imgui.ImVec2(width, height), imgui.InputTextFlags_.read_only)
else: _, _ = imgui.input_text(f"##{label}", value, imgui.InputTextFlags_.read_only)
else:
if multiline: _, _ = imgui.input_text_multiline(f"##{label}", value, imgui.ImVec2(width, height), imgui.InputTextFlags_.read_only)
else: _, _ = imgui.input_text(f"##{label}", value, imgui.InputTextFlags_.read_only)