Aurorae supports drawing a halo behind the window title.

New options in General section of config file: HaloActive and HaloInactive. Default to off.
FEATURE: 224011

svn path=/trunk/KDE/kdebase/workspace/; revision=1081745
This commit is contained in:
Martin Gräßlin 2010-01-29 09:19:45 +00:00
parent fc0633fae3
commit b15fc9e1d9
5 changed files with 37 additions and 6 deletions

View file

@ -836,12 +836,12 @@ void AuroraeClient::paintEvent(QPaintEvent *event)
} else { } else {
result = Plasma::PaintUtils::transition(m_activeText, m_inactiveText, m_animationProgress); result = Plasma::PaintUtils::transition(m_activeText, m_inactiveText, m_animationProgress);
} }
painter.drawPixmap(titleRect(), result); painter.drawPixmap(0, 0, result);
} else { } else {
if (isActive()) { if (isActive()) {
painter.drawPixmap(titleRect(), m_activeText); painter.drawPixmap(0, 0, m_activeText);
} else { } else {
painter.drawPixmap(titleRect(), m_inactiveText); painter.drawPixmap(0, 0, m_inactiveText);
} }
} }
} }
@ -855,6 +855,15 @@ void AuroraeClient::generateTextPixmap(QPixmap& pixmap, bool active)
} }
const ThemeConfig &conf = AuroraeFactory::instance()->themeConfig(); const ThemeConfig &conf = AuroraeFactory::instance()->themeConfig();
painter.setFont(options()->font(active)); painter.setFont(options()->font(active));
if ((active && conf.haloActive()) || (!active && conf.haloInactive())) {
QRectF haloRect = painter.fontMetrics().boundingRect(titleRect(),
conf.alignment() | conf.verticalAlignment() | Qt::TextSingleLine,
caption());
if (haloRect.width() > titleRect().width()) {
haloRect.setWidth(titleRect().width());
}
Plasma::PaintUtils::drawHalo(&painter, haloRect);
}
if (conf.useTextShadow()) { if (conf.useTextShadow()) {
// shadow code is inspired by Qt FAQ: How can I draw shadows behind text? // shadow code is inspired by Qt FAQ: How can I draw shadows behind text?
// see http://www.qtsoftware.com/developer/faqs/faq.2007-07-27.3052836051 // see http://www.qtsoftware.com/developer/faqs/faq.2007-07-27.3052836051
@ -892,7 +901,7 @@ void AuroraeClient::generateTextPixmap(QPixmap& pixmap, bool active)
} else { } else {
painter.setPen(conf.inactiveTextColor()); painter.setPen(conf.inactiveTextColor());
} }
painter.drawText(pixmap.rect(), conf.alignment() | conf.verticalAlignment() | Qt::TextSingleLine, painter.drawText(titleRect(), conf.alignment() | conf.verticalAlignment() | Qt::TextSingleLine,
caption()); caption());
painter.end(); painter.end();
} }
@ -966,9 +975,9 @@ void AuroraeClient::animationFinished(int id)
void AuroraeClient::resize(const QSize& s) void AuroraeClient::resize(const QSize& s)
{ {
KCommonDecoration::resize(s); KCommonDecoration::resize(s);
m_activeText = QPixmap(titleRect().size()); m_activeText = QPixmap(QSize(widget()->width(), titleRect().height() + titleRect().y()));
m_activeText.fill(Qt::transparent); m_activeText.fill(Qt::transparent);
m_inactiveText = QPixmap(titleRect().size()); m_inactiveText = QPixmap(QSize(widget()->width(), titleRect().height() + titleRect().y()));
m_inactiveText.fill(Qt::transparent); m_inactiveText.fill(Qt::transparent);
captionChange(); captionChange();
} }

View file

