Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateviewhelpers.cpp
Show First 20 Lines • Show All 1587 Lines • ▼ Show 20 Line(s) | 1585 | { | |||
---|---|---|---|---|---|
1588 | if (m_iconBorderOn) { | 1588 | if (m_iconBorderOn) { | ||
1589 | w += iconPaneWidth + 2; | 1589 | w += iconPaneWidth + 2; | ||
1590 | } | 1590 | } | ||
1591 | 1591 | | |||
1592 | if (m_annotationBorderOn) { | 1592 | if (m_annotationBorderOn) { | ||
1593 | w += m_annotationBorderWidth + 2; | 1593 | w += m_annotationBorderWidth + 2; | ||
1594 | } | 1594 | } | ||
1595 | 1595 | | |||
1596 | if (m_lineNumbersOn || (m_view->dynWordWrap() && m_dynWrapIndicatorsOn)) { | 1596 | if (m_lineNumbersOn || (m_dynWrapIndicatorsOn && m_view->config()->dynWordWrap())) { | ||
1597 | w += lineNumberWidth() + 2; | 1597 | w += lineNumberWidth() + 2; | ||
1598 | } | 1598 | } | ||
1599 | 1599 | | |||
1600 | if (m_foldingMarkersOn) { | 1600 | if (m_foldingMarkersOn) { | ||
1601 | w += iconPaneWidth; | 1601 | w += iconPaneWidth; | ||
1602 | } | 1602 | } | ||
1603 | 1603 | | |||
1604 | // space for the line modification system border | 1604 | // space for the line modification system border | ||
Show All 31 Lines | |||||
1636 | } | 1636 | } | ||
1637 | 1637 | | |||
1638 | int KateIconBorder::lineNumberWidth() const | 1638 | int KateIconBorder::lineNumberWidth() const | ||
1639 | { | 1639 | { | ||
1640 | // width = (number of digits + 1) * char width | 1640 | // width = (number of digits + 1) * char width | ||
1641 | const int digits = (int) ceil(log10((double)(m_view->doc()->lines() + 1))); | 1641 | const int digits = (int) ceil(log10((double)(m_view->doc()->lines() + 1))); | ||
1642 | int width = m_lineNumbersOn ? (int)ceil((digits + 1) * m_maxCharWidth) : 0; | 1642 | int width = m_lineNumbersOn ? (int)ceil((digits + 1) * m_maxCharWidth) : 0; | ||
1643 | 1643 | | |||
1644 | if (m_view->dynWordWrap() && m_dynWrapIndicatorsOn) { | 1644 | if (m_dynWrapIndicatorsOn && m_view->config()->dynWordWrap()) { | ||
1645 | // HACK: 16 == style().scrollBarExtent().width() | 1645 | // HACK: 16 == style().scrollBarExtent().width() | ||
1646 | width = qMax(16 + 4, width); | 1646 | width = qMax(16 + 4, width); | ||
1647 | 1647 | | |||
1648 | if (m_cachedLNWidth != width || m_oldBackgroundColor != m_view->renderer()->config()->iconBarColor()) { | 1648 | if (m_cachedLNWidth != width || m_oldBackgroundColor != m_view->renderer()->config()->iconBarColor()) { | ||
1649 | int w = 16;// HACK: 16 == style().scrollBarExtent().width() style().scrollBarExtent().width(); | 1649 | int w = 16;// HACK: 16 == style().scrollBarExtent().width() style().scrollBarExtent().width(); | ||
1650 | int h = m_view->renderer()->lineHeight(); | 1650 | int h = m_view->renderer()->lineHeight(); | ||
1651 | 1651 | | |||
1652 | QSize newSize(w * devicePixelRatio(), h * devicePixelRatio()); | 1652 | QSize newSize(w * devicePixelRatio(), h * devicePixelRatio()); | ||
▲ Show 20 Lines • Show All 305 Lines • ▼ Show 20 Line(s) | 1952 | { | |||
1958 | 1958 | | |||
1959 | // center the folding boxes | 1959 | // center the folding boxes | ||
1960 | int m_px = (h - 11) / 2; | 1960 | int m_px = (h - 11) / 2; | ||
1961 | if (m_px < 0) { | 1961 | if (m_px < 0) { | ||
1962 | m_px = 0; | 1962 | m_px = 0; | ||
1963 | } | 1963 | } | ||
1964 | 1964 | | |||
1965 | int lnWidth(0); | 1965 | int lnWidth(0); | ||
1966 | if (m_lineNumbersOn || (m_view->dynWordWrap() && m_dynWrapIndicatorsOn)) { // avoid calculating unless needed ;-) | 1966 | if (m_lineNumbersOn || m_dynWrapIndicatorsOn) { // avoid calculating unless needed ;-) | ||
1967 | lnWidth = lineNumberWidth(); | 1967 | lnWidth = lineNumberWidth(); | ||
1968 | if (lnWidth != m_cachedLNWidth || m_oldBackgroundColor != m_view->renderer()->config()->iconBarColor()) { | 1968 | if (lnWidth != m_cachedLNWidth || m_oldBackgroundColor != m_view->renderer()->config()->iconBarColor()) { | ||
1969 | // we went from n0 ->n9 lines or vice versa | 1969 | // we went from n0 ->n9 lines or vice versa | ||
1970 | // this causes an extra updateGeometry() first time the line numbers | 1970 | // this causes an extra updateGeometry() first time the line numbers | ||
1971 | // are displayed, but sizeHint() is supposed to be const so we can't set | 1971 | // are displayed, but sizeHint() is supposed to be const so we can't set | ||
1972 | // the cached value there. | 1972 | // the cached value there. | ||
1973 | m_cachedLNWidth = lnWidth; | 1973 | m_cachedLNWidth = lnWidth; | ||
1974 | m_oldBackgroundColor = m_view->renderer()->config()->iconBarColor(); | 1974 | m_oldBackgroundColor = m_view->renderer()->config()->iconBarColor(); | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | 2056 | if ((realLine > -1) && model) { | |||
2062 | m_annotationItemDelegate->paint(&p, styleOption, model, realLine); | 2062 | m_annotationItemDelegate->paint(&p, styleOption, model, realLine); | ||
2063 | } | 2063 | } | ||
2064 | 2064 | | |||
2065 | // adjust current X position | 2065 | // adjust current X position | ||
2066 | lnX += m_annotationBorderWidth + /* separator line width */1; | 2066 | lnX += m_annotationBorderWidth + /* separator line width */1; | ||
2067 | } | 2067 | } | ||
2068 | 2068 | | |||
2069 | // line number | 2069 | // line number | ||
2070 | if (m_lineNumbersOn || (m_view->dynWordWrap() && m_dynWrapIndicatorsOn)) { | 2070 | if (m_lineNumbersOn || m_dynWrapIndicatorsOn) { | ||
2071 | if (realLine > -1) { | 2071 | if (realLine > -1) { | ||
2072 | int distanceToCurrent = abs(realLine - static_cast<int>(currentLine)); | 2072 | int distanceToCurrent = abs(realLine - static_cast<int>(currentLine)); | ||
2073 | QColor color; | 2073 | QColor color; | ||
2074 | 2074 | | |||
2075 | if (distanceToCurrent == 0) { | 2075 | if (distanceToCurrent == 0) { | ||
2076 | color = m_view->renderer()->config()->currentLineNumberColor(); | 2076 | color = m_view->renderer()->config()->currentLineNumberColor(); | ||
2077 | } else { | 2077 | } else { | ||
2078 | color = m_view->renderer()->config()->lineNumberColor(); | 2078 | color = m_view->renderer()->config()->lineNumberColor(); | ||
Show All 13 Lines | 2084 | if (m_relLineNumbersOn) { | |||
2092 | if (m_updateRelLineNumbers) { | 2092 | if (m_updateRelLineNumbers) { | ||
2093 | m_updateRelLineNumbers = false; | 2093 | m_updateRelLineNumbers = false; | ||
2094 | update(); | 2094 | update(); | ||
2095 | } | 2095 | } | ||
2096 | } else if (m_lineNumbersOn) { | 2096 | } else if (m_lineNumbersOn) { | ||
2097 | p.drawText(lnX + m_maxCharWidth / 2, y, lnWidth - m_maxCharWidth, h, | 2097 | p.drawText(lnX + m_maxCharWidth / 2, y, lnWidth - m_maxCharWidth, h, | ||
2098 | Qt::TextDontClip | Qt::AlignRight | Qt::AlignVCenter, QString::number(realLine + 1)); | 2098 | Qt::TextDontClip | Qt::AlignRight | Qt::AlignVCenter, QString::number(realLine + 1)); | ||
2099 | } | 2099 | } | ||
2100 | } else if (m_view->dynWordWrap() && m_dynWrapIndicatorsOn) { | 2100 | } else if (m_dynWrapIndicatorsOn) { | ||
2101 | p.drawPixmap(lnX + lnWidth - (m_arrow.width() / m_arrow.devicePixelRatio()) - 2, y, m_arrow); | 2101 | p.drawPixmap(lnX + lnWidth - (m_arrow.width() / m_arrow.devicePixelRatio()) - 2, y, m_arrow); | ||
2102 | } | 2102 | } | ||
2103 | } | 2103 | } | ||
2104 | 2104 | | |||
2105 | lnX += lnWidth + 2; | 2105 | lnX += lnWidth + 2; | ||
2106 | } | 2106 | } | ||
2107 | 2107 | | |||
2108 | // folding markers | 2108 | // folding markers | ||
▲ Show 20 Lines • Show All 1095 Lines • Show Last 20 Lines |