From fa1828e22502156c3ef10adcc8157ce5285bf935 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 14 Mar 2024 20:35:26 +0800 Subject: [PATCH] - enhancement: Folding button scales with editor font. --- libs/qsynedit/qsynedit/painter.cpp | 7 +++---- libs/redpanda_qt_utils/qt_utils/utils.cpp | 4 ++-- libs/redpanda_qt_utils/qt_utils/utils.h | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libs/qsynedit/qsynedit/painter.cpp b/libs/qsynedit/qsynedit/painter.cpp index 0684a2b4..20ca9bf3 100644 --- a/libs/qsynedit/qsynedit/painter.cpp +++ b/libs/qsynedit/qsynedit/painter.cpp @@ -91,7 +91,7 @@ void QSynEditPainter::paintEditingArea(const QRect& clip) void QSynEditPainter::paintGutter(const QRect& clip) { - QRect rcLine, rcFold; + QRectF rcLine, rcFold; int x; mClip = clip; @@ -102,7 +102,7 @@ void QSynEditPainter::paintGutter(const QRect& clip) if (mEdit->mGutter.showLineNumbers()) { // prepare the rect initially rcLine = mClip; - rcLine.setRight( std::max(rcLine.right(), mEdit->mGutterWidth - 2)); + rcLine.setRight( std::max(rcLine.right(), mEdit->mGutterWidth - 2.0)); rcLine.setBottom(rcLine.top()); if (mEdit->mGutter.useFontStyle()) { @@ -200,7 +200,6 @@ void QSynEditPainter::paintGutter(const QRect& clip) } // make a square rect - inflateRect(rcFold,-2, 0); int size = std::min(mEdit->font().pixelSize() * 4 / 5, mEdit->mGutter.rightOffset()) - lineWidth; float centerX = rcFold.left() + rcFold.width() / 2.0; float centerY = rcFold.top() + rcFold.height() / 2.0; @@ -217,7 +216,7 @@ void QSynEditPainter::paintGutter(const QRect& clip) // Paint minus sign mPainter->drawLine( - rcFold.left() + lineWidth * 2 , centerY, + rcFold.left() + lineWidth * 2 + 1 , centerY, rcFold.right() - lineWidth * 2 , centerY ); // Paint vertical line of plus sign if (foldRange->collapsed) { diff --git a/libs/redpanda_qt_utils/qt_utils/utils.cpp b/libs/redpanda_qt_utils/qt_utils/utils.cpp index 5735e2b3..adc52d74 100644 --- a/libs/redpanda_qt_utils/qt_utils/utils.cpp +++ b/libs/redpanda_qt_utils/qt_utils/utils.cpp @@ -609,12 +609,12 @@ int compareFileModifiedTime(const QString &filename1, const QString &filename2) } -void inflateRect(QRect &rect, int delta) +void inflateRect(QRectF &rect, float delta) { inflateRect(rect,delta,delta); } -void inflateRect(QRect &rect, int dx, int dy) +void inflateRect(QRectF &rect, float dx, float dy) { rect.setLeft(rect.left()-dx); rect.setRight(rect.right()+dx); diff --git a/libs/redpanda_qt_utils/qt_utils/utils.h b/libs/redpanda_qt_utils/qt_utils/utils.h index cf387433..e95744d5 100644 --- a/libs/redpanda_qt_utils/qt_utils/utils.h +++ b/libs/redpanda_qt_utils/qt_utils/utils.h @@ -150,8 +150,8 @@ int compareFileModifiedTime(const QString& filename1, const QString& filename2); int compareFileModifiedTime(const QString& filename1, qint64 timestamp); /* UI utils */ -void inflateRect(QRect& rect, int delta); -void inflateRect(QRect& rect, int dx, int dy); +void inflateRect(QRectF& rect, float delta); +void inflateRect(QRectF& rect, float dx, float dy); int screenDPI(); void setScreenDPI(int dpi);