From e748b5244bc531c9c9e2bd1a67c52e90a137b170 Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Wed, 14 Oct 2009 15:36:08 +0000 Subject: [PATCH] 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 --- clients/oxygen/oxygenclient.cpp | 50 ++++++++++++++++----------------- clients/oxygen/oxygenclient.h | 10 +++++++ 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/clients/oxygen/oxygenclient.cpp b/clients/oxygen/oxygenclient.cpp index ce79c459be..ab6da2ccd2 100644 --- a/clients/oxygen/oxygenclient.cpp +++ b/clients/oxygen/oxygenclient.cpp @@ -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 { diff --git a/clients/oxygen/oxygenclient.h b/clients/oxygen/oxygenclient.h index de41413d13..e868d0ef0c 100644 --- a/clients/oxygen/oxygenclient.h +++ b/clients/oxygen/oxygenclient.h @@ -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