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

            Line data    Source code
       1              : #include "gui/components/footswitch.h"
       2              : 
       3              : #include <cstdio>
       4              : 
       5              : #include "gui/theme/theme.h"
       6              : 
       7              : namespace Amplitron {
       8              : 
       9          171 : void FootswitchComponent::render(const char* imgui_id, const FootswitchProps& props, float zoom,
      10              :                                  ImVec2 center) {
      11          171 :     ImDrawList* dl = ImGui::GetWindowDrawList();
      12              : 
      13          171 :     float radius = 18.0f * zoom;
      14          171 :     float inner_radius = 12.0f * zoom;
      15          171 :     float hit_w = 50.0f * zoom;
      16          171 :     float hit_h = 30.0f * zoom;
      17              : 
      18          171 :     dl->AddCircleFilled(center, radius, Theme::SWITCH_BODY);
      19          171 :     dl->AddCircle(center, radius, Theme::SWITCH_RING, 0, 2.0f * zoom);
      20          228 :     dl->AddCircleFilled(center, inner_radius,
      21          171 :                         props.enabled ? Theme::SWITCH_ACTIVE : Theme::SWITCH_IDLE);
      22              : 
      23          171 :     ImGui::SetCursorScreenPos(ImVec2(center.x - hit_w * 0.5f, center.y - hit_h * 0.5f));
      24          171 :     ImGui::SetNextItemAllowOverlap();
      25          171 :     ImGui::InvisibleButton(imgui_id, ImVec2(hit_w, hit_h));
      26              : 
      27          171 :     if (ImGui::IsItemClicked() && props.on_clicked) {
      28            3 :         props.on_clicked();
      29            1 :     }
      30              : 
      31          171 :     if (ImGui::IsItemHovered()) {
      32            2 :         char tip[128];
      33            8 :         std::snprintf(tip, sizeof(tip), "%s%s", props.tooltip_prefix,
      34            6 :                       props.enabled ? "Click to bypass" : "Click to enable");
      35            6 :         ImGui::SetTooltip("%s", tip);
      36            2 :     }
      37          171 : }
      38              : 
      39              : }  // namespace Amplitron
        

Generated by: LCOV version 2.0-1