From 9805e4a3958671747d19d1d785ecc5a636ee47d1 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Mon, 30 Nov 2020 21:17:36 +0100 Subject: [PATCH] Fixed loading screen --- CMakeLists.txt | 6 +- core/src/core.cpp | 26 ++----- core/src/gui/dialogs/credits.cpp | 6 +- core/src/gui/dialogs/loading_screen.cpp | 91 +++++++++++++++++++++++++ core/src/gui/dialogs/loading_screen.h | 10 +++ core/src/gui/frequency_select.cpp | 4 +- core/src/gui/frequency_select.h | 1 - core/src/gui/gui.h | 1 + core/src/gui/main_window.cpp | 3 + core/src/gui/style.cpp | 12 +++- core/src/gui/style.h | 5 ++ core/src/module.cpp | 7 ++ root_dev/config.json | 2 +- root_dev/module_list.json | 14 ++-- root_dev/soapy_source_config.json | 4 +- 15 files changed, 149 insertions(+), 43 deletions(-) create mode 100644 core/src/gui/dialogs/loading_screen.cpp create mode 100644 core/src/gui/dialogs/loading_screen.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 98b12b80..0c024e82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,12 +6,12 @@ add_subdirectory("core") add_subdirectory("radio") add_subdirectory("recorder") add_subdirectory("soapy") -add_subdirectory("file_source") +#add_subdirectory("file_source") add_subdirectory("rtl_tcp_source") add_subdirectory("audio_sink") -add_subdirectory("rx888_source") +#add_subdirectory("rx888_source") add_subdirectory("plutosdr_source") -add_subdirectory("demo") +#add_subdirectory("demo") if (MSVC) set(CMAKE_CXX_FLAGS "-O2 /std:c++17") diff --git a/core/src/core.cpp b/core/src/core.cpp index ddd34286..90685555 100644 --- a/core/src/core.cpp +++ b/core/src/core.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -153,34 +154,17 @@ int sdrpp_main() { style::setDarkStyle(); + LoadingScreen::setWindow(window); - // ==================================================== - glfwPollEvents(); - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplGlfw_NewFrame(); - ImGui::NewFrame(); - - ImGui::Begin("Main", NULL, WINDOW_FLAGS); - ImGui::ShowDemoWindow(); - ImGui::End(); - - ImGui::Render(); - int display_w, display_h; - glfwGetFramebufferSize(window, &display_w, &display_h); - glViewport(0, 0, display_w, display_h); - glClearColor(0.0666f, 0.0666f, 0.0666f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); - - glfwSwapBuffers(window); - // ==================================================== - + LoadingScreen::show("Loading icons"); spdlog::info("Loading icons"); icons::load(); + LoadingScreen::show("Loading band plans"); spdlog::info("Loading band plans"); bandplan::loadFromDir(ROOT_DIR "/bandplans"); + LoadingScreen::show("Loading band plan colors"); spdlog::info("Loading band plans color table"); bandplan::loadColorTable(ROOT_DIR "/band_colors.json"); diff --git a/core/src/gui/dialogs/credits.cpp b/core/src/gui/dialogs/credits.cpp index a8fa5986..143f92a5 100644 --- a/core/src/gui/dialogs/credits.cpp +++ b/core/src/gui/dialogs/credits.cpp @@ -1,14 +1,14 @@ #include #include #include +#include #include namespace credits { ImFont* bigFont; void init() { - // TODO: Have a font manager instead - bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 128.0f); + } void show() { @@ -16,7 +16,7 @@ namespace credits { ImGui::OpenPopup("Credits"); ImGui::BeginPopupModal("Credits", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove); - ImGui::PushFont(bigFont); + ImGui::PushFont(style::hugeFont); ImGui::Text("SDR++ "); ImGui::PopFont(); ImGui::SameLine(); diff --git a/core/src/gui/dialogs/loading_screen.cpp b/core/src/gui/dialogs/loading_screen.cpp new file mode 100644 index 00000000..0cd897bb --- /dev/null +++ b/core/src/gui/dialogs/loading_screen.cpp @@ -0,0 +1,91 @@ +#include +#include +#include +#include +#include "imgui_impl_glfw.h" +#include "imgui_impl_opengl3.h" +#include +#include + +namespace LoadingScreen { + GLFWwindow* _win; + + void setWindow(GLFWwindow* win) { + _win = win; + } + + void show(std::string msg) { + glfwPollEvents(); + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplGlfw_NewFrame(); + + ImGui::NewFrame(); + ImGui::Begin("Main", NULL, WINDOW_FLAGS); + + + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20.0f, 20.0f)); + ImGui::OpenPopup("Credits"); + ImGui::PushStyleColor(ImGuiCol_ModalWindowDarkening, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); + ImGui::BeginPopupModal("Credits", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground); + + ImGui::PushFont(style::hugeFont); + ImGui::Text("SDR++ "); + ImGui::PopFont(); + ImGui::SameLine(); + ImGui::Image(icons::LOGO, ImVec2(128, 128)); + ImGui::Spacing(); + ImGui::Spacing(); + ImGui::Spacing(); + + ImGui::Text("This software is brought to you by\n\n"); + + ImGui::Columns(3, "CreditColumns", true); + + // Contributors + ImGui::Text("Contributors"); + ImGui::BulletText("Ryzerth (Creator)"); + ImGui::BulletText("aosync"); + ImGui::BulletText("Benjamin Kyd"); + ImGui::BulletText("Tobias Mädel"); + ImGui::BulletText("Raov"); + ImGui::BulletText("Howard0su"); + + // Libraries + ImGui::NextColumn(); + ImGui::Text("Libraries"); + ImGui::BulletText("SoapySDR (PothosWare)"); + ImGui::BulletText("Dear ImGui (ocornut)"); + ImGui::BulletText("spdlog (gabime)"); + ImGui::BulletText("json (nlohmann)"); + ImGui::BulletText("portaudio (PA Comm.)"); + + // Patrons + ImGui::NextColumn(); + ImGui::Text("Patrons"); + ImGui::BulletText("SignalsEverywhere"); + ImGui::BulletText("Lee Donaghy"); + + ImGui::Columns(1, "CreditColumnsEnd", true); + + ImGui::Spacing(); + ImGui::Spacing(); + ImGui::Spacing(); + ImGui::Text(msg.c_str()); + + ImGui::EndPopup(); + ImGui::PopStyleVar(1); + ImGui::PopStyleColor(1); + + ImGui::End(); + + ImGui::Render(); + int display_w, display_h; + glfwGetFramebufferSize(_win, &display_w, &display_h); + glViewport(0, 0, display_w, display_h); + glClearColor(0.0666f, 0.0666f, 0.0666f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + + glfwSwapBuffers(_win); + } +} \ No newline at end of file diff --git a/core/src/gui/dialogs/loading_screen.h b/core/src/gui/dialogs/loading_screen.h new file mode 100644 index 00000000..fd5ef5fe --- /dev/null +++ b/core/src/gui/dialogs/loading_screen.h @@ -0,0 +1,10 @@ +#pragma once +#include +#include +#include +#include + +namespace LoadingScreen { + void setWindow(GLFWwindow* win); + void show(std::string msg); +}; \ No newline at end of file diff --git a/core/src/gui/frequency_select.cpp b/core/src/gui/frequency_select.cpp index 25f25f37..d0f96363 100644 --- a/core/src/gui/frequency_select.cpp +++ b/core/src/gui/frequency_select.cpp @@ -1,5 +1,6 @@ #include #include +#include bool isInArea(ImVec2 val, ImVec2 min, ImVec2 max) { return val.x >= min.x && val.x < max.x && val.y >= min.y && val.y < max.y; @@ -10,7 +11,6 @@ FrequencySelect::FrequencySelect() { } void FrequencySelect::init() { - font = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 42.0f); for (int i = 0; i < 12; i++) { digits[i] = 0; @@ -76,7 +76,7 @@ void FrequencySelect::draw() { widgetEndPos.y += window->Pos.y - 3; widgetSize = ImVec2(widgetEndPos.x - widgetPos.x, widgetEndPos.y - widgetPos.y); - ImGui::PushFont(font); + ImGui::PushFont(style::bigFont); if (widgetPos.x != lastWidgetPos.x || widgetPos.y != lastWidgetPos.y) { lastWidgetPos = widgetPos; diff --git a/core/src/gui/frequency_select.h b/core/src/gui/frequency_select.h index ebbe9bae..1a81a9f2 100644 --- a/core/src/gui/frequency_select.h +++ b/core/src/gui/frequency_select.h @@ -27,7 +27,6 @@ private: ImVec2 lastWidgetSize; ImGuiWindow* window; - ImFont* font; int digits[12]; ImVec2 digitBottomMins[12]; diff --git a/core/src/gui/gui.h b/core/src/gui/gui.h index aa241d3b..1e371638 100644 --- a/core/src/gui/gui.h +++ b/core/src/gui/gui.h @@ -2,6 +2,7 @@ #include #include #include +#include #include namespace gui { diff --git a/core/src/gui/main_window.cpp b/core/src/gui/main_window.cpp index 7d7598e6..4132d48e 100644 --- a/core/src/gui/main_window.cpp +++ b/core/src/gui/main_window.cpp @@ -29,6 +29,7 @@ #include #include #include +#include std::thread worker; std::mutex fft_mtx; @@ -83,6 +84,7 @@ bool showMenu = true; dsp::stream dummyStream; void windowInit() { + LoadingScreen::show("Initializing UI"); gui::waterfall.init(); credits::init(); @@ -130,6 +132,7 @@ void windowInit() { // And a module add/remove/change order menu // Update UI settings + LoadingScreen::show("Loading configuration"); core::configManager.aquire(); fftMin = core::configManager.conf["min"]; fftMax = core::configManager.conf["max"]; diff --git a/core/src/gui/style.cpp b/core/src/gui/style.cpp index 2541bd5a..c22dd806 100644 --- a/core/src/gui/style.cpp +++ b/core/src/gui/style.cpp @@ -4,6 +4,10 @@ #include namespace style { + ImFont* baseFont; + ImFont* bigFont; + ImFont* hugeFont; + void setDefaultStyle() { ImGui::GetStyle().WindowRounding = 0.0f; ImGui::GetStyle().ChildRounding = 0.0f; @@ -12,7 +16,9 @@ namespace style { ImGui::GetStyle().PopupRounding = 0.0f; ImGui::GetStyle().ScrollbarRounding = 0.0f; - ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 16.0f); + baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 16.0f); + bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 42.0f); + hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 128.0f); ImGui::StyleColorsDark(); //ImGui::StyleColorsLight(); @@ -30,7 +36,9 @@ namespace style { ImGui::GetStyle().PopupRounding = 0.0f; ImGui::GetStyle().ScrollbarRounding = 0.0f; - ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 16.0f); + baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 16.0f); + bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 42.0f); + hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 128.0f); ImGui::StyleColorsDark(); diff --git a/core/src/gui/style.h b/core/src/gui/style.h index 13e62c9e..c76f81c8 100644 --- a/core/src/gui/style.h +++ b/core/src/gui/style.h @@ -1,6 +1,11 @@ #pragma once +#include namespace style { + extern ImFont* baseFont; + extern ImFont* bigFont; + extern ImFont* hugeFont; + void setDefaultStyle(); void setDarkStyle(); void beginDisabled(); diff --git a/core/src/module.cpp b/core/src/module.cpp index 05c9ed94..2afb9e1a 100644 --- a/core/src/module.cpp +++ b/core/src/module.cpp @@ -3,6 +3,7 @@ #include #include #include +#include using nlohmann::json; @@ -88,6 +89,12 @@ namespace mod { std::map list = data.get>(); for (auto const& [name, file] : list) { + std::string msg = "Loading "; + msg += name; + msg += " ("; + msg += file; + msg += ")"; + LoadingScreen::show(msg); spdlog::info("Loading {0} ({1})", name, file); loadModule(file, name); } diff --git a/root_dev/config.json b/root_dev/config.json index 9cccba4b..f87cc3f3 100644 --- a/root_dev/config.json +++ b/root_dev/config.json @@ -40,7 +40,7 @@ "sourceSettings": {}, "streams": { "Radio": { - "muted": false, + "muted": true, "sink": "Audio", "volume": 0.65625 } diff --git a/root_dev/module_list.json b/root_dev/module_list.json index bacdf9ce..5187e16c 100644 --- a/root_dev/module_list.json +++ b/root_dev/module_list.json @@ -1,10 +1,8 @@ { - "Radio": "./radio/RelWithDebInfo/radio.dll", - "Recorder": "./recorder/RelWithDebInfo/recorder.dll", - "Soapy": "./soapy/RelWithDebInfo/soapy.dll", - "RTLTCPSource": "./rtl_tcp_source/RelWithDebInfo/rtl_tcp_source.dll", - "FileSource": "./file_source/RelWithDebInfo/file_source.dll", - "RX888Source": "./rx888_source/RelWithDebInfo/rx888_source.dll", - "PlutoSDRSource": "./plutosdr_source/RelWithDebInfo/plutosdr_source.dll", - "AudioSink": "./audio_sink/RelWithDebInfo/audio_sink.dll" + "Radio": "./radio/Release/radio.dll", + "Recorder": "./recorder/Release/recorder.dll", + "Soapy": "./soapy/Release/soapy.dll", + "RTLTCPSource": "./rtl_tcp_source/Release/rtl_tcp_source.dll", + "PlutoSDRSource": "./plutosdr_source/Release/plutosdr_source.dll", + "AudioSink": "./audio_sink/Release/audio_sink.dll" } diff --git a/root_dev/soapy_source_config.json b/root_dev/soapy_source_config.json index 84c2fc7b..bae23563 100644 --- a/root_dev/soapy_source_config.json +++ b/root_dev/soapy_source_config.json @@ -1,5 +1,5 @@ { - "device": "", + "device": "Generic RTL2832U OEM :: 00000001", "devices": { "": { "gains": { @@ -22,7 +22,7 @@ }, "Generic RTL2832U OEM :: 00000001": { "gains": { - "TUNER": 0.0 + "TUNER": 23.406999588012695 }, "sampleRate": 2560000.0 },