diff --git a/src/gui_2.py b/src/gui_2.py index 3174327e..0d125393 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -6044,7 +6044,7 @@ def render_patch_modal(app: App) -> None: if opened: p_min = imgui.get_window_pos() p_max = imgui.ImVec2(p_min.x + imgui.get_window_size().x, p_min.y + imgui.get_window_size().y) - shaders.draw_soft_shadow(imgui.get_background_draw_list(), p_min, p_max, imgui.ImVec4(0, 0, 0, 0.6), 25.0, 6.0) + draw_soft_shadow(imgui.get_background_draw_list(), p_min, p_max, imgui.ImVec4(0, 0, 0, 0.6), 25.0, 6.0) imgui.text_colored(theme.get_color("status_warning"), "Tier 4 QA Generated a Patch") imgui.separator() @@ -7013,11 +7013,9 @@ def render_track_proposal_modal(app: App) -> None: if app._show_track_proposal_modal: imgui.open_popup("Track Proposal") if imgui.begin_popup_modal("Track Proposal", True, imgui.WindowFlags_.always_auto_resize)[0]: - from src import shaders #TODO(Ed): Review local import p_min = imgui.get_window_pos() p_max = imgui.ImVec2(p_min.x + imgui.get_window_size().x, p_min.y + imgui.get_window_size().y) - # Render soft shadow behind the modal - shaders.draw_soft_shadow(imgui.get_background_draw_list(), p_min, p_max, imgui.ImVec4(0, 0, 0, 0.6), 25.0, 6.0) + draw_soft_shadow(imgui.get_background_draw_list(), p_min, p_max, imgui.ImVec4(0, 0, 0, 0.6), 25.0, 6.0) if app._show_track_proposal_modal: imgui.text_colored(C_IN(), "Proposed Implementation Tracks") @@ -8483,3 +8481,28 @@ def get_bg() -> BackgroundShader: _bg = BackgroundShader() return _bg #endregion: Bg Shader + +#region: Shaders (moved from src/shaders.py) +def draw_soft_shadow(draw_list: imgui.ImDrawList, p_min: imgui.ImVec2, p_max: imgui.ImVec2, color: imgui.ImVec4, shadow_size: float = 10.0, rounding: float = 0.0) -> None: + r, g, b, a = color.x, color.y, color.z, color.w + steps = int(shadow_size) + if steps <= 0: return + alpha_step = a / steps + for i in range(steps): + current_alpha = a - (i * alpha_step) + current_alpha = current_alpha * (1.0 - (i / steps)**2) + if current_alpha <= 0.01: + continue + expand = float(i) + c_min = imgui.ImVec2(p_min.x - expand, p_min.y - expand) + c_max = imgui.ImVec2(p_max.x + expand, p_max.y + expand) + u32_color = imgui.get_color_u32(imgui.ImVec4(r, g, b, current_alpha)) + draw_list.add_rect( + c_min, + c_max, + u32_color, + rounding + expand if rounding > 0 else 0.0, + flags=imgui.ImDrawFlags_.round_corners_all if rounding > 0 else imgui.ImDrawFlags_.none, + thickness=1.0 + ) +#endregion: Shaders diff --git a/src/shaders.py b/src/shaders.py deleted file mode 100644 index 1cfa3eab..00000000 --- a/src/shaders.py +++ /dev/null @@ -1,35 +0,0 @@ -from imgui_bundle import imgui - - -def draw_soft_shadow(draw_list: imgui.ImDrawList, p_min: imgui.ImVec2, p_max: imgui.ImVec2, color: imgui.ImVec4, shadow_size: float = 10.0, rounding: float = 0.0) -> None: - """ - Simulates a soft shadow effect by drawing multiple concentric rounded rectangles - with decreasing alpha values. This is a faux-shader effect using primitive batching. - """ - r, g, b, a = color.x, color.y, color.z, color.w - steps = int(shadow_size) - if steps <= 0: return - - alpha_step = a / steps - - for i in range(steps): - current_alpha = a - (i * alpha_step) - # Apply an easing function (e.g., cubic) for a smoother shadow falloff - current_alpha = current_alpha * (1.0 - (i / steps)**2) - if current_alpha <= 0.01: - continue - - expand = float(i) - c_min = imgui.ImVec2(p_min.x - expand, p_min.y - expand) - c_max = imgui.ImVec2(p_max.x + expand, p_max.y + expand) - - u32_color = imgui.get_color_u32(imgui.ImVec4(r, g, b, current_alpha)) - - draw_list.add_rect( - c_min, - c_max, - u32_color, - rounding + expand if rounding > 0 else 0.0, - flags=imgui.ImDrawFlags_.round_corners_all if rounding > 0 else imgui.ImDrawFlags_.none, - thickness=1.0 - )