Misc enhancements (#9)
* deploy docs only for main * Revert "deploy docs only for main" This reverts commit 53e37bd8a43e7e20d5a64bed1b3e00ced551dcae. * init czi specific view * fix build
This commit is contained in:
committed by
Maximilian Kueffner
parent
22fd65773d
commit
e60203b57d
@@ -2,38 +2,9 @@
|
||||
|
||||
#include <format>
|
||||
|
||||
#include "RenderHelpers.hpp"
|
||||
#include "imaging/IPixelariumImage.hpp"
|
||||
#include "imgui.h"
|
||||
|
||||
/// @brief Checks if the dimensions of two ImVec2 vectors have changed significantly.
|
||||
/// @param ref_rect The reference ImVec2 vector.
|
||||
/// @param new_rect The new ImVec2 vector to compare against.
|
||||
/// @return True if the absolute difference between the y-coordinates is greater than 5 or the x-coordinates are
|
||||
/// different; otherwise, false.
|
||||
static bool dim_changed_p(const ImVec2& ref_rect, const ImVec2& new_rect)
|
||||
{
|
||||
if (std::abs(ref_rect.y - new_rect.y) > 5 || std::abs(ref_rect.x - new_rect.x))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @brief Calculates dimensions to maintain aspect ratio.
|
||||
/// @param img The input image.
|
||||
/// @param curr_dim The current dimensions.
|
||||
/// @return The calculated dimensions maintaining aspect ratio.
|
||||
ImVec2 aspect_const_dimensions(const ImVec2& raw_dim, const ImVec2& curr_dim)
|
||||
{
|
||||
const auto w_fact = (curr_dim.x / raw_dim.x);
|
||||
const auto h_fact = (curr_dim.y / raw_dim.y);
|
||||
|
||||
const auto fact = w_fact < h_fact ? w_fact : h_fact;
|
||||
|
||||
return ImVec2(raw_dim.x * fact, raw_dim.y * fact);
|
||||
}
|
||||
|
||||
/// @brief Displays the image in an ImGui window.
|
||||
///
|
||||
/// If the image is null, empty, or has an empty name, the function returns immediately. Otherwise, it creates an ImGui
|
||||
@@ -47,13 +18,15 @@ void pixelarium::render::PixelariumImageViewDefault::ShowImage()
|
||||
this->is_dirty_ = false;
|
||||
}
|
||||
|
||||
if (this->img_->Empty() || this->img_->type_ == imaging::ImageFileType::UNKNOWN || !cached_image_ || this->img_->Name().empty())
|
||||
if (this->img_->Empty() || this->img_->type_ == imaging::ImageFileType::UNKNOWN || !cached_image_ ||
|
||||
this->img_->Name().empty())
|
||||
{
|
||||
// do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::Begin(this->img_->Name().c_str(), &this->open_p, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_MenuBar);
|
||||
ImGui::Begin(this->img_->Name().c_str(), &this->open_p,
|
||||
ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_MenuBar);
|
||||
|
||||
this->curr_dim_ = ImGui::GetContentRegionAvail();
|
||||
auto new_dim = ImGui::GetContentRegionAvail();
|
||||
|
||||
Reference in New Issue
Block a user