2024-12-29 20:13:58 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2025-05-19 22:26:32 +02:00
|
|
|
#include "common/widgets/menuitem_fileopen.h"
|
2025-07-18 12:19:40 +02:00
|
|
|
#include "dsp/task_queue.h"
|
2025-05-19 22:26:32 +02:00
|
|
|
#include "handlers/handler.h"
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2025-05-03 12:12:36 +02:00
|
|
|
#include "imgui/dialogs/widget.h"
|
2025-08-01 00:39:05 +02:00
|
|
|
#include <cstdint>
|
2025-07-24 11:53:20 +02:00
|
|
|
#include <memory>
|
2025-01-03 10:03:04 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
namespace satdump
|
|
|
|
|
{
|
2025-06-22 17:18:53 +02:00
|
|
|
namespace explorer
|
2024-12-29 20:13:58 +01:00
|
|
|
{
|
2025-07-24 21:55:57 +02:00
|
|
|
// Predef
|
|
|
|
|
class ExplorerApplication;
|
|
|
|
|
|
|
|
|
|
// Events
|
|
|
|
|
struct RenderLoadMenuElementsEvent
|
2024-12-29 20:13:58 +01:00
|
|
|
{
|
2025-07-24 21:55:57 +02:00
|
|
|
std::shared_ptr<handlers::Handler> &curr_handler;
|
|
|
|
|
std::shared_ptr<handlers::Handler> &master_handler;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct GetLastSelectedOfTypeEvent
|
|
|
|
|
{
|
|
|
|
|
std::string type;
|
|
|
|
|
std::shared_ptr<handlers::Handler> &h;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ExplorerAddHandlerEvent
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<handlers::Handler> h;
|
|
|
|
|
bool open = false;
|
|
|
|
|
bool is_processing = false;
|
|
|
|
|
};
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2025-07-24 21:55:57 +02:00
|
|
|
struct ExplorerRequestFileLoad
|
|
|
|
|
{
|
2025-07-25 19:35:55 +02:00
|
|
|
std::string path;
|
2025-07-24 21:55:57 +02:00
|
|
|
std::vector<std::pair<std::string, std::function<void(std::string, ExplorerApplication *)>>> &loaders;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Actual explorer
|
|
|
|
|
class ExplorerApplication
|
|
|
|
|
{
|
2025-07-23 12:21:02 +02:00
|
|
|
public:
|
|
|
|
|
void draw();
|
|
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
protected:
|
|
|
|
|
const std::string app_id;
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
float panel_ratio = 0.23;
|
|
|
|
|
float last_width = -1.0f;
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2025-01-02 17:04:32 +01:00
|
|
|
void drawPanel();
|
|
|
|
|
void drawContents();
|
|
|
|
|
void drawMenuBar();
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2025-07-24 11:53:20 +02:00
|
|
|
// Groups definitions. TODOREWORK don't hardcode
|
|
|
|
|
std::map<std::string, std::vector<std::string>> group_definitions = {
|
|
|
|
|
{"Recorders", {"recorder", "newrec_test_handler"}},
|
|
|
|
|
{"Products", {"dataset_handler", "image_product_handler", "punctiform_product_handler"}},
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-22 17:18:53 +02:00
|
|
|
// Explorer main handlers
|
2025-05-19 22:26:32 +02:00
|
|
|
std::shared_ptr<handlers::Handler> curr_handler;
|
2025-07-13 14:40:31 +02:00
|
|
|
std::shared_ptr<handlers::Handler> processing_handler;
|
2025-07-24 11:53:20 +02:00
|
|
|
std::map<std::string, std::shared_ptr<handlers::Handler>> groups_handlers;
|
|
|
|
|
std::shared_ptr<handlers::Handler> master_handler;
|
2025-05-19 22:26:32 +02:00
|
|
|
std::shared_ptr<handlers::Handler> trash_handler;
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2025-05-19 22:26:32 +02:00
|
|
|
// File open
|
|
|
|
|
widget::MenuItemFileOpen file_open_dialog;
|
2025-07-18 12:19:40 +02:00
|
|
|
TaskQueue file_open_queue;
|
2025-01-03 10:03:04 +01:00
|
|
|
|
2025-05-23 12:30:42 +02:00
|
|
|
std::string quickOpenString;
|
|
|
|
|
|
2025-08-01 00:39:05 +02:00
|
|
|
protected:
|
|
|
|
|
intptr_t satdump_logo_texture = 0;
|
2025-08-05 19:07:45 +02:00
|
|
|
std::string tip_of_the_day = "The tip of the day is that this tip failed to load... Sorry about that.";
|
2025-08-01 00:39:05 +02:00
|
|
|
|
2025-05-15 14:04:34 +02:00
|
|
|
public:
|
|
|
|
|
// TODOREWORK last opened by time
|
2025-05-19 22:26:32 +02:00
|
|
|
std::map<std::string, std::shared_ptr<handlers::Handler>> last_selected_handler;
|
2025-05-15 14:04:34 +02:00
|
|
|
|
2025-01-25 19:07:35 +01:00
|
|
|
public:
|
2025-07-24 11:53:20 +02:00
|
|
|
void addHandler(std::shared_ptr<handlers::Handler> h, bool open = false, bool is_processing = false);
|
2025-06-22 17:18:53 +02:00
|
|
|
void tryOpenFileInExplorer(std::string path);
|
2025-08-13 13:52:48 +02:00
|
|
|
void tryOpenSomethingInExplorer(std::function<void(ExplorerApplication *)> f);
|
2025-01-03 10:03:04 +01:00
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
public:
|
2025-06-22 17:18:53 +02:00
|
|
|
ExplorerApplication();
|
|
|
|
|
~ExplorerApplication();
|
2024-12-29 20:13:58 +01:00
|
|
|
};
|
2025-07-14 21:21:55 +02:00
|
|
|
|
2025-06-22 17:18:53 +02:00
|
|
|
} // namespace explorer
|
2025-05-03 12:12:36 +02:00
|
|
|
}; // namespace satdump
|