2025-03-13 12:00:14 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <GLFW/glfw3.h>
|
2025-03-14 19:32:40 +01:00
|
|
|
|
2025-03-13 12:00:14 +01:00
|
|
|
#include <cstdio>
|
2025-06-13 22:23:20 +00:00
|
|
|
#include <format>
|
2025-03-17 18:50:31 +01:00
|
|
|
#include <memory>
|
2025-03-13 12:00:14 +01:00
|
|
|
|
2025-06-13 22:23:20 +00:00
|
|
|
#include "PixelariumImage.hpp"
|
2025-03-13 12:00:14 +01:00
|
|
|
#include "imgui.h"
|
2025-03-17 10:44:56 +01:00
|
|
|
#include "rendering/CvMatRender.hpp"
|
2025-06-13 22:23:20 +00:00
|
|
|
#include "resources/resource.hpp"
|
2025-03-17 18:50:31 +01:00
|
|
|
#include "utilities/ILog.hpp"
|
2025-03-13 12:00:14 +01:00
|
|
|
|
2025-03-14 19:32:40 +01:00
|
|
|
namespace pixelarium::ui
|
2025-03-13 12:00:14 +01:00
|
|
|
{
|
2025-03-17 17:33:31 +01:00
|
|
|
static bool dim_changed_p(const ImVec2& ref_rect, const ImVec2& new_rect);
|
|
|
|
|
|
2025-06-13 22:23:20 +00:00
|
|
|
static ImVec2 aspect_const_dimensions(const pixelarium::imaging::PixelariumImage& img, const ImVec2& curr_dim);
|
2025-03-17 17:33:31 +01:00
|
|
|
|
2025-03-13 12:00:14 +01:00
|
|
|
enum LogLevelSelection
|
|
|
|
|
{
|
|
|
|
|
Debug = 0,
|
|
|
|
|
Info = 1,
|
|
|
|
|
Warning = 2,
|
|
|
|
|
Error = 3
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class AppGLFW
|
|
|
|
|
{
|
|
|
|
|
public:
|
2025-06-14 16:39:39 +02:00
|
|
|
explicit AppGLFW(std::unique_ptr<utils::log::ILog>& log) : logger_(*log)
|
2025-06-13 22:23:20 +00:00
|
|
|
{
|
2025-06-14 16:39:39 +02:00
|
|
|
logger_.Debug(std::format("{}: Initiating a new window", __FUNCTION__).c_str());
|
2025-06-13 22:23:20 +00:00
|
|
|
|
2025-06-14 16:39:39 +02:00
|
|
|
if (pool_)
|
|
|
|
|
{
|
|
|
|
|
logger_.Debug(std::format("{}: We have an image resource pool!", __FUNCTION__).c_str());
|
2025-06-13 22:23:20 +00:00
|
|
|
}
|
2025-06-14 16:39:39 +02:00
|
|
|
|
|
|
|
|
this->InitMainWindow();
|
2025-06-13 22:23:20 +00:00
|
|
|
}
|
|
|
|
|
AppGLFW(std::unique_ptr<utils::log::ILog>& log, std::unique_ptr<pixelarium::resources::ImageResourcePool>& pool)
|
|
|
|
|
: AppGLFW(log)
|
|
|
|
|
{
|
|
|
|
|
pool_ = pool.get();
|
|
|
|
|
};
|
2025-03-13 12:00:14 +01:00
|
|
|
int Run();
|
|
|
|
|
|
2025-03-14 19:32:40 +01:00
|
|
|
private:
|
2025-03-18 21:22:41 +01:00
|
|
|
void InitMainWindow();
|
2025-03-14 19:32:40 +01:00
|
|
|
void MenuBar();
|
|
|
|
|
void LoadImageProt();
|
|
|
|
|
|
2025-03-13 12:00:14 +01:00
|
|
|
private:
|
2025-03-17 17:33:31 +01:00
|
|
|
// LogLevelSelection log_level_ = static_cast<LogLevelSelection>(0);
|
2025-06-14 16:39:39 +02:00
|
|
|
utils::log::ILog& logger_;
|
2025-06-13 22:23:20 +00:00
|
|
|
resources::ImageResourcePool* pool_;
|
2025-03-13 12:00:14 +01:00
|
|
|
GLFWwindow* window = nullptr;
|
2025-06-13 22:23:20 +00:00
|
|
|
ImGuiWindowFlags window_flags_ = 0;
|
|
|
|
|
std::shared_ptr<pixelarium::imaging::PixelariumImage> img_;
|
|
|
|
|
pixelarium::render::CvMatRender render_;
|
|
|
|
|
bool imagep_{false};
|
2025-06-14 16:39:39 +02:00
|
|
|
bool demop_{false};
|
|
|
|
|
int log_level_{0};
|
2025-06-13 22:23:20 +00:00
|
|
|
ImVec2 curr_dim_;
|
2025-03-13 12:00:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void glfw_error_callback(int error, const char* description)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "GLFW Error %d: %s\n", error, description);
|
|
|
|
|
}
|
2025-06-13 22:23:20 +00:00
|
|
|
} // namespace pixelarium::ui
|