From 5d543bcc0d15b871315a2123aec01041d73c53fb Mon Sep 17 00:00:00 2001
From: fszontagh <51741446+fszontagh@users.noreply.github.com>
Date: Sun, 25 Feb 2024 15:37:58 +0000
Subject: [PATCH] drag and drop
---
ui/ImageViewerImageWindow.h | 76 ++++++++++++++++++++++++++++++++++++-
1 files changed, 73 insertions(+), 3 deletions(-)
diff --git a/ui/ImageViewerImageWindow.h b/ui/ImageViewerImageWindow.h
index 211fac0..c665cc0 100644
--- a/ui/ImageViewerImageWindow.h
+++ b/ui/ImageViewerImageWindow.h
@@ -9,17 +9,87 @@
#include "ImageViewer.h"
//// end generated include
+#include <map>
+#include <iostream>
+#include "../res/app_icon.h"
+#include "../utils.h"
/** Implementing ImageWindow */
class ImageViewerImageWindow : public ImageWindow
{
- public:
- /** Constructor */
- ImageViewerImageWindow( wxWindow* parent );
+protected:
+ // Handlers for ImageWindow events.
+ void OnDropFile(wxDropFilesEvent &event);
+ void OnWindowKeyUp(wxKeyEvent &event);
+ void OnWindowMouseWheel(wxMouseEvent &event);
+ void WindowOnSize(wxSizeEvent &event);
+ void OnBitmapDoubleLeftClick(wxMouseEvent &event);
+ void OnListItemSelected(wxListEvent &event);
+ void OnRotateLeftClicked(wxCommandEvent &event);
+ void OnRotateRightClicked(wxCommandEvent &event);
+ void OnZoomInClicked(wxCommandEvent &event);
+ void OnZoomResetClicked(wxCommandEvent &event);
+ void OnZoomOutClicked(wxCommandEvent &event);
+ void OnShowFullScreenClick(wxCommandEvent &event);
+
+public:
+ /** Constructor */
+ ImageViewerImageWindow(wxWindow *parent);
//// end generated class members
+private:
+ wxString windowTitle;
+ /// @brief int imagelist id, wxImage the image
+ std::map<int, ImageUtils::ImageFileInfo *> images;
+ wxImage currentVisibleImage;
+ wxImage currentOriginalImage;
+ wxImageList *imgList;
+ int currentZoom = 100;
+ void ShowImage(wxImage img);
+ wxImage FitImage(wxImage img, int targetWidth, int targetHeight);
+ wxImage RotateImage(ImageUtils::ROTATE_DIRECTION dir, wxImage img);
+ void ZoomImage(int factor);
+ inline wxImage cropResizeImage(const wxImage &originalImage, int targetWidth, int targetHeight)
+ {
+ int originalWidth = originalImage.GetWidth();
+ int originalHeight = originalImage.GetHeight();
+ double aspectRatio = static_cast<double>(originalWidth) / static_cast<double>(originalHeight);
+ int newWidth = targetWidth;
+ int newHeight = targetHeight;
+
+ // Kiszámítjuk az új méreteket, hogy megtartsuk a képarányt
+ if (originalWidth > targetWidth || originalHeight > targetHeight)
+ {
+ if (aspectRatio > 1.0)
+ {
+ // Szélesség alapján skálázzuk az új méretet
+ newWidth = targetWidth;
+ newHeight = static_cast<int>(targetWidth / aspectRatio);
+ }
+ else
+ {
+ // Magasság alapján skálázzuk az új méretet
+ newHeight = targetHeight;
+ newWidth = static_cast<int>(targetHeight * aspectRatio);
+ }
+ }
+
+ // Méretezzük az eredeti képet az új méretekre
+ wxImage resizedImage = originalImage.Scale(newWidth, newHeight);
+
+ // Üres terület hozzáadása és transzparens töltése
+ if (newWidth < targetWidth || newHeight < targetHeight)
+ {
+ wxImage finalImage(targetWidth, targetHeight);
+ finalImage.SetAlpha();
+ finalImage.Paste(resizedImage, (targetWidth - newWidth) / 2, (targetHeight - newHeight) / 2);
+ return finalImage;
+ }
+
+ return resizedImage;
+ }
};
#endif // __ImageViewerImageWindow__
--
Gitblit v1.9.3