2025-07-11 18:09:41 +02:00
|
|
|
#define SATDUMP_DLL_EXPORT2 1
|
|
|
|
|
|
2025-08-26 20:31:06 +02:00
|
|
|
#include "explorer/explorer.h"
|
|
|
|
|
|
2025-07-06 22:54:20 +02:00
|
|
|
#include "common/imgui_utils.h"
|
2025-07-08 22:20:21 +02:00
|
|
|
#include "core/style.h"
|
2025-07-08 17:42:18 +01:00
|
|
|
#include "recorder/recorder.h"
|
2025-06-01 13:18:41 +02:00
|
|
|
|
2026-01-25 15:02:38 +01:00
|
|
|
#include "status_logger_sink.h"
|
|
|
|
|
|
2023-02-19 23:21:06 +01:00
|
|
|
#include "common/audio/audio_sink.h"
|
2025-05-03 12:12:36 +02:00
|
|
|
#include "common/widgets/markdown_helper.h"
|
2026-01-25 15:02:38 +01:00
|
|
|
#include "common/widgets/menuitem_tooltip.h"
|
2025-05-03 12:12:36 +02:00
|
|
|
#include "core/backend.h"
|
2025-06-01 13:18:41 +02:00
|
|
|
#include "core/plugin.h"
|
|
|
|
|
#include "core/resources.h"
|
2025-05-03 12:12:36 +02:00
|
|
|
#include "imgui/imgui.h"
|
|
|
|
|
#include "imgui/imgui_flags.h"
|
2023-05-20 22:40:36 +02:00
|
|
|
#include "imgui_notify/imgui_notify.h"
|
2025-07-06 22:54:20 +02:00
|
|
|
#include "main_ui.h"
|
2023-05-20 22:40:36 +02:00
|
|
|
#include "notify_logger_sink.h"
|
2025-05-03 12:12:36 +02:00
|
|
|
#include "offline.h"
|
|
|
|
|
#include "satdump_vars.h"
|
|
|
|
|
#include "settings.h"
|
2022-08-08 10:45:19 +02:00
|
|
|
|
2023-10-04 21:40:08 +02:00
|
|
|
#include "imgui/implot/implot.h"
|
2024-12-20 20:47:52 +01:00
|
|
|
#include "imgui/implot3d/implot3d.h"
|
2023-10-04 21:40:08 +02:00
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
namespace satdump
|
2021-08-15 16:47:44 +02:00
|
|
|
{
|
2025-06-22 17:18:53 +02:00
|
|
|
SATDUMP_DLL2 std::shared_ptr<explorer::ExplorerApplication> explorer_app;
|
2022-04-11 16:26:40 +02:00
|
|
|
|
2024-05-18 19:22:33 +02:00
|
|
|
SATDUMP_DLL2 bool update_ui = true;
|
2022-04-11 16:26:40 +02:00
|
|
|
|
2026-01-25 15:02:38 +01:00
|
|
|
::widgets::MarkdownHelper credits_md;
|
2022-06-20 18:54:33 +02:00
|
|
|
|
2023-05-20 22:40:36 +02:00
|
|
|
std::shared_ptr<NotifyLoggerSink> notify_logger_sink;
|
2023-08-09 22:21:32 -04:00
|
|
|
std::shared_ptr<StatusLoggerSink> status_logger_sink;
|
2023-05-20 22:40:36 +02:00
|
|
|
|
2025-12-08 17:50:52 +01:00
|
|
|
void showProcessing(); // TODOREWORK
|
|
|
|
|
|
2024-01-21 17:30:00 -05:00
|
|
|
void initMainUI()
|
2022-03-10 19:56:37 +01:00
|
|
|
{
|
2023-10-04 21:40:08 +02:00
|
|
|
ImPlot::CreateContext();
|
2024-12-20 20:47:52 +01:00
|
|
|
ImPlot3D::CreateContext();
|
2023-10-04 21:40:08 +02:00
|
|
|
|
2023-02-19 23:21:06 +01:00
|
|
|
audio::registerSinks();
|
2022-03-10 19:56:37 +01:00
|
|
|
offline::setup();
|
2022-03-30 15:41:23 +02:00
|
|
|
settings::setup();
|
|
|
|
|
|
2025-12-08 17:50:52 +01:00
|
|
|
// Register events
|
|
|
|
|
eventBus->register_handler<ShowProcesingEvent>([](ShowProcesingEvent) { showProcessing(); });
|
|
|
|
|
eventBus->register_handler<AddRecorderEvent>(
|
|
|
|
|
[](AddRecorderEvent)
|
|
|
|
|
{
|
|
|
|
|
explorer_app->tryOpenSomethingInExplorer(
|
|
|
|
|
[](explorer::ExplorerApplication *)
|
|
|
|
|
{
|
|
|
|
|
logger->warn("Adding Recorder!");
|
2026-01-28 20:27:21 +01:00
|
|
|
eventBus->fire_event<explorer::ExplorerAddHandlerEvent>({std::make_shared<RecorderApplication>(), true}); // TODOREWORK do not bind this directly.
|
2025-12-08 17:50:52 +01:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
eventBus->register_handler<TryOpenFileInMainExplorerEvent>([](TryOpenFileInMainExplorerEvent e) { explorer_app->tryOpenFileInExplorer(e.path); });
|
|
|
|
|
|
2022-06-20 18:54:33 +02:00
|
|
|
// Load credits MD
|
|
|
|
|
std::ifstream ifs(resources::getResourcePath("credits.md"));
|
|
|
|
|
std::string credits_markdown((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
|
|
|
|
credits_md.set_md(credits_markdown);
|
|
|
|
|
|
2025-06-22 17:18:53 +02:00
|
|
|
explorer_app = std::make_shared<explorer::ExplorerApplication>();
|
2023-05-20 22:40:36 +02:00
|
|
|
|
2023-10-04 21:40:08 +02:00
|
|
|
// Logger status bar sync
|
2023-08-10 12:03:26 -04:00
|
|
|
status_logger_sink = std::make_shared<StatusLoggerSink>();
|
2023-10-04 21:40:08 +02:00
|
|
|
if (status_logger_sink->is_shown())
|
2023-08-09 22:21:32 -04:00
|
|
|
logger->add_sink(status_logger_sink);
|
2023-11-19 16:22:39 -05:00
|
|
|
|
|
|
|
|
// Shut down the logger init buffer manually to prevent init warnings
|
|
|
|
|
// From showing as a toast, or in the product processor screen
|
|
|
|
|
completeLoggerInit();
|
|
|
|
|
|
|
|
|
|
// Logger notify sink
|
|
|
|
|
notify_logger_sink = std::make_shared<NotifyLoggerSink>();
|
|
|
|
|
logger->add_sink(notify_logger_sink);
|
2022-03-10 19:56:37 +01:00
|
|
|
}
|
2021-08-15 16:47:44 +02:00
|
|
|
|
2022-05-08 16:35:54 +02:00
|
|
|
void exitMainUI()
|
|
|
|
|
{
|
2025-06-08 16:57:37 +02:00
|
|
|
satdump_cfg.saveUser();
|
2025-12-25 15:36:19 +01:00
|
|
|
explorer_app.reset();
|
2022-05-08 16:35:54 +02:00
|
|
|
}
|
|
|
|
|
|
2025-07-05 22:22:17 +02:00
|
|
|
// TODOREWORKUI
|
|
|
|
|
bool offline_en = false;
|
2025-07-06 22:54:20 +02:00
|
|
|
bool about_en = false;
|
|
|
|
|
bool settings_en = false;
|
2025-07-05 22:22:17 +02:00
|
|
|
|
2025-08-12 22:43:29 +02:00
|
|
|
void showProcessing() { offline_en = 1; }
|
|
|
|
|
|
2023-12-31 16:49:23 -05:00
|
|
|
void renderMainUI()
|
2021-08-15 16:47:44 +02:00
|
|
|
{
|
2024-01-21 17:30:00 -05:00
|
|
|
if (update_ui)
|
|
|
|
|
{
|
2024-01-22 23:39:05 -05:00
|
|
|
style::setStyle();
|
2024-01-21 17:30:00 -05:00
|
|
|
style::setFonts(ui_scale);
|
|
|
|
|
update_ui = false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-31 16:49:23 -05:00
|
|
|
std::pair<int, int> dims = backend::beginFrame();
|
2025-12-24 17:25:01 +01:00
|
|
|
|
|
|
|
|
// On Windows minimizing makes the window dimensions 0,
|
|
|
|
|
// which of course cause a whole lot of issues...
|
|
|
|
|
// Simply abort any further rendering of this happens!
|
|
|
|
|
if (dims.first == 0 && dims.second == 0)
|
|
|
|
|
{
|
|
|
|
|
backend::endFrame();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-26 22:45:55 -05:00
|
|
|
dims.second -= status_logger_sink->draw();
|
2022-09-17 16:22:26 +02:00
|
|
|
|
2022-03-05 12:44:19 +01:00
|
|
|
{
|
2022-03-10 19:56:37 +01:00
|
|
|
ImGui::SetNextWindowPos({0, 0});
|
2024-01-26 22:45:55 -05:00
|
|
|
ImGui::SetNextWindowSize({(float)dims.first, (float)dims.second});
|
2025-09-04 17:44:37 +02:00
|
|
|
ImGui::Begin("SatDump UI", nullptr, NOWINDOW_FLAGS | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoScrollWithMouse);
|
2025-07-05 22:22:17 +02:00
|
|
|
|
|
|
|
|
if (ImGui::BeginMenuBar())
|
|
|
|
|
{
|
2026-01-23 21:29:48 +01:00
|
|
|
// Show/Hide explorer sidebar
|
|
|
|
|
if (ImGui::MenuItem("\uf85b", NULL, explorer_app->show_panel))
|
|
|
|
|
explorer_app->show_panel = !explorer_app->show_panel;
|
|
|
|
|
|
2025-07-07 21:56:23 +02:00
|
|
|
if (ImGui::BeginMenu("File"))
|
2025-07-05 22:22:17 +02:00
|
|
|
{
|
2025-07-12 12:34:32 +02:00
|
|
|
if (ImGui::MenuItem("Processing"))
|
2025-07-06 22:54:20 +02:00
|
|
|
offline_en = true;
|
2025-07-07 22:28:43 +02:00
|
|
|
|
2025-08-12 11:11:22 +02:00
|
|
|
if (ImGui::MenuItem("Settings"))
|
|
|
|
|
settings_en = true;
|
|
|
|
|
|
2025-08-12 11:04:46 +02:00
|
|
|
ImGui::EndMenu();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui::BeginMenu("Add"))
|
|
|
|
|
{
|
|
|
|
|
if (ImGui::MenuItem("Recorder"))
|
2025-08-13 13:52:48 +02:00
|
|
|
explorer_app->tryOpenSomethingInExplorer(
|
|
|
|
|
[](explorer::ExplorerApplication *)
|
|
|
|
|
{
|
|
|
|
|
eventBus->fire_event<explorer::ExplorerAddHandlerEvent>({std::make_shared<RecorderApplication>()}); // TODOREWORK do not bind this directly.
|
|
|
|
|
});
|
2025-07-08 17:42:18 +01:00
|
|
|
|
2025-07-07 22:28:43 +02:00
|
|
|
ImGui::EndMenu();
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-05 22:22:17 +02:00
|
|
|
ImGui::EndMenuBar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (offline_en)
|
|
|
|
|
{
|
2025-08-05 13:59:22 +02:00
|
|
|
// ImGui::SetNextWindowSize({600 * ui_scale, 0});
|
|
|
|
|
ImGui::SetNextWindowPos({0, 0});
|
|
|
|
|
ImGui::SetNextWindowSize({(float)dims.first, (float)dims.second});
|
|
|
|
|
if (ImGui::Begin("Start Processing", &offline_en, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse))
|
2025-07-23 12:21:02 +02:00
|
|
|
{
|
|
|
|
|
offline::render();
|
2025-07-25 19:35:55 +02:00
|
|
|
ImGui::End();
|
2025-07-23 12:21:02 +02:00
|
|
|
}
|
2025-07-06 22:54:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (settings_en)
|
|
|
|
|
ImGui::OpenPopup("Settings");
|
|
|
|
|
|
|
|
|
|
if (ImGui::BeginPopupModal("Settings", &settings_en, /*ImGuiWindowFlags_AlwaysAutoResize |*/ ImGuiWindowFlags_AlwaysVerticalScrollbar))
|
|
|
|
|
{
|
|
|
|
|
settings::render();
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (about_en)
|
|
|
|
|
ImGui::OpenPopup("About");
|
|
|
|
|
|
|
|
|
|
if (ImGui::BeginPopupModal("About", &about_en, /*ImGuiWindowFlags_AlwaysAutoResize |*/ ImGuiWindowFlags_AlwaysVerticalScrollbar))
|
|
|
|
|
{
|
|
|
|
|
credits_md.render();
|
|
|
|
|
ImGui::EndPopup();
|
2025-07-05 22:22:17 +02:00
|
|
|
}
|
|
|
|
|
|
2025-07-07 22:32:31 +02:00
|
|
|
if (ImGui::BeginMenuBar())
|
|
|
|
|
{
|
2026-01-25 15:02:38 +01:00
|
|
|
if (widgets::BeginMenuTooltip("?", "Help"))
|
2025-07-07 22:32:31 +02:00
|
|
|
{
|
|
|
|
|
if (ImGui::MenuItem("Documentation"))
|
|
|
|
|
;
|
|
|
|
|
if (ImGui::MenuItem("About"))
|
|
|
|
|
about_en = true;
|
|
|
|
|
ImGui::EndMenu();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::EndMenuBar();
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 18:16:43 +01:00
|
|
|
explorer_app->draw();
|
|
|
|
|
|
2023-11-20 14:18:52 -05:00
|
|
|
ImGuiUtils_SendCurrentWindowToBack();
|
2022-03-10 19:56:37 +01:00
|
|
|
ImGui::End();
|
2022-03-05 12:44:19 +01:00
|
|
|
|
2023-01-30 12:12:04 +01:00
|
|
|
if (settings::show_imgui_demo)
|
2024-12-06 19:49:11 +01:00
|
|
|
{
|
2023-01-30 12:12:04 +01:00
|
|
|
ImGui::ShowDemoWindow();
|
2024-12-06 19:49:11 +01:00
|
|
|
ImPlot::ShowDemoWindow();
|
2024-12-20 20:47:52 +01:00
|
|
|
ImPlot3D::ShowDemoWindow();
|
2024-12-06 19:49:11 +01:00
|
|
|
}
|
2022-03-10 19:56:37 +01:00
|
|
|
}
|
2023-05-20 22:40:36 +02:00
|
|
|
|
|
|
|
|
// Render toasts on top of everything, at the end of your code!
|
|
|
|
|
// You should push style vars here
|
2023-09-13 15:27:42 -04:00
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.f);
|
2024-09-08 22:25:10 -04:00
|
|
|
ImGui::PushStyleColor(ImGuiCol_WindowBg, (ImVec4)style::theme.notification_bg);
|
2023-10-31 20:18:35 -04:00
|
|
|
notify_logger_sink->notify_mutex.lock();
|
2023-09-13 15:27:42 -04:00
|
|
|
ImGui::RenderNotifications();
|
2023-10-31 20:18:35 -04:00
|
|
|
notify_logger_sink->notify_mutex.unlock();
|
2023-09-13 15:27:42 -04:00
|
|
|
ImGui::PopStyleVar(1);
|
2023-05-20 22:40:36 +02:00
|
|
|
ImGui::PopStyleColor(1);
|
2023-12-31 16:49:23 -05:00
|
|
|
|
|
|
|
|
backend::endFrame();
|
2022-03-05 12:44:19 +01:00
|
|
|
}
|
2022-03-10 19:56:37 +01:00
|
|
|
|
2024-05-18 19:22:33 +02:00
|
|
|
SATDUMP_DLL2 ctpl::thread_pool ui_thread_pool(8);
|
2025-05-03 12:12:36 +02:00
|
|
|
} // namespace satdump
|