- enhancement: Folding button scales with editor font.

This commit is contained in:
Roy Qu 2024-03-14 20:35:26 +08:00
parent 46b273a88d
commit fa1828e225
3 changed files with 7 additions and 8 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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);