From ae07d4793b657071b9084b634c09a7e7f4e01bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Poizl?= Date: Sun, 11 Feb 2024 13:52:52 +0100 Subject: [PATCH] Draw only visible filenames in thumbnails --- imagescrollareagl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/imagescrollareagl.cpp b/imagescrollareagl.cpp index 9def140..8d11a5d 100644 --- a/imagescrollareagl.cpp +++ b/imagescrollareagl.cpp @@ -366,7 +366,9 @@ void ImageWidget::paintGL() QPainter painter(this); const int w = width()/THUMB_SIZE_BORDER; const int off = (THUMB_SIZE_BORDER - THUMB_SIZE) / 2; - for(int i=0; i < m_thumbnailCount; i++) + int start = std::max((int)(m_dy / THUMB_SIZE_BORDER_Y * w - w), 0); + int end = std::min((int)(m_dy + m_height) / THUMB_SIZE_BORDER_Y * w + w, m_thumbnailCount); + for(int i=start; i < end; i++) { float x = (i % w) * THUMB_SIZE_BORDER; float y = i / w * THUMB_SIZE_BORDER_Y + THUMB_SIZE - m_dy + off;