2021-08-15 16:47:44 +02:00
|
|
|
#include "main_ui.h"
|
|
|
|
|
#include "imgui/imgui_flags.h"
|
|
|
|
|
#include "imgui/imgui.h"
|
|
|
|
|
#include "processing.h"
|
2022-03-07 20:29:23 +01:00
|
|
|
#include "offline.h"
|
2022-03-30 15:41:23 +02:00
|
|
|
#include "settings.h"
|
2022-03-10 19:56:37 +01:00
|
|
|
#include "error.h"
|
2022-03-30 15:41:23 +02:00
|
|
|
#include "satdump_vars.h"
|
|
|
|
|
#include "core/config.h"
|
2022-05-02 18:59:03 +02:00
|
|
|
#include "core/style.h"
|
2022-03-20 20:56:32 +01:00
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
namespace satdump
|
2021-08-15 16:47:44 +02:00
|
|
|
{
|
2022-05-07 18:16:24 +02:00
|
|
|
std::shared_ptr<RecorderApplication> recorder_app;
|
|
|
|
|
std::shared_ptr<ViewerApplication> viewer_app;
|
2022-04-11 16:26:40 +02:00
|
|
|
|
2022-04-24 12:43:34 +02:00
|
|
|
bool in_app = false; // true;
|
2022-04-11 16:26:40 +02:00
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
void initMainUI()
|
|
|
|
|
{
|
|
|
|
|
offline::setup();
|
2022-03-30 15:41:23 +02:00
|
|
|
settings::setup();
|
|
|
|
|
|
|
|
|
|
light_theme = config::main_cfg["user_interface"]["light_theme"]["value"].get<bool>();
|
|
|
|
|
float manual_dpi_scaling = config::main_cfg["user_interface"]["manual_dpi_scaling"]["value"].get<float>();
|
|
|
|
|
|
|
|
|
|
ui_scale = manual_dpi_scaling;
|
|
|
|
|
|
|
|
|
|
// Setup Theme
|
|
|
|
|
if (std::filesystem::exists("Roboto-Medium.ttf"))
|
|
|
|
|
{
|
|
|
|
|
if (light_theme)
|
|
|
|
|
style::setLightStyle(".", manual_dpi_scaling);
|
|
|
|
|
else
|
|
|
|
|
style::setDarkStyle(".", manual_dpi_scaling);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (light_theme)
|
2022-05-12 16:56:46 +02:00
|
|
|
style::setLightStyle(satdump::RESPATH);
|
2022-03-30 15:41:23 +02:00
|
|
|
else
|
2022-05-12 16:56:46 +02:00
|
|
|
style::setDarkStyle(satdump::RESPATH);
|
2022-03-30 15:41:23 +02:00
|
|
|
}
|
2022-04-11 16:26:40 +02:00
|
|
|
|
|
|
|
|
registerApplications();
|
2022-04-12 20:18:44 +02:00
|
|
|
registerViewerHandlers();
|
|
|
|
|
|
2022-05-07 18:16:24 +02:00
|
|
|
recorder_app = std::make_shared<RecorderApplication>();
|
|
|
|
|
viewer_app = std::make_shared<ViewerApplication>();
|
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()
|
|
|
|
|
{
|
2022-05-08 16:58:14 +02:00
|
|
|
recorder_app->save_settings();
|
2022-05-08 16:35:54 +02:00
|
|
|
}
|
|
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
void renderMainUI(int wwidth, int wheight)
|
2021-08-15 16:47:44 +02:00
|
|
|
{
|
2022-05-07 18:16:24 +02:00
|
|
|
/*if (in_app)
|
2022-04-11 16:26:40 +02:00
|
|
|
{
|
|
|
|
|
ImGui::SetNextWindowPos({0, 0});
|
|
|
|
|
ImGui::SetNextWindowSize({(float)wwidth, (float)wheight});
|
2022-05-02 08:11:47 -07:00
|
|
|
ImGui::Begin("Main", NULL, NOWINDOW_FLAGS | ImGuiWindowFlags_NoDecoration);
|
2022-04-11 16:26:40 +02:00
|
|
|
current_app->draw();
|
|
|
|
|
ImGui::End();
|
2022-05-07 18:16:24 +02:00
|
|
|
}*/
|
2022-05-03 17:00:43 +02:00
|
|
|
/*else if (processing::is_processing)
|
2021-08-15 16:47:44 +02:00
|
|
|
{
|
2022-03-10 19:56:37 +01:00
|
|
|
processing::ui_call_list_mutex->lock();
|
|
|
|
|
float winheight = processing::ui_call_list->size() > 0 ? wheight / processing::ui_call_list->size() : wheight;
|
|
|
|
|
float currentPos = 0;
|
|
|
|
|
for (std::shared_ptr<ProcessingModule> module : *processing::ui_call_list)
|
|
|
|
|
{
|
|
|
|
|
ImGui::SetNextWindowPos({0, currentPos});
|
|
|
|
|
currentPos += winheight;
|
|
|
|
|
ImGui::SetNextWindowSize({(float)wwidth, (float)winheight});
|
|
|
|
|
module->drawUI(false);
|
|
|
|
|
}
|
|
|
|
|
processing::ui_call_list_mutex->unlock();
|
2022-05-03 17:00:43 +02:00
|
|
|
}*/
|
2022-05-07 18:16:24 +02:00
|
|
|
// else
|
2022-03-05 12:44:19 +01:00
|
|
|
{
|
2022-03-10 19:56:37 +01:00
|
|
|
ImGui::SetNextWindowPos({0, 0});
|
2022-03-11 09:29:20 +01:00
|
|
|
ImGui::SetNextWindowSize({(float)wwidth, (float)wheight});
|
2022-05-02 08:11:47 -07:00
|
|
|
ImGui::Begin("Main", NULL, NOWINDOW_FLAGS | ImGuiWindowFlags_NoDecoration);
|
2022-03-10 19:56:37 +01:00
|
|
|
if (ImGui::BeginTabBar("Main TabBar", ImGuiTabBarFlags_None))
|
2022-03-05 12:44:19 +01:00
|
|
|
{
|
2022-03-10 19:56:37 +01:00
|
|
|
if (ImGui::BeginTabItem("Offline processing"))
|
|
|
|
|
{
|
2022-05-03 17:00:43 +02:00
|
|
|
if (processing::is_processing)
|
|
|
|
|
{
|
|
|
|
|
// ImGui::BeginChild("OfflineProcessingChild");
|
|
|
|
|
processing::ui_call_list_mutex->lock();
|
|
|
|
|
int live_width = wwidth; // ImGui::GetWindowWidth();
|
|
|
|
|
int live_height = ImGui::GetWindowHeight() - ImGui::GetCursorPos().y;
|
|
|
|
|
float winheight = processing::ui_call_list->size() > 0 ? live_height / processing::ui_call_list->size() : live_height;
|
|
|
|
|
float currentPos = ImGui::GetCursorPos().y;
|
|
|
|
|
for (std::shared_ptr<ProcessingModule> module : *processing::ui_call_list)
|
|
|
|
|
{
|
|
|
|
|
ImGui::SetNextWindowPos({0, currentPos});
|
|
|
|
|
currentPos += winheight;
|
|
|
|
|
ImGui::SetNextWindowSize({(float)live_width, (float)winheight});
|
|
|
|
|
module->drawUI(true);
|
|
|
|
|
}
|
|
|
|
|
processing::ui_call_list_mutex->unlock();
|
|
|
|
|
// ImGui::EndChild();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
offline::render();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
ImGui::EndTabItem();
|
|
|
|
|
}
|
2022-05-07 18:16:24 +02:00
|
|
|
if (ImGui::BeginTabItem("Recorder"))
|
|
|
|
|
{
|
|
|
|
|
recorder_app->draw();
|
|
|
|
|
ImGui::EndTabItem();
|
|
|
|
|
}
|
|
|
|
|
if (ImGui::BeginTabItem("Viewer"))
|
|
|
|
|
{
|
|
|
|
|
viewer_app->draw();
|
|
|
|
|
ImGui::EndTabItem();
|
|
|
|
|
}
|
2022-04-11 16:26:40 +02:00
|
|
|
if (ImGui::BeginTabItem("Applications"))
|
|
|
|
|
{
|
2022-04-12 20:18:44 +02:00
|
|
|
// current_app->draw();
|
2022-05-07 18:16:24 +02:00
|
|
|
if (in_app)
|
2022-04-11 16:26:40 +02:00
|
|
|
{
|
2022-05-07 18:16:24 +02:00
|
|
|
// current_app->draw();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
for (std::pair<const std::string, std::function<std::shared_ptr<Application>()>> &appEntry : application_registry)
|
2022-04-11 16:26:40 +02:00
|
|
|
{
|
2022-05-07 18:16:24 +02:00
|
|
|
if (ImGui::Button(appEntry.first.c_str()))
|
|
|
|
|
{
|
|
|
|
|
in_app = true;
|
|
|
|
|
// current_app = application_registry[appEntry.first]();
|
|
|
|
|
}
|
2022-04-11 16:26:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::EndTabItem();
|
|
|
|
|
}
|
2022-03-30 15:41:23 +02:00
|
|
|
if (ImGui::BeginTabItem("Settings"))
|
|
|
|
|
{
|
|
|
|
|
settings::render();
|
|
|
|
|
ImGui::EndTabItem();
|
|
|
|
|
}
|
2022-03-05 12:44:19 +01:00
|
|
|
}
|
2022-03-10 19:56:37 +01:00
|
|
|
ImGui::EndTabBar();
|
|
|
|
|
ImGui::End();
|
2022-03-05 12:44:19 +01:00
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
if (error::hasError)
|
|
|
|
|
error::render();
|
|
|
|
|
}
|
2022-03-05 12:44:19 +01:00
|
|
|
}
|
2022-03-10 19:56:37 +01:00
|
|
|
|
2022-03-30 15:41:23 +02:00
|
|
|
bool light_theme;
|
|
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
ctpl::thread_pool ui_thread_pool(8);
|
2021-08-15 16:47:44 +02:00
|
|
|
}
|