From 9d34c6a8c1f0b2f8723c030df493050ee4a61ab8 Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Mon, 13 Sep 2021 20:07:40 +0200 Subject: [PATCH] Fixed wonky center tuning behavior --- core/src/gui/main_window.cpp | 5 +++++ core/src/gui/widgets/waterfall.cpp | 2 +- core/src/gui/widgets/waterfall.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/gui/main_window.cpp b/core/src/gui/main_window.cpp index 9f29fd0d..954dbd6d 100644 --- a/core/src/gui/main_window.cpp +++ b/core/src/gui/main_window.cpp @@ -188,6 +188,7 @@ void MainWindow::init() { gui::waterfall.setFFTHeight(fftHeight); tuningMode = core::configManager.conf["centerTuning"] ? tuner::TUNER_MODE_CENTER : tuner::TUNER_MODE_NORMAL; + gui::waterfall.VFOMoveSingleClick = (tuningMode == tuner::TUNER_MODE_CENTER); core::configManager.release(); @@ -397,6 +398,7 @@ void MainWindow::draw() { ImGui::PushID(ImGui::GetID("sdrpp_ena_st_btn")); if (ImGui::ImageButton(icons::CENTER_TUNING, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5)) { tuningMode = tuner::TUNER_MODE_NORMAL; + gui::waterfall.VFOMoveSingleClick = false; core::configManager.acquire(); core::configManager.conf["centerTuning"] = false; core::configManager.release(true); @@ -407,6 +409,7 @@ void MainWindow::draw() { ImGui::PushID(ImGui::GetID("sdrpp_dis_st_btn")); if (ImGui::ImageButton(icons::NORMAL_TUNING, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5)) { tuningMode = tuner::TUNER_MODE_CENTER; + gui::waterfall.VFOMoveSingleClick = true; tuner::tune(tuner::TUNER_MODE_CENTER, gui::waterfall.selectedVFO, gui::freqSelect.frequency); core::configManager.acquire(); core::configManager.conf["centerTuning"] = true; @@ -525,6 +528,8 @@ void MainWindow::draw() { firstMenuRender = true; } + ImGui::Checkbox("WF Single Click", &gui::waterfall.VFOMoveSingleClick); + ImGui::Spacing(); } diff --git a/core/src/gui/widgets/waterfall.cpp b/core/src/gui/widgets/waterfall.cpp index 970388ef..8d5eb8b2 100644 --- a/core/src/gui/widgets/waterfall.cpp +++ b/core/src/gui/widgets/waterfall.cpp @@ -418,7 +418,7 @@ namespace ImGui { } // Finally, if nothing else was selected, just move the VFO - if (ImGui::IsMouseDown(ImGuiMouseButton_Left) && (mouseInFFT|mouseInWaterfall) && (mouseMoved || hoveredVFOName == "")) { + if ((VFOMoveSingleClick ? ImGui::IsMouseClicked(ImGuiMouseButton_Left) : ImGui::IsMouseDown(ImGuiMouseButton_Left)) && (mouseInFFT|mouseInWaterfall) && (mouseMoved || hoveredVFOName == "")) { if (selVfo != NULL) { int refCenter = mousePos.x - (widgetPos.x + 50); if (refCenter >= 0 && refCenter < dataWidth) { diff --git a/core/src/gui/widgets/waterfall.h b/core/src/gui/widgets/waterfall.h index 55e4c798..957d821d 100644 --- a/core/src/gui/widgets/waterfall.h +++ b/core/src/gui/widgets/waterfall.h @@ -175,6 +175,7 @@ namespace ImGui { }; bool inputHandled = false; + bool VFOMoveSingleClick = false; Event onInputProcess; enum {