LCOV - code coverage report
Current view: top level - src/gui/components - led.cpp (source / functions) Coverage Total Hit
Test: merged.info Lines: 93.3 % 30 28
Test Date: 2026-06-03 09:13:19 Functions: 100.0 % 1 1

            Line data    Source code
       1              : #include "gui/components/led.h"
       2              : #include "gui/theme/theme.h"
       3              : 
       4              : namespace Amplitron {
       5              : 
       6          186 : void LedComponent::render(const char* imgui_id, const LedProps& props, float zoom, ImVec2 center) {
       7          186 :     ImDrawList* dl = ImGui::GetWindowDrawList();
       8              : 
       9          186 :     float radius = 6.0f * zoom;
      10          186 :     float glow_radius = 10.0f * zoom;
      11              : 
      12          186 :     ImU32 base_color = Theme::LED_OFF;
      13          186 :     bool is_on = props.enabled;
      14              : 
      15          186 :     if (props.blink) {
      16              :         // Blinking alpha oscillation
      17           12 :         ImVec4 osc = Theme::RecBlink(props.blink_time);
      18           12 :         if (is_on) {
      19            8 :             base_color = ImGui::ColorConvertFloat4ToU32(
      20            8 :                 ImVec4(props.led_color.x, props.led_color.y, props.led_color.z, osc.w)
      21              :             );
      22            2 :         }
      23          178 :     } else if (is_on) {
      24          165 :         base_color = ImGui::ColorConvertFloat4ToU32(props.led_color);
      25           55 :     }
      26              : 
      27          186 :     dl->AddCircleFilled(center, radius, base_color);
      28              : 
      29          186 :     if (is_on) {
      30          171 :         int glow_alpha = props.blink ? static_cast<int>(Theme::RecBlink(props.blink_time).w * 40) : 40;
      31          228 :         dl->AddCircleFilled(center, glow_radius,
      32          171 :             IM_COL32(
      33              :                 static_cast<int>(props.led_color.x * 255),
      34              :                 static_cast<int>(props.led_color.y * 255),
      35              :                 static_cast<int>(props.led_color.z * 255),
      36              :                 glow_alpha
      37              :             )
      38              :         );
      39           57 :     }
      40              : 
      41          186 :     if (props.tooltip) {
      42          186 :         ImGui::SetCursorScreenPos(ImVec2(center.x - 10.0f * zoom, center.y - 10.0f * zoom));
      43          186 :         ImGui::SetNextItemAllowOverlap();
      44          186 :         ImGui::InvisibleButton(imgui_id, ImVec2(20.0f * zoom, 20.0f * zoom));
      45          186 :         if (ImGui::IsItemHovered()) {
      46            0 :             ImGui::SetTooltip("%s", props.tooltip);
      47            0 :         }
      48           62 :     }
      49          186 : }
      50              : 
      51              : } // namespace Amplitron
        

Generated by: LCOV version 2.0-1