[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/4.2/kdelibs/kate/view
From: Matthew Woehlke <mw_triad () users ! sourceforge ! net>
Date: 2009-01-09 21:48:27
Message-ID: 1231537707.686061.1148.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 908542 by mwoehlke:
Don't use hard-coded (and potentially wrong) colors for the folding markers. For 4.2 \
this loses the rainbow colors, they'll come back in 4.3 where I can make the UI \
changes (which I can't in 4.2 due to string freeze) to make them configurable. Fixes \
bug 173695 (which I am not closing until it is fixed with configurable colors in \
trunk).
CCBUG: 173695
M +29 -87 kateviewhelpers.cpp
M +2 -3 kateviewhelpers.h
--- branches/KDE/4.2/kdelibs/kate/view/kateviewhelpers.cpp #908541:908542
@@ -39,7 +39,7 @@
#include <kapplication.h>
#include <kcharsets.h>
-#include <kcolorscheme.h>
+#include <kcolorutils.h>
#include <kdebug.h>
#include <kglobalsettings.h>
#include <klocale.h>
@@ -721,72 +721,16 @@
void KateIconBorder::initializeFoldingColors()
{
- // the idea is that we make a gradient from the background color,
- // to the neutral text color, to the positive text color.
- // perhaps this is semantic abuse, but it looks good and it's
- // better than hardcoded values in that it adjusts to the colorscheme.
-
- const int half_colors = MAXFOLDINGCOLORS / 2;
-
- const KColorScheme scheme( QPalette::Normal );
-
- // we generate gradients with HSV so that it looks nicer to humans,
- // so first convert the colors
-
- const QColor background( scheme.background().color() );
- qreal bh, bs, bv;
- background.getHsvF( &bh, &bs, &bv );
-
- const QColor middle( scheme.foreground( KColorScheme::NeutralText ).color() );
- qreal mh, ms, mv;
- middle.getHsvF( &mh, &ms, &mv );
-
- const QColor final( scheme.foreground( KColorScheme::PositiveText ).color() );
- qreal fh, fs, fv;
- final.getHsvF( &fh, &fs, &fv );
-
- // some colors may be achromatic, propagate chromas from others
- // bh-->mh-->fh-->mh-->bh so that if any is chromatic, other become, too
- if( -1 == mh )
- mh = bh;
- if( -1 == fh )
- fh = mh;
- if( -1 == mh )
- mh = fh;
- if( -1 == bh )
- bh = mh;
-
- { // first half of the gradient
- const qreal dh = (mh - bh) / half_colors;
- const qreal ds = (ms - bs) / half_colors;
- const qreal dv = (mv - bv) / half_colors;
-
- for( int i = 0; i < half_colors; i++ ) {
- const qreal h = bh + dh * i;
- const qreal s = bs + ds * i;
- const qreal v = bv + dv * i;
- m_foldingColors[i] = QBrush( QColor::fromHsvF( h, s, v, 0.5 ),
- Qt::SolidPattern );
- m_foldingColorsSolid[i] = QBrush( QColor::fromHsvF( h, s, v ),
- Qt::SolidPattern );
- }
- }
+ // Get the schema
+ KateRendererConfig *config = m_view->renderer()->config();
- { // second half of the gradient
- const int num_colors = MAXFOLDINGCOLORS - half_colors;
- const qreal dh = (fh - mh) / num_colors;
- const qreal ds = (fs - ms) / num_colors;
- const qreal dv = (fv - mv) / num_colors;
-
- for( int i = 0; i < num_colors; i++ ) {
- const qreal h = mh + dh * i;
- const qreal s = ms + ds * i;
- const qreal v = mv + dv * i;
- m_foldingColors[i + half_colors] = QBrush( QColor::fromHsvF( h, s, v, 0.5 ),
- Qt::SolidPattern );
- m_foldingColorsSolid[i + half_colors] = QBrush( QColor::fromHsvF( h, s, v ),
- Qt::SolidPattern );
- }
+ const QColor background( config->iconBarColor() );
+ const QColor foreground( config->lineNumberColor() );
+ static const qreal n = 1.0 / MAXFOLDINGCOLORS;
+
+ for( int i = 0; i < MAXFOLDINGCOLORS; i++ ) {
+ const qreal j = 0.8 * pow(qreal(i) * n, 0.8);
+ m_foldingColors[i] = KColorUtils::mix( background, foreground, j );
}
}
@@ -953,28 +897,26 @@
return width;
}
-const QBrush& KateIconBorder::foldingColor(KateLineInfo *info,int realLine, bool \
solid) { +QBrush KateIconBorder::foldingColor(KateLineInfo *info,int realLine, bool \
solid) { int depth;
- if (info!=0) {
- depth=info->depth;
+ if (info != 0) { \
+ depth = info->depth; \
} else {
KateLineInfo tmp;
- m_doc->lineInfo(&tmp,realLine);
- depth=tmp.depth;
+ m_doc->lineInfo(&tmp, realLine); \
+ depth = tmp.depth; \
}
- if (solid) {
- if (depth<MAXFOLDINGCOLORS)
- return m_foldingColorsSolid[depth];
- else
- return m_foldingColorsSolid[MAXFOLDINGCOLORS-1];
- } else {
- if (depth<MAXFOLDINGCOLORS)
- return m_foldingColors[depth];
- else
- return m_foldingColors[MAXFOLDINGCOLORS-1];
- }
+ QColor result;
+ if (depth < MAXFOLDINGCOLORS)
+ result = m_foldingColors[depth];
+ else
+ result = m_foldingColors[MAXFOLDINGCOLORS-1];
+ if (!solid)
+ result.setAlphaF(0.4);
+ return QBrush( result );
+
}
void KateIconBorder::paintEvent(QPaintEvent* e)
@@ -988,12 +930,12 @@
qreal size = qMin (width, height);
- QColor c = baseColor.dark ();
+ QColor c;
+ if ( KColorUtils::luma( baseColor ) > 0.25 )
+ c = KColorUtils::darken( baseColor );
+ else
+ c = KColorUtils::shade( baseColor, 0.2 );
- // just test if that worked, else use light..., black on black is evil...
- if (c == baseColor)
- c = baseColor.light ();
-
QPen pen;
pen.setJoinStyle (Qt::RoundJoin);
pen.setColor (c);
--- branches/KDE/4.2/kdelibs/kate/view/kateviewhelpers.h #908541:908542
@@ -184,9 +184,8 @@
void showBlock(int line);
void hideBlock();
- QBrush m_foldingColors[MAXFOLDINGCOLORS];
- QBrush m_foldingColorsSolid[MAXFOLDINGCOLORS];
- const QBrush &foldingColor(KateLineInfo *, int,bool solid);
+ QColor m_foldingColors[MAXFOLDINGCOLORS];
+ QBrush foldingColor(KateLineInfo *, int,bool solid);
QString m_hoveredAnnotationText;
void initializeFoldingColors();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic