Skip to content

Commit

Permalink
Fixed loading screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryzerth committed Nov 30, 2020
1 parent 6a01c9d commit 9805e4a
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 43 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
26 changes: 5 additions & 21 deletions core/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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");

Expand Down
6 changes: 3 additions & 3 deletions core/src/gui/dialogs/credits.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#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() {
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20.0f, 20.0f));
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();
Expand Down
91 changes: 91 additions & 0 deletions core/src/gui/dialogs/loading_screen.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
}
10 changes: 10 additions & 0 deletions core/src/gui/dialogs/loading_screen.h
Original file line number Diff line number Diff line change
@@ -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);
};
4 changes: 2 additions & 2 deletions core/src/gui/frequency_select.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion core/src/gui/frequency_select.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class FrequencySelect {
ImVec2 lastWidgetSize;

ImGuiWindow* window;
ImFont* font;

int digits[12];
ImVec2 digitBottomMins[12];
Expand Down
1 change: 1 addition & 0 deletions core/src/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions core/src/gui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -83,6 +84,7 @@ bool showMenu = true;
dsp::stream<dsp::complex_t> dummyStream;

void windowInit() {
LoadingScreen::show("Initializing UI");
gui::waterfall.init();

credits::init();
Expand Down Expand Up @@ -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"];
Expand Down
12 changes: 10 additions & 2 deletions core/src/gui/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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();

Expand Down
5 changes: 5 additions & 0 deletions core/src/gui/style.h
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
7 changes: 7 additions & 0 deletions core/src/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <spdlog/spdlog.h>
#include <json.hpp>
#include <fstream>
#include <gui/dialogs/loading_screen.h>

using nlohmann::json;

Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion root_dev/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"sourceSettings": {},
"streams": {
"Radio": {
"muted": false,
"muted": true,
"sink": "Audio",
"volume": 0.65625
}
Expand Down
14 changes: 6 additions & 8 deletions root_dev/module_list.json
Original file line number Diff line number Diff line change
@@ -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"
}
4 changes: 2 additions & 2 deletions root_dev/soapy_source_config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"device": "",
"device": "Generic RTL2832U OEM :: 00000001",
"devices": {
"": {
"gains": {
Expand All @@ -22,7 +22,7 @@
},
"Generic RTL2832U OEM :: 00000001": {
"gains": {
"TUNER": 0.0
"TUNER": 23.406999588012695
},
"sampleRate": 2560000.0
},
Expand Down

0 comments on commit 9805e4a

Please sign in to comment.