@ -36,6 +36,8 @@ void ThemeConfig::load(KConfig *conf)
m_inactiveTextShadowColor = general.readEntry("InactiveTextShadowColor", QColor(Qt::white)); m_inactiveTextShadowColor = general.readEntry("InactiveTextShadowColor", QColor(Qt::white));
m_textShadowOffsetX = general.readEntry("TextShadowOffsetX", 0); m_textShadowOffsetX = general.readEntry("TextShadowOffsetX", 0);
m_textShadowOffsetY = general.readEntry("TextShadowOffsetY", 0); m_textShadowOffsetY = general.readEntry("TextShadowOffsetY", 0);
m_haloActive = general.readEntry("HaloActive", false);
m_haloInactive = general.readEntry("HaloInactive", false);
QString alignment = (general.readEntry("TitleAlignment", "Left")).toLower(); QString alignment = (general.readEntry("TitleAlignment", "Left")).toLower();
if (alignment == "left") { if (alignment == "left") {
m_alignment = Qt::AlignLeft; m_alignment = Qt::AlignLeft;

View file

@ -55,6 +55,12 @@ public:
bool useTextShadow() const { bool useTextShadow() const {
return m_useTextShadow; return m_useTextShadow;
} }
bool haloActive() const {
return m_haloActive;
}
bool haloInactive() const {
return m_haloInactive;
}
// Alignment // Alignment
Qt::Alignment alignment() const { Qt::Alignment alignment() const {
return m_alignment; return m_alignment;
@ -184,6 +190,8 @@ private:
int m_textShadowOffsetX; int m_textShadowOffsetX;
int m_textShadowOffsetY; int m_textShadowOffsetY;
bool m_useTextShadow; bool m_useTextShadow;
bool m_haloActive;
bool m_haloInactive;
Qt::Alignment m_alignment; Qt::Alignment m_alignment;
Qt::Alignment m_verticalAlignment; Qt::Alignment m_verticalAlignment;
// borders // borders

View file

@ -94,6 +94,8 @@ ActiveTextShadowColor=255,255,255,255 # Shadow text color of active window
InactiveTextShadowColor=255,255,255,255 # Shadow text color of active window InactiveTextShadowColor=255,255,255,255 # Shadow text color of active window
TextShadowOffsetX=0 # Offset of shadow in x direction TextShadowOffsetX=0 # Offset of shadow in x direction
TextShadowOffsetY=0 # Offset of shadow in y direction TextShadowOffsetY=0 # Offset of shadow in y direction
HaloActive=false # Draw halo behing title of active window (since 4.5)
HaloInactive=false # Draw halo behing title of inactive window (since 4.5)
LeftButtons=MS # buttons in left button group (see http://api.kde.org/4.x-api/kdebase-workspace-apidocs/kwin/lib/html/classKDecorationOptions.html#8ad12d76c93c5f1a12ea07b30f92d2fa) LeftButtons=MS # buttons in left button group (see http://api.kde.org/4.x-api/kdebase-workspace-apidocs/kwin/lib/html/classKDecorationOptions.html#8ad12d76c93c5f1a12ea07b30f92d2fa)
RightButtons=HIA__X # buttons in right button group RightButtons=HIA__X # buttons in right button group
Shadow=true # decoration provides shadows: you have to add padding Shadow=true # decoration provides shadows: you have to add padding

View file

@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KStandardDirs> #include <KStandardDirs>
// Plasma // Plasma
#include <Plasma/FrameSvg> #include <Plasma/FrameSvg>
#include <Plasma/PaintUtils>
namespace KWin namespace KWin
{ {
@ -319,6 +320,15 @@ void AuroraePreview::paintDeco( QPainter *painter, bool active, const QRect &rec
caption = i18n( "Inactive Window" ); caption = i18n( "Inactive Window" );
} }
painter->setFont( KGlobalSettings::windowTitleFont() ); painter->setFont( KGlobalSettings::windowTitleFont() );
if( ( active && m_themeConfig->haloActive() ) || ( !active && m_themeConfig->haloInactive() ) )
{
QRectF haloRect = painter->fontMetrics().boundingRect(titleRect.toRect(),
m_themeConfig->alignment() | m_themeConfig->verticalAlignment() | Qt::TextSingleLine,
caption);
if( haloRect.width() > titleRect.width() )
haloRect.setWidth( titleRect.width() );
Plasma::PaintUtils::drawHalo(painter, haloRect);
}
if( m_themeConfig->useTextShadow() ) if( m_themeConfig->useTextShadow() )
{ {
// shadow code is inspired by Qt FAQ: How can I draw shadows behind text? // shadow code is inspired by Qt FAQ: How can I draw shadows behind text?