diff --git a/src-interface/main_ui.cpp b/src-interface/main_ui.cpp index 1435d2556..2779b7a0e 100644 --- a/src-interface/main_ui.cpp +++ b/src-interface/main_ui.cpp @@ -9,12 +9,10 @@ #include "core/config.h" #include "core/style.h" -#include "app.h" -#include "viewer/viewer.h" - namespace satdump { - std::shared_ptr current_app; + std::shared_ptr recorder_app; + std::shared_ptr viewer_app; bool in_app = false; // true; @@ -47,19 +45,20 @@ namespace satdump registerApplications(); registerViewerHandlers(); - // current_app = application_registry["viewer"](); + recorder_app = std::make_shared(); + viewer_app = std::make_shared(); } void renderMainUI(int wwidth, int wheight) { - if (in_app) + /*if (in_app) { ImGui::SetNextWindowPos({0, 0}); ImGui::SetNextWindowSize({(float)wwidth, (float)wheight}); ImGui::Begin("Main", NULL, NOWINDOW_FLAGS | ImGuiWindowFlags_NoDecoration); current_app->draw(); ImGui::End(); - } + }*/ /*else if (processing::is_processing) { processing::ui_call_list_mutex->lock(); @@ -74,7 +73,7 @@ namespace satdump } processing::ui_call_list_mutex->unlock(); }*/ - else + // else { ImGui::SetNextWindowPos({0, 0}); ImGui::SetNextWindowSize({(float)wwidth, (float)wheight}); @@ -108,16 +107,33 @@ namespace satdump ImGui::EndTabItem(); } + if (ImGui::BeginTabItem("Recorder")) + { + recorder_app->draw(); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Viewer")) + { + viewer_app->draw(); + ImGui::EndTabItem(); + } if (ImGui::BeginTabItem("Applications")) { // current_app->draw(); - - for (std::pair()>> &appEntry : application_registry) + if (in_app) { - if (ImGui::Button(appEntry.first.c_str())) + // current_app->draw(); + } + else + { + + for (std::pair()>> &appEntry : application_registry) { - in_app = true; - current_app = application_registry[appEntry.first](); + if (ImGui::Button(appEntry.first.c_str())) + { + in_app = true; + // current_app = application_registry[appEntry.first](); + } } } diff --git a/src-interface/main_ui.h b/src-interface/main_ui.h index 1da37e984..96746e7ab 100644 --- a/src-interface/main_ui.h +++ b/src-interface/main_ui.h @@ -2,6 +2,9 @@ #include #include "libs/ctpl/ctpl_stl.h" +#include "app.h" +#include "viewer/viewer.h" +#include "recorder/recorder.h" namespace satdump { @@ -12,6 +15,9 @@ namespace satdump extern bool light_theme; + extern std::shared_ptr recorder_app; + extern std::shared_ptr viewer_app; + void initMainUI(); void renderMainUI(int wwidth, int wheight); } \ No newline at end of file diff --git a/src-interface/processing.cpp b/src-interface/processing.cpp index 59153edda..2e4a51ae1 100644 --- a/src-interface/processing.cpp +++ b/src-interface/processing.cpp @@ -4,8 +4,8 @@ #include "core/pipeline.h" #include "error.h" -#include "viewer/viewer.h" #include "core/config.h" +#include "main_ui.h" namespace satdump { @@ -57,10 +57,7 @@ namespace satdump if (std::filesystem::exists(output_file + "/dataset.json")) { logger->info("Opening viewer!"); - std::shared_ptr viewer = std::make_shared(); - viewer->loadDatasetInViewer(output_file + "/dataset.json"); - in_app = true; - current_app = viewer; + viewer_app->loadDatasetInViewer(output_file + "/dataset.json"); } } diff --git a/src-interface/recorder/recorder.cpp b/src-interface/recorder/recorder.cpp index 4b5063d37..3894a8ad4 100644 --- a/src-interface/recorder/recorder.cpp +++ b/src-interface/recorder/recorder.cpp @@ -59,9 +59,11 @@ namespace satdump void RecorderApplication::drawUI() { ImVec2 recorder_size = ImGui::GetContentRegionAvail(); + // recorder_size.y -= ImGui::GetCursorPosY(); + ImGui::BeginGroup(); - float wf_size = recorder_size.y - (is_processing ? 250 : 0); + float wf_size = recorder_size.y - (is_processing ? 240 * ui_scale : 0); ImGui::BeginChild("RecorderChildPanel", {float(recorder_size.x * 0.20), wf_size}, false); { if (ImGui::CollapsingHeader("Device")) @@ -336,7 +338,7 @@ namespace satdump if (is_processing) { - float y_pos = ImGui::GetCursorPosY() + 10 * ui_scale; + float y_pos = ImGui::GetCursorPosY() + 35 * ui_scale; float live_width = recorder_size.x + 16 * ui_scale; float live_height = 250; float winwidth = live_pipeline->modules.size() > 0 ? live_width / live_pipeline->modules.size() : live_width; diff --git a/src-interface/settings.cpp b/src-interface/settings.cpp index 1c3ab641e..e49efe31b 100644 --- a/src-interface/settings.cpp +++ b/src-interface/settings.cpp @@ -135,6 +135,8 @@ namespace satdump satdump::config::main_cfg["satdump_output_directories"][p.first]["value"] = p.second.getValue(); config::saveUserConfig(); } + + ImGui::TextColored(ImColor(255, 255, 0), "Note : Some settings will require SatDump to be restarted\nto take effect!"); } } } diff --git a/src-interface/viewer/viewer.cpp b/src-interface/viewer/viewer.cpp index 51b0d5380..2534953a2 100644 --- a/src-interface/viewer/viewer.cpp +++ b/src-interface/viewer/viewer.cpp @@ -51,7 +51,7 @@ namespace satdump // Init Handler std::string handler_id; if (instrument_viewer_settings.contains("handler")) - instrument_viewer_settings["handler"].get(); + handler_id = instrument_viewer_settings["handler"].get(); else if (products->contents["type"] == "image") handler_id = "image_handler"; logger->debug("Using handler {:s} for instrument {:s}", handler_id, products->instrument_name); @@ -162,7 +162,8 @@ namespace satdump ImGui::BeginChild("ViewerChildPanel", {float(viewer_size.x * 0.20), float(viewer_size.y)}, false); { drawPanel(); - products_and_handlers[current_handler_id].handler->drawMenu(); + if (products_and_handlers.size() > 0) + products_and_handlers[current_handler_id].handler->drawMenu(); } ImGui::EndChild(); ImGui::EndGroup(); @@ -170,7 +171,8 @@ namespace satdump ImGui::SameLine(); ImGui::BeginGroup(); - products_and_handlers[current_handler_id].handler->drawContents({float(viewer_size.x * 0.80 - 4), float(viewer_size.y)}); + if (products_and_handlers.size() > 0) + products_and_handlers[current_handler_id].handler->drawContents({float(viewer_size.x * 0.80 - 4), float(viewer_size.y)}); ImGui::EndGroup(); }