Fixed loading screen

This commit is contained in:
Ryzerth 2020-11-30 21:17:36 +01:00
parent 6a01c9d426
commit 9805e4a395
15 changed files with 149 additions and 43 deletions

View File

@ -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")

View File

@ -6,6 +6,7 @@
#include <GLFW/glfw3.h>
#include <gui/main_window.h>
#include <gui/style.h>
#include <gui/gui.h>
#include <gui/icons.h>
#include <version.h>
#include <spdlog/spdlog.h>
@ -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");

View File

@ -1,14 +1,14 @@
#include <gui/dialogs/credits.h>
#include <imgui.h>
#include <gui/icons.h>
#include <gui/style.h>
#include <config.h>
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();

View File

@ -0,0 +1,91 @@
#include <GL/glew.h>
#include <gui/dialogs/loading_screen.h>
#include <gui/main_window.h>
#include <imgui.h>
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include <gui/icons.h>
#include <gui/style.h>
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);
}
}

View File

@ -0,0 +1,10 @@
#pragma once
#include <thread>
#include <string>
#include <mutex>
#include <GLFW/glfw3.h>
namespace LoadingScreen {
void setWindow(GLFWwindow* win);
void show(std::string msg);
};

View File

@ -1,5 +1,6 @@
#include <gui/frequency_select.h>
#include <config.h>
#include <gui/style.h>
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;

View File

@ -27,7 +27,6 @@ private:
ImVec2 lastWidgetSize;
ImGuiWindow* window;
ImFont* font;
int digits[12];
ImVec2 digitBottomMins[12];

View File

@ -2,6 +2,7 @@
#include <gui/waterfall.h>
#include <gui/frequency_select.h>
#include <gui/menu.h>
#include <gui/dialogs/loading_screen.h>
#include <module.h>
namespace gui {

View File

@ -29,6 +29,7 @@
#include <gui/menus/scripting.h>
#include <gui/dialogs/credits.h>
#include <signal_path/source.h>
#include <gui/dialogs/loading_screen.h>
std::thread worker;
std::mutex fft_mtx;
@ -83,6 +84,7 @@ bool showMenu = true;
dsp::stream<dsp::complex_t> 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"];

View File

@ -4,6 +4,10 @@
#include <config.h>
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();

View File

@ -1,6 +1,11 @@
#pragma once
#include <imgui.h>
namespace style {
extern ImFont* baseFont;
extern ImFont* bigFont;
extern ImFont* hugeFont;
void setDefaultStyle();
void setDarkStyle();
void beginDisabled();

View File

@ -3,6 +3,7 @@
#include <spdlog/spdlog.h>
#include <json.hpp>
#include <fstream>
#include <gui/dialogs/loading_screen.h>
using nlohmann::json;
@ -88,6 +89,12 @@ namespace mod {
std::map<std::string, std::string> list = data.get<std::map<std::string, std::string>>();
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);
}

View File

@ -40,7 +40,7 @@
"sourceSettings": {},
"streams": {
"Radio": {
"muted": false,
"muted": true,
"sink": "Audio",
"volume": 0.65625
}

View File

@ -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"
}

View File

@ -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
},