diff --git a/core/src/gui/icons.cpp b/core/src/gui/icons.cpp index bf0c6e5..72447e4 100644 --- a/core/src/gui/icons.cpp +++ b/core/src/gui/icons.cpp @@ -13,6 +13,8 @@ namespace icons { ImTextureID MENU; ImTextureID MUTED; ImTextureID UNMUTED; + ImTextureID NORMAL_TUNING; + ImTextureID CENTER_TUNING; GLuint loadTexture(std::string path) { int w,h,n; @@ -35,5 +37,7 @@ namespace icons { MENU = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/menu.png"); MUTED = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/muted.png"); UNMUTED = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/unmuted.png"); + NORMAL_TUNING = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/normal_tuning.png"); + CENTER_TUNING = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/center_tuning.png"); } } \ No newline at end of file diff --git a/core/src/gui/icons.h b/core/src/gui/icons.h index e71ca59..74c4a84 100644 --- a/core/src/gui/icons.h +++ b/core/src/gui/icons.h @@ -10,6 +10,8 @@ namespace icons { extern ImTextureID MENU; extern ImTextureID MUTED; extern ImTextureID UNMUTED; + extern ImTextureID NORMAL_TUNING; + extern ImTextureID CENTER_TUNING; GLuint loadTexture(std::string path); void load(); diff --git a/core/src/gui/main_window.cpp b/core/src/gui/main_window.cpp index 0a37085..702ca88 100644 --- a/core/src/gui/main_window.cpp +++ b/core/src/gui/main_window.cpp @@ -163,6 +163,8 @@ void windowInit() { // Add default main config to avoid having to ship one // Have a good directory system on both linux and windows (should fix occassional underruns) // Switch to double buffering + // Fix gain not updated on startup, soapysdr + // Fix memory leak when enabling and disabling repeatedly // TODO for 0.2.6 // Add a module add/remove/change order menu @@ -232,6 +234,7 @@ void setVFO(double freq) { if (centerTuning) { gui::waterfall.setViewOffset((BW / 2.0) - (viewBW / 2.0)); gui::waterfall.setCenterFrequency(freq); + gui::waterfall.setViewOffset(0); sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, 0); sigpath::sourceManager.tune(freq); return; @@ -310,6 +313,9 @@ void drawWindow() { if (vfo != NULL) { if (vfo->centerOffsetChanged) { + if (centerTuning) { + setVFO(gui::waterfall.getCenterFrequency() + vfo->generalOffset); + } gui::freqSelect.setFrequency(gui::waterfall.getCenterFrequency() + vfo->generalOffset); gui::freqSelect.frequencyChanged = false; core::configManager.aquire(); @@ -401,12 +407,37 @@ void drawWindow() { ImGui::SameLine(); //ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 8); - sigpath::sinkManager.showVolumeSlider(gui::waterfall.selectedVFO, "##_sdrpp_main_volume_", 248, 30, 5); + sigpath::sinkManager.showVolumeSlider(gui::waterfall.selectedVFO, "##_sdrpp_main_volume_", 248, 30, 5, true); ImGui::SameLine(); gui::freqSelect.draw(); + //ImGui::SameLine(); + + ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 9); + if (centerTuning) { + ImGui::PushID(ImGui::GetID("sdrpp_ena_st_btn")); + if (ImGui::ImageButton(icons::CENTER_TUNING, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5)) { + centerTuning = false; + core::configManager.aquire(); + core::configManager.conf["centerTuning"] = centerTuning; + core::configManager.release(true); + } + ImGui::PopID(); + } + else { // TODO: Might need to check if there even is a device + ImGui::PushID(ImGui::GetID("sdrpp_dis_st_btn")); + if (ImGui::ImageButton(icons::NORMAL_TUNING, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5)) { + centerTuning = true; + setVFO(gui::freqSelect.frequency); + core::configManager.aquire(); + core::configManager.conf["centerTuning"] = centerTuning; + core::configManager.release(true); + } + ImGui::PopID(); + } + ImGui::SameLine(); // Logo button diff --git a/core/src/gui/widgets/frequency_select.cpp b/core/src/gui/widgets/frequency_select.cpp index be0d211..ba611bb 100644 --- a/core/src/gui/widgets/frequency_select.cpp +++ b/core/src/gui/widgets/frequency_select.cpp @@ -151,7 +151,10 @@ void FrequencySelect::draw() { frequency = freq; ImGui::PopFont(); - ImGui::NewLine(); + + ImGui::SetCursorPosX(digitBottomMaxs[11].x + 17); + + //ImGui::NewLine(); } void FrequencySelect::setFrequency(uint64_t freq) { diff --git a/core/src/signal_path/sink.cpp b/core/src/signal_path/sink.cpp index a1a2d3a..90361ab 100644 --- a/core/src/signal_path/sink.cpp +++ b/core/src/signal_path/sink.cpp @@ -164,7 +164,7 @@ void SinkManager::setStreamSink(std::string name, std::string providerName) { spdlog::warn("setStreamSink is NOT implemented!!!"); } -void SinkManager::showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight, int btwBorder) { +void SinkManager::showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight, int btwBorder, bool sameLine) { // TODO: Replace map with some hashmap for it to be faster float height = ImGui::GetTextLineHeightWithSpacing() + 2; float sliderHeight = height; @@ -185,6 +185,7 @@ void SinkManager::showVolumeSlider(std::string name, std::string prefix, float w ImGui::SetCursorPosY(ypos + ((height - sliderHeight) / 2.0f) + btwBorder); ImGui::SliderFloat((prefix + name).c_str(), &dummy, 0.0f, 1.0f, ""); style::endDisabled(); + if (sameLine) { ImGui::SetCursorPosY(ypos); } return; } @@ -221,6 +222,7 @@ void SinkManager::showVolumeSlider(std::string name, std::string prefix, float w saveStreamConfig(name); core::configManager.release(true); } + if (sameLine) { ImGui::SetCursorPosY(ypos); } //ImGui::SetCursorPosY(ypos); } diff --git a/core/src/signal_path/sink.h b/core/src/signal_path/sink.h index 26e8ec4..ca30355 100644 --- a/core/src/signal_path/sink.h +++ b/core/src/signal_path/sink.h @@ -99,7 +99,7 @@ public: void setStreamSink(std::string name, std::string providerName); - void showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight = -1.0f, int btwBorder = 0); + void showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight = -1.0f, int btwBorder = 0, bool sameLine = false); dsp::stream* bindStream(std::string name); void unbindStream(std::string name, dsp::stream* stream); diff --git a/root_dev/config.json b/root_dev/config.json index 3b68a2e..07af47b 100644 --- a/root_dev/config.json +++ b/root_dev/config.json @@ -1,9 +1,9 @@ { "bandPlan": "General", "bandPlanEnabled": true, - "centerTuning": false, + "centerTuning": true, "fftHeight": 300, - "frequency": 100100000, + "frequency": 99000000, "max": 0.0, "maximized": false, "menuOrder": [ @@ -41,7 +41,7 @@ "Radio": { "muted": false, "sink": "Audio", - "volume": 0.29591837525367737 + "volume": 0.47959184646606445 }, "Radio 1": { "muted": false, diff --git a/root_dev/res/icons/center_tuning.png b/root_dev/res/icons/center_tuning.png new file mode 100644 index 0000000..00bf848 Binary files /dev/null and b/root_dev/res/icons/center_tuning.png differ diff --git a/root_dev/res/icons/normal_tuning.png b/root_dev/res/icons/normal_tuning.png new file mode 100644 index 0000000..76d171e Binary files /dev/null and b/root_dev/res/icons/normal_tuning.png differ