SDRPlusPlus/core/src/gui/menus/source.cpp

33 lines
958 B
C++
Raw Normal View History

#include <gui/menus/source.h>
2020-10-01 01:21:15 +02:00
#include <imgui.h>
#include <gui/gui.h>
#include <core.h>
#include <signal_path/signal_path.h>
namespace sourecmenu {
2020-10-01 01:21:15 +02:00
int sourceId = 0;
2020-10-01 01:21:15 +02:00
void init() {
// Select default
// TODO: Replace by setting
if (sigpath::sourceManager.sourceNames.size() > 0) {
sigpath::sourceManager.selectSource(sigpath::sourceManager.sourceNames[0]);
}
}
void draw(void* ctx) {
2020-10-01 01:21:15 +02:00
std::string items = "";
for (std::string name : sigpath::sourceManager.sourceNames) {
items += name;
items += '\0';
}
float itemWidth = ImGui::GetContentRegionAvailWidth();
2020-10-01 01:21:15 +02:00
ImGui::SetNextItemWidth(itemWidth);
if (ImGui::Combo("##source", &sourceId, items.c_str())) {
sigpath::sourceManager.selectSource(sigpath::sourceManager.sourceNames[sourceId]);
}
sigpath::sourceManager.showSelectedMenu();
}
}