From 3422998bd1d1e3a014a060fef2eb784ae104f61f Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Thu, 11 Feb 2021 15:29:51 +0100 Subject: [PATCH] fixed file select and folder select widget bug --- core/src/gui/widgets/file_select.cpp | 2 +- core/src/gui/widgets/folder_select.cpp | 2 +- sdrplay_source/CMakeLists.txt | 9 +++++---- sdrplay_source/src/main.cpp | 27 +++++++++++++++++++++----- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/core/src/gui/widgets/file_select.cpp b/core/src/gui/widgets/file_select.cpp index d976458d..075d6865 100644 --- a/core/src/gui/widgets/file_select.cpp +++ b/core/src/gui/widgets/file_select.cpp @@ -11,8 +11,8 @@ FileSelect::FileSelect(std::string defaultPath) { bool FileSelect::render(std::string id) { bool _pathChanged = false; -#ifdef _WIN32 float menuColumnWidth = ImGui::GetContentRegionAvailWidth(); +#ifdef _WIN32 float buttonWidth = ImGui::CalcTextSize("...").x + 20.0f; bool lastPathValid = pathValid; if (!lastPathValid) { diff --git a/core/src/gui/widgets/folder_select.cpp b/core/src/gui/widgets/folder_select.cpp index 0a7c9189..5633408e 100644 --- a/core/src/gui/widgets/folder_select.cpp +++ b/core/src/gui/widgets/folder_select.cpp @@ -9,8 +9,8 @@ FolderSelect::FolderSelect(std::string defaultPath) { bool FolderSelect::render(std::string id) { bool _pathChanged = false; -#ifdef _WIN32 float menuColumnWidth = ImGui::GetContentRegionAvailWidth(); +#ifdef _WIN32 float buttonWidth = ImGui::CalcTextSize("...").x + 20.0f; bool lastPathValid = pathValid; if (!lastPathValid) { diff --git a/sdrplay_source/CMakeLists.txt b/sdrplay_source/CMakeLists.txt index f9e7bf36..be7e9017 100644 --- a/sdrplay_source/CMakeLists.txt +++ b/sdrplay_source/CMakeLists.txt @@ -18,14 +18,15 @@ set_target_properties(sdrplay_source PROPERTIES PREFIX "") if (MSVC) # Lib path target_link_directories(sdrpp_core PUBLIC "C:/Program Files/SDRplay/API/x64") + target_include_directories(sdrplay_source PUBLIC "C:/Program Files/SDRplay/API/inc") target_link_libraries(sdrplay_source PUBLIC sdrplay_api) else (MSVC) find_package(PkgConfig) - pkg_check_modules(LIBAIRSPYHF REQUIRED libairspy) + pkg_check_modules(LIBSDRPLAY REQUIRED libsdrplay) - target_include_directories(sdrplay_source PUBLIC ${LIBAIRSPYHF_INCLUDE_DIRS}) - target_link_directories(sdrplay_source PUBLIC ${LIBAIRSPYHF_LIBRARY_DIRS}) - target_link_libraries(sdrplay_source PUBLIC ${LIBAIRSPYHF_LIBRARIES}) + target_include_directories(sdrplay_source PUBLIC ${LIBSDRPLAY_INCLUDE_DIRS}) + target_link_directories(sdrplay_source PUBLIC ${LIBSDRPLAY_LIBRARY_DIRS}) + target_link_libraries(sdrplay_source PUBLIC ${LIBSDRPLAY_LIBRARIES}) endif (MSVC) \ No newline at end of file diff --git a/sdrplay_source/src/main.cpp b/sdrplay_source/src/main.cpp index cf1de8e2..f310bbb3 100644 --- a/sdrplay_source/src/main.cpp +++ b/sdrplay_source/src/main.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #define CONCAT(a, b) ((std::string(a) + b).c_str()) @@ -27,6 +27,8 @@ public: SDRPlaySourceModule(std::string name) { this->name = name; + sdrplay_api_Open(); + sampleRate = 10000000.0; handler.ctx = this; @@ -54,7 +56,7 @@ public: } ~SDRPlaySourceModule() { - + sdrplay_api_Close(); } void enable() { @@ -73,7 +75,15 @@ public: devList.clear(); devListTxt = ""; - // Fill in list here + sdrplay_api_DeviceT devArr[128]; + unsigned int numDev = 0; + sdrplay_api_GetDevices(devArr, &numDev, 128); + + for (unsigned int i = 0; i < numDev; i++) { + devList.push_back(devArr[i].SerNo); + devListTxt += devArr[i].SerNo; + devListTxt += '\0'; + } } private: @@ -145,7 +155,12 @@ private: ImGui::SetNextItemWidth(menuWidth); - // Menu here + if (_this->running) { style::beginDisabled(); } + if (ImGui::Combo(CONCAT("##sdrplay_dev", _this->name), &_this->devId, _this->devListTxt.c_str())) { + + } + + if (_this->running) { style::endDisabled(); } } @@ -158,10 +173,12 @@ private: bool running = false; double freq; + sdrplay_api_DeviceT openDev; + int devId = 0; int srId = 0; - std::vector devList; + std::vector devList; std::string devListTxt; std::vector sampleRateList; std::string sampleRateListTxt;