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

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

Generated by: LCOV version 2.0-1