Changeset View
Changeset View
Standalone View
Standalone View
src/render/katerenderer.cpp
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 47 | KateRenderer::KateRenderer(KTextEditor::DocumentPrivate *doc, Kate::TextFolding &folding, KTextEditor::ViewPrivate *view) | |||
---|---|---|---|---|---|
58 | , m_showNonPrintableSpaces(false) | 58 | , m_showNonPrintableSpaces(false) | ||
59 | , m_printerFriendly(false) | 59 | , m_printerFriendly(false) | ||
60 | , m_config(new KateRendererConfig(this)) | 60 | , m_config(new KateRendererConfig(this)) | ||
61 | { | 61 | { | ||
62 | updateAttributes(); | 62 | updateAttributes(); | ||
63 | 63 | | |||
64 | // initialize with a sane font height | 64 | // initialize with a sane font height | ||
65 | updateFontHeight(); | 65 | updateFontHeight(); | ||
66 | | ||||
67 | // make the proper calculation for markerSize | ||||
68 | updateMarkerSize(); | ||||
66 | } | 69 | } | ||
67 | 70 | | |||
68 | KateRenderer::~KateRenderer() | 71 | KateRenderer::~KateRenderer() | ||
69 | { | 72 | { | ||
70 | delete m_config; | 73 | delete m_config; | ||
71 | } | 74 | } | ||
72 | 75 | | |||
73 | void KateRenderer::updateAttributes() | 76 | void KateRenderer::updateAttributes() | ||
▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Line(s) | 247 | { | |||
262 | paint.drawLines(points, 4); | 265 | paint.drawLines(points, 4); | ||
263 | paint.setPen(penBackup); | 266 | paint.setPen(penBackup); | ||
264 | } | 267 | } | ||
265 | 268 | | |||
266 | void KateRenderer::paintTrailingSpace(QPainter &paint, qreal x, qreal y) | 269 | void KateRenderer::paintTrailingSpace(QPainter &paint, qreal x, qreal y) | ||
267 | { | 270 | { | ||
268 | QPen penBackup(paint.pen()); | 271 | QPen penBackup(paint.pen()); | ||
269 | QPen pen(config()->tabMarkerColor()); | 272 | QPen pen(config()->tabMarkerColor()); | ||
270 | pen.setWidthF(spaceWidth() / 3.5); | 273 | | ||
274 | pen.setWidthF(m_markerSize); | ||||
anthonyfieroni: You can move width calculation in setmarkersize to safe unwanted calculations. | |||||
271 | pen.setCapStyle(Qt::RoundCap); | 275 | pen.setCapStyle(Qt::RoundCap); | ||
272 | paint.setPen(pen); | 276 | paint.setPen(pen); | ||
273 | paint.setRenderHint(QPainter::Antialiasing, true); | 277 | paint.setRenderHint(QPainter::Antialiasing, true); | ||
274 | 278 | | |||
275 | paint.drawPoint(QPointF(x, y)); | 279 | paint.drawPoint(QPointF(x, y)); | ||
276 | paint.setPen(penBackup); | 280 | paint.setPen(penBackup); | ||
277 | } | 281 | } | ||
278 | 282 | | |||
▲ Show 20 Lines • Show All 664 Lines • ▼ Show 20 Line(s) | |||||
943 | void KateRenderer::updateFontHeight() | 947 | void KateRenderer::updateFontHeight() | ||
944 | { | 948 | { | ||
945 | // use height of font + round down, ensure we have at least one pixel | 949 | // use height of font + round down, ensure we have at least one pixel | ||
946 | // we round down to avoid artifacts: line height too large vs. qt background rendering of text attributes | 950 | // we round down to avoid artifacts: line height too large vs. qt background rendering of text attributes | ||
947 | const qreal height = config()->fontMetrics().height(); | 951 | const qreal height = config()->fontMetrics().height(); | ||
948 | m_fontHeight = qMax(1, qFloor(height)); | 952 | m_fontHeight = qMax(1, qFloor(height)); | ||
949 | } | 953 | } | ||
950 | 954 | | |||
955 | void KateRenderer::updateMarkerSize() | ||||
956 | { | ||||
957 | // marker size will be calculated over the value defined | ||||
958 | // on dialog | ||||
959 | | ||||
960 | m_markerSize = spaceWidth() / (3.5 - (m_doc->config()->markerSize() * 0.5)); | ||||
961 | } | ||||
962 | | ||||
951 | qreal KateRenderer::spaceWidth() const | 963 | qreal KateRenderer::spaceWidth() const | ||
952 | { | 964 | { | ||
953 | return config()->fontMetrics().width(spaceChar); | 965 | return config()->fontMetrics().width(spaceChar); | ||
954 | } | 966 | } | ||
955 | 967 | | |||
956 | void KateRenderer::layoutLine(KateLineLayoutPtr lineLayout, int maxwidth, bool cacheLayout) const | 968 | void KateRenderer::layoutLine(KateLineLayoutPtr lineLayout, int maxwidth, bool cacheLayout) const | ||
957 | { | 969 | { | ||
958 | // if maxwidth == -1 we have no wrap | 970 | // if maxwidth == -1 we have no wrap | ||
▲ Show 20 Lines • Show All 179 Lines • Show Last 20 Lines |
You can move width calculation in setmarkersize to safe unwanted calculations.