#pragma once #include "image/image.h" #include "imgui/imgui.h" #include #include #include #include class ImageViewWidget { private: struct ImageContainer { unsigned int texture_id = 0; std::vector texture_buffer; int img_width = 0; int img_height = 0; int offset_x = 0; int offset_y = 0; }; private: std::vector img_chunks; int fimg_width = 0; int fimg_height = 0; bool has_to_update = false; std::mutex image_mtx; std::string id_str; public: bool autoFitNextFrame = false; bool zoom_in_next = false; bool zoom_out_next = false; bool select_crop_next = false; bool isSelectingCrop = false; ImVec2 crop_initial_pos; ImVec2 crop_end_pos; std::function cropCallback = [](int, int, int, int) {}; public: ImageViewWidget(); ~ImageViewWidget(); std::function mouseCallback = [](int, int) {}; // Function that can be used to handle mouse events void update(image::Image &image); void draw(ImVec2 win_size); unsigned int getTextID() { return img_chunks.size() > 0 ? img_chunks[0].texture_id : 0; } };