Added contrast pixel on titlebar text. This creates 'carved-in' font, as a possible replacement to bold.
Implemented after discussion with pinheiro. svn path=/trunk/KDE/kdebase/workspace/; revision=1048886
This commit is contained in:
parent
ec0e2f0c63
commit
9ff89e1768
2 changed files with 57 additions and 8 deletions
|
@ -391,6 +391,21 @@ namespace Oxygen
|
|||
|
||||
}
|
||||
|
||||
|
||||
//_________________________________________________________
|
||||
QColor OxygenClient::titlebarContrastColor(const QPalette &palette)
|
||||
{
|
||||
if( timeLineIsRunning() ) return KColorUtils::mix(
|
||||
titlebarContrastColor( palette, false ),
|
||||
titlebarContrastColor( palette, true ),
|
||||
opacity() );
|
||||
else return titlebarContrastColor( palette, isActive() );
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
QColor OxygenClient::titlebarContrastColor(const QPalette &palette, bool active)
|
||||
{ return helper().calcLightColor( palette.color( widget()->window()->backgroundRole() ) ); }
|
||||
|
||||
//_________________________________________________________
|
||||
void OxygenClient::renderWindowBackground( QPainter* painter, const QRect& rect, const QWidget* widget, const QPalette& palette ) const
|
||||
{
|
||||
|
@ -611,29 +626,53 @@ namespace Oxygen
|
|||
}
|
||||
|
||||
//_________________________________________________________
|
||||
void OxygenClient::renderTitleText( QPainter* painter, const QRect& rect, QColor color ) const
|
||||
void OxygenClient::renderTitleText( QPainter* painter, const QRect& rect, const QColor& color, const QColor& contrast ) const
|
||||
{
|
||||
|
||||
if( titleTimeLineIsRunning() )
|
||||
{
|
||||
|
||||
if( !oldCaption().isEmpty() ) renderTitleText( painter, rect, oldCaption(), helper().alphaColor( color, 1.0 - titleOpacity() ) );
|
||||
if( !caption().isEmpty() ) renderTitleText( painter, rect, caption(), helper().alphaColor( color, titleOpacity() ) );
|
||||
if( !oldCaption().isEmpty() ) {
|
||||
|
||||
renderTitleText(
|
||||
painter, rect, oldCaption(),
|
||||
helper().alphaColor( color, 1.0 - titleOpacity() ),
|
||||
contrast.isValid() ? helper().alphaColor( contrast, 1.0 - titleOpacity() ):contrast );
|
||||
|
||||
}
|
||||
|
||||
if( !caption().isEmpty() ) {
|
||||
|
||||
renderTitleText(
|
||||
painter, rect, caption(),
|
||||
helper().alphaColor( color, titleOpacity() ),
|
||||
contrast.isValid() ? helper().alphaColor( contrast, titleOpacity() ):contrast );
|
||||
|
||||
}
|
||||
|
||||
} else if( !caption().isEmpty() ) {
|
||||
|
||||
renderTitleText( painter, rect, caption(), color );
|
||||
renderTitleText( painter, rect, caption(), color, contrast );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_______________________________________________________________________
|
||||
void OxygenClient::renderTitleText( QPainter* painter, const QRect& rect, const QString& caption, const QColor& color ) const
|
||||
void OxygenClient::renderTitleText( QPainter* painter, const QRect& rect, const QString& caption, const QColor& color, const QColor& contrast ) const
|
||||
{
|
||||
|
||||
Qt::Alignment alignment( configuration().titleAlignment() | Qt::AlignVCenter );
|
||||
QString local( QFontMetrics( painter->font() ).elidedText( caption, Qt::ElideRight, rect.width() ) );
|
||||
|
||||
if( contrast.isValid() )
|
||||
{
|
||||
painter->setPen( contrast );
|
||||
painter->translate( 0, 1 );
|
||||
painter->drawText( rect, alignment, local );
|
||||
painter->translate( 0, -1 );
|
||||
}
|
||||
|
||||
painter->setPen( color );
|
||||
painter->drawText( rect, alignment, local );
|
||||
|
||||
|
@ -983,7 +1022,9 @@ namespace Oxygen
|
|||
}
|
||||
|
||||
// title text
|
||||
renderTitleText( &painter, boundingRect, titlebarTextColor( backgroundPalette( widget(), palette ) ) );
|
||||
renderTitleText( &painter, boundingRect,
|
||||
titlebarTextColor( palette ),
|
||||
titlebarContrastColor( palette ) );
|
||||
|
||||
// separator
|
||||
if( drawSeparator() ) renderSeparator(&painter, frame, widget(), color );
|
||||
|
|
|
@ -192,10 +192,12 @@ namespace Oxygen
|
|||
virtual void renderTitleOutline( QPainter*, const QRect&, const QPalette& ) const;
|
||||
|
||||
//! title text
|
||||
virtual void renderTitleText( QPainter*, const QRect&, QColor ) const;
|
||||
/*! second color, if valid, is for contrast pixel */
|
||||
virtual void renderTitleText( QPainter*, const QRect&, const QColor&, const QColor& = QColor() ) const;
|
||||
|
||||
//! title text
|
||||
virtual void renderTitleText( QPainter*, const QRect&, const QString&, const QColor& ) const;
|
||||
/*! second color, if valid, is for contrast pixel */
|
||||
virtual void renderTitleText( QPainter*, const QRect&, const QString&, const QColor&, const QColor& = QColor() ) const;
|
||||
|
||||
//! render float frame
|
||||
virtual void renderFloatFrame( QPainter*, const QRect&, const QPalette& ) const;
|
||||
|
@ -244,6 +246,12 @@ namespace Oxygen
|
|||
//! text color
|
||||
QColor titlebarTextColor(const QPalette&, bool active);
|
||||
|
||||
//! text color
|
||||
QColor titlebarContrastColor(const QPalette&);
|
||||
|
||||
//! text color
|
||||
QColor titlebarContrastColor(const QPalette&, bool active);
|
||||
|
||||
//!@name size grip
|
||||
//@{
|
||||
|
||||
|
|
Loading…
Reference in a new issue