More code cleanup: moved declaration of 'reduceContrast' and 'renderDot' global functions to oxygenclient.h. Added 'renderFlags' to control which part of the button is to be drawn. Also added flag to force button as 'inactive' even if belonging to an active window (needed for window tabs)

svn path=/trunk/KDE/kdebase/workspace/; revision=1035241
This commit is contained in:
Hugo Pereira Da Costa 2009-10-14 15:36:08 +00:00
parent f898d1193f
commit e748b5244b
2 changed files with 35 additions and 25 deletions

View file

@ -53,6 +53,31 @@ namespace Oxygen
{
p->drawEllipse(QRectF(point.x()-diameter/2, point.y()-diameter/2, diameter, diameter));
}
//_________________________________________________________
QColor reduceContrast(const QColor &c0, const QColor &c1, double t)
{
double s = KColorUtils::contrastRatio(c0, c1);
if (s < t)
return c1;
double l = 0.0, h = 1.0;
double x = s, a;
QColor r = c1;
for (int maxiter = 16; maxiter; --maxiter)
{
a = 0.5 * (l + h);
r = KColorUtils::mix(c0, c1, a);
x = KColorUtils::contrastRatio(c0, r);
if (fabs(x - t) < 0.01) break;
if (x > t) h = a;
else l = a;
}
return r;
}
//___________________________________________
OxygenClient::OxygenClient(KDecorationBridge *b, OxygenFactory *f):
@ -184,31 +209,6 @@ namespace Oxygen
}
}
//_________________________________________________________
QColor reduceContrast(const QColor &c0, const QColor &c1, double t)
{
double s = KColorUtils::contrastRatio(c0, c1);
if (s < t)
return c1;
double l = 0.0, h = 1.0;
double x = s, a;
QColor r = c1;
for (int maxiter = 16; maxiter; --maxiter)
{
a = 0.5 * (l + h);
r = KColorUtils::mix(c0, c1, a);
x = KColorUtils::contrastRatio(c0, r);
if (fabs(x - t) < 0.01) break;
if (x > t) h = a;
else l = a;
}
return r;
}
//_________________________________________________________
QRegion OxygenClient::calcMask( void ) const
{

View file

@ -298,6 +298,16 @@ namespace Oxygen
};
//!@name utility functions
//@{
// dot
void renderDot(QPainter*, const QPointF&, qreal );
// contrast
QColor reduceContrast(const QColor&, const QColor&, double t);
//@}
} // namespace Oxygen