//
// Created by martin on 19.11.21.
//

#include "SyncTrack.h"

#include <imgui.h>

#include <sstream>

void SyncTrack::DrawDebugUi() {
  ImGui::SliderFloat("duration", &m_duration, 0.001f, 10.f);

  ImGui::Text("Marker");
  ImGui::SameLine();
  ImGui::Text("%d", m_num_intervals);
  ImGui::SameLine();
  if (ImGui::Button("+")) {
    if (m_num_intervals < cSyncTrackMaxIntervals) {
      m_num_intervals ++;
    }
  }
  ImGui::SameLine();
  if (ImGui::Button("-")) {
    if (m_num_intervals > 0) {
      m_num_intervals --;
    }
  }

  ImGui::Text("Marker:");
  for (int i = 0; i < m_num_intervals; i++) {
    ImGui::Text("%2d:", i);
    ImGui::SameLine();
    std::ostringstream marker_stream;
    marker_stream << i;
    ImGui::SliderFloat(
        marker_stream.str().c_str(),
        &m_sync_markers[i],
        0.f,
        1.f);
  }

  if (ImGui::Button ("Update Intervals")) {
    CalcIntervals();
  }
}