forked from qt-creator/qt-creator
Editor: improve indent marker painting
Slightly move the indent marker and paint also the the first level. Change-Id: I8a80b8f694950e3240e69807de71a626a4adc16d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -4341,7 +4341,7 @@ void TextEditorWidgetPrivate::paintIndentDepth(PaintEventData &data,
|
|||||||
if (currentDepth < 0)
|
if (currentDepth < 0)
|
||||||
currentDepth = tabSettings.indentationColumn(text);
|
currentDepth = tabSettings.indentationColumn(text);
|
||||||
|
|
||||||
if (currentDepth <= tabSettings.m_indentSize || blockData.layout->lineCount() < 1)
|
if (currentDepth == 0 || blockData.layout->lineCount() < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const qreal horizontalAdvance = QFontMetricsF(q->font()).horizontalAdvance(
|
const qreal horizontalAdvance = QFontMetricsF(q->font()).horizontalAdvance(
|
||||||
@@ -4352,11 +4352,10 @@ void TextEditorWidgetPrivate::paintIndentDepth(PaintEventData &data,
|
|||||||
|
|
||||||
const QTextLine textLine = blockData.layout->lineAt(0);
|
const QTextLine textLine = blockData.layout->lineAt(0);
|
||||||
const QRectF rect = textLine.naturalTextRect();
|
const QRectF rect = textLine.naturalTextRect();
|
||||||
qreal x = textLine.cursorToX(0) + data.offset.x();
|
qreal x = textLine.cursorToX(0) + data.offset.x() + qMax(0, q->cursorWidth() - 1);
|
||||||
int paintColumn = tabSettings.m_indentSize;
|
int paintColumn = 0;
|
||||||
|
|
||||||
while (paintColumn < currentDepth) {
|
while (paintColumn < currentDepth) {
|
||||||
x += horizontalAdvance;
|
|
||||||
if (x >= 0) {
|
if (x >= 0) {
|
||||||
int paintPosition = tabSettings.positionAtColumn(text, paintColumn);
|
int paintPosition = tabSettings.positionAtColumn(text, paintColumn);
|
||||||
if (blockData.layout->lineForTextPosition(paintPosition).lineNumber() != 0)
|
if (blockData.layout->lineForTextPosition(paintPosition).lineNumber() != 0)
|
||||||
@@ -4366,6 +4365,7 @@ void TextEditorWidgetPrivate::paintIndentDepth(PaintEventData &data,
|
|||||||
const QLineF line(top, bottom);
|
const QLineF line(top, bottom);
|
||||||
painter.drawLine(line);
|
painter.drawLine(line);
|
||||||
}
|
}
|
||||||
|
x += horizontalAdvance;
|
||||||
paintColumn += tabSettings.m_indentSize;
|
paintColumn += tabSettings.m_indentSize;
|
||||||
}
|
}
|
||||||
painter.restore();
|
painter.restore();
|
||||||
|
Reference in New Issue
Block a user