LCOV - code coverage report
Current view: top level - src/gui/components - led.cpp (source / functions) Coverage Total Hit
Test: merged.info Lines: 93.5 % 31 29
Test Date: 2026-06-07 15:51:50 Functions: 100.0 % 1 1

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

Generated by: LCOV version 2.0-1