Files
pixelarium/lib/app/DefaultApp.cpp
T
m-aXimilian b37814204f Misc (#19)
* get image returns optional<Mat> instead of unique_ptr<Mat>

* introduce complexity

* rename image load function

* add example for a basic reader for binary image files

* fix windows build?

* add a status bar underneath the menu bar

* use status bar in custom_0 example app

* clang formats

* packing w/ pragma push

* add "Save As" functions to image views

* resize over reserve

* rm local override uri

* add simple thread pool

* rename to simple_thread_pool

* get rid of useless renderlib

* document version inc

* extract hardcoded values to in-header

* clang format patch

* clone registered image in custom_0

* document binary-file header

* minor fixes

* clang format

* rm unused render cmake
2026-02-16 20:36:48 +01:00

60 lines
1.5 KiB
C++

#include "DefaultApp.hpp"
#include <cstddef>
#include <format>
#include "PixelariumImageFactory.hpp"
#include "app_resources_default.h"
#include "imgui.h"
#include "portable-file-dialogs.h"
#include "resources/resource.hpp"
#include "utilities/ILog.hpp"
using namespace pixelarium::imaging;
using namespace pixelarium::application;
void DefaultApp::MenuBarOptionsColumn1()
{
ImGui::MenuItem(SHOWIMGUIDEMOS, NULL, &this->demop_);
ImGui::MenuItem(SHOWIMAGEGALLERY, NULL, &this->image_listp_);
}
void DefaultApp::MenuBarOptionsColumn2()
{
if (ImGui::BeginMenu(FILEMENUNAME))
{
if (ImGui::MenuItem(LOADIMAGE))
{
this->LoadImageDialogue();
}
ImGui::EndMenu();
}
}
void DefaultApp::Run()
{
if (demop_) ImGui::ShowDemoWindow(&this->demop_);
if (image_listp_) this->gallery_.RenderGallery();
this->gallery_.RenderImages();
}
void DefaultApp::LoadImageDialogue()
{
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));
try
{
pool_.SetResource(PixelariumImageFactory::CreateImage(p, logger_));
}
catch (pixelarium::resources::empty_resource_exception& e)
{
logger_.Error(std::format("{}: Failed to load file '{}' with '{}'", __PRETTY_FUNCTION__, p, e.what()));
}
}
}