Files
pixelarium/lib/app/DefaultApp.cpp
T

60 lines
1.4 KiB
C++
Raw Normal View History

2025-09-22 23:13:28 +02:00
#include "DefaultApp.hpp"
2025-08-18 22:39:43 +00:00
2025-09-13 14:49:59 +02:00
#include <cstddef>
2025-08-18 22:39:43 +00:00
#include <format>
2025-09-22 23:13:28 +02:00
#include "PixelariumImageFactory.hpp"
2025-09-13 14:49:59 +02:00
#include "app_resources_default.h"
2025-08-18 22:39:43 +00:00
#include "imgui.h"
#include "portable-file-dialogs.h"
2025-09-22 23:13:28 +02:00
#include "resources/resource.hpp"
2025-08-18 22:39:43 +00:00
#include "utilities/ILog.hpp"
using namespace pixelarium::imaging;
using namespace pixelarium::application;
2025-08-18 22:39:43 +00:00
void DefaultApp::MenuBarOptionsColumn1()
2025-08-18 22:39:43 +00:00
{
ImGui::MenuItem(SHOWIMGUIDEMOS, NULL, &this->demop_);
ImGui::MenuItem(SHOWIMAGEGALLERY, NULL, &this->image_listp_);
}
void DefaultApp::MenuBarOptionsColumn2()
2025-08-18 22:39:43 +00:00
{
if (ImGui::BeginMenu(FILEMENUNAME))
{
2025-09-22 23:13:28 +02:00
if (ImGui::MenuItem(LOADIMAGE))
2025-08-18 22:39:43 +00:00
{
2025-09-22 23:13:28 +02:00
this->LoadImage();
2025-08-18 22:39:43 +00:00
}
ImGui::EndMenu();
}
}
void DefaultApp::Run()
2025-08-18 22:39:43 +00:00
{
if (demop_) ImGui::ShowDemoWindow(&this->demop_);
2025-10-11 17:23:58 +02:00
if (image_listp_) this->gallery_.RenderGallery();
2025-09-13 14:49:59 +02:00
2025-10-11 17:23:58 +02:00
this->gallery_.RenderImages();
2025-09-13 14:49:59 +02:00
}
void DefaultApp::LoadImage()
2025-08-18 22:39:43 +00:00
{
auto res{pfd::open_file("Load Inputs", pfd::path::home(), {"All Files", "*"}, pfd::opt::multiselect).result()};
for (auto& p : res)
{
this->logger_.Debug(std::format("{}: Creating image {}", __FUNCTION__, p));
2025-09-22 23:13:28 +02:00
try
{
2025-09-26 21:09:51 +02:00
pool_.SetResource(PixelariumImageFactory::CreateImage(p, logger_));
2025-09-22 23:13:28 +02:00
}
catch (pixelarium::resources::empty_resource_exception& e)
{
logger_.Error(std::format("{}: Failed to load file '{}' with '{}'", __PRETTY_FUNCTION__, p, e.what()));
}
2025-08-18 22:39:43 +00:00
}
}