diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-06-25 09:13:38 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-07-02 10:10:18 -0400 |
| commit | 9e3214a73a5cc38a9b4f0313d8a48c0374cb57a3 (patch) | |
| tree | 6c0333f102d9dcf731e178f2d6b983e3d164272e /src/modinfodialogimages.h | |
| parent | 24b9f050c10d039be13a266d41088ae0fcc068f4 (diff) | |
refactored calculations
Diffstat (limited to 'src/modinfodialogimages.h')
| -rw-r--r-- | src/modinfodialogimages.h | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/modinfodialogimages.h b/src/modinfodialogimages.h index 88e22a6a..9c3e5746 100644 --- a/src/modinfodialogimages.h +++ b/src/modinfodialogimages.h @@ -91,17 +91,49 @@ private: } }; + struct PaintContext + { + QPainter painter; + int thumbSize; + QRect topRect; + + PaintContext(QWidget* w) + : painter(w), thumbSize(0) + { + } + }; + ScalableImage* m_image; std::vector<File> m_files; std::vector<QString> m_supportedFormats; int m_margins, m_padding, m_border; + void getSupportedFormats(); + void scrollAreaResized(const QSize& s); void paintThumbnails(QPaintEvent* e); void thumbnailsMouseEvent(QMouseEvent* e); - bool needsReload(const File& file, const QSize& thumbSize) const; - QSize scaledImageSize(const QSize& originalSize, const QSize& thumbSize) const; + int calcThumbSize(int availableWidth) const; + int calcWidgetHeight(int availableWidth) const; + QRect calcTopThumbRect(int thumbSize) const; + std::pair<std::size_t, std::size_t> calcVisibleRange( + int top, int bottom, int thumbSize) const; + + QRect calcBorderRect(const QRect& topRect, int thumbSize, std::size_t i) const; + QRect calcImageRect(const QRect& topRect, int thumbSize, std::size_t i) const; + QSize calcScaledImageSize( + const QSize& originalSize, const QSize& imageSize) const; + + void paintThumbnail(PaintContext& cx, std::size_t i); + void paintThumbnailBorder(PaintContext& cx, std::size_t i); + void paintThumbnailImage(PaintContext& cx, std::size_t i); + + const File* fileAtPos(const QPoint& p) const; + + bool needsReload(const File& file, const QSize& imageSize) const; + void reload(File& file, const QSize& imageSize); + void resizeWidget(); }; #endif // MODINFODIALOGIMAGES_H |
