OverwriteColors -> TitleOutline; added ::renderWindowBorder and ::renderTitleHighlight, as a replacement for the ozone blue border. Changed ShadowTilesOption into a class to initialize variables right, and make comparison operator
svn path=/trunk/KDE/kdebase/workspace/; revision=1019901
This commit is contained in:
parent
400f627430
commit
06acf4cc37
2 changed files with 181 additions and 29 deletions
|
@ -172,13 +172,16 @@ namespace Nitrogen
|
||||||
if( !( respectWindowState && maximized ))
|
if( !( respectWindowState && maximized ))
|
||||||
{ border = TFRAMESIZE; }
|
{ border = TFRAMESIZE; }
|
||||||
|
|
||||||
|
if( configuration().drawTitleOutline() ) border += HFRAMESIZE/2;
|
||||||
|
|
||||||
return border + extraBorder;
|
return border + extraBorder;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case LM_TitleEdgeBottom:
|
case LM_TitleEdgeBottom:
|
||||||
{
|
{
|
||||||
return 0;
|
if( configuration().drawTitleOutline() ) return HFRAMESIZE/2;
|
||||||
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LM_TitleEdgeLeft:
|
case LM_TitleEdgeLeft:
|
||||||
|
@ -194,7 +197,11 @@ namespace Nitrogen
|
||||||
|
|
||||||
case LM_TitleBorderLeft:
|
case LM_TitleBorderLeft:
|
||||||
case LM_TitleBorderRight:
|
case LM_TitleBorderRight:
|
||||||
return 5;
|
{
|
||||||
|
int border = 5;
|
||||||
|
if( configuration().drawTitleOutline() ) border += 2*HFRAMESIZE;
|
||||||
|
return border;
|
||||||
|
}
|
||||||
|
|
||||||
case LM_ButtonWidth:
|
case LM_ButtonWidth:
|
||||||
case LM_ButtonHeight:
|
case LM_ButtonHeight:
|
||||||
|
@ -333,7 +340,7 @@ namespace Nitrogen
|
||||||
QColor NitrogenClient::titlebarTextColor(const QPalette &palette)
|
QColor NitrogenClient::titlebarTextColor(const QPalette &palette)
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !configuration().overwriteColors() )
|
if( configuration().drawTitleOutline() )
|
||||||
{
|
{
|
||||||
|
|
||||||
return options()->color(ColorFont, isActive());
|
return options()->color(ColorFont, isActive());
|
||||||
|
@ -369,18 +376,120 @@ namespace Nitrogen
|
||||||
if( configuration().blendColor() == NitrogenConfiguration::NoBlending )
|
if( configuration().blendColor() == NitrogenConfiguration::NoBlending )
|
||||||
{
|
{
|
||||||
|
|
||||||
painter->fillRect( rect, backgroundPalette( widget, palette ).color( widget->window()->backgroundRole() ) );
|
painter->fillRect( rect, palette.color( widget->window()->backgroundRole() ) );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
int offset = layoutMetric( LM_OuterPaddingBottom );
|
int offset = layoutMetric( LM_OuterPaddingTop );
|
||||||
int height = 64 + configuration().buttonSize() - 22;
|
int height = 64 + configuration().buttonSize() - 22;
|
||||||
helper().renderWindowBackground(painter, rect, widget, backgroundPalette( widget, palette ), offset, height );
|
helper().renderWindowBackground(painter, rect, widget, palette, offset, height );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//_________________________________________________________
|
||||||
|
void NitrogenClient::renderWindowBorder( QPainter* painter, const QRect& clipRect, const QWidget* widget, const QPalette& palette ) const
|
||||||
|
{
|
||||||
|
|
||||||
|
QWidget* window = widget->window();
|
||||||
|
|
||||||
|
// get coordinates relative to the client area
|
||||||
|
QPoint position = (isPreview()) ?
|
||||||
|
widget->mapTo( const_cast<QWidget*>( NitrogenClient::widget() ), widget->rect().topLeft() ):
|
||||||
|
widget->mapTo( window, widget->rect().topLeft() );
|
||||||
|
|
||||||
|
// save painter
|
||||||
|
if (clipRect.isValid()) {
|
||||||
|
painter->save();
|
||||||
|
painter->setClipRegion(clipRect,Qt::IntersectClip);
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->setPen( Qt::NoPen );
|
||||||
|
|
||||||
|
QColor color = palette.color(window->backgroundRole());
|
||||||
|
QColor top = helper().backgroundTopColor( color );
|
||||||
|
QColor bottom = helper().backgroundBottomColor( color );
|
||||||
|
|
||||||
|
QRect r = (isPreview()) ? NitrogenClient::widget()->rect():window->rect();
|
||||||
|
r.adjust( SHADOW_WIDTH, SHADOW_WIDTH, -SHADOW_WIDTH, -SHADOW_WIDTH );
|
||||||
|
r.adjust(0,0, 1, 1);
|
||||||
|
|
||||||
|
// draw top line
|
||||||
|
// one could probably use a 'slab' here to have a drop shadow
|
||||||
|
{
|
||||||
|
|
||||||
|
int shadow_size = 5;
|
||||||
|
int height = HFRAMESIZE;
|
||||||
|
QRect rect( r.topLeft()-position, QSize( r.width(), height ) );
|
||||||
|
helper().slab( palette.color( widget->backgroundRole() ), 0, shadow_size )->render( rect.adjusted(-2, 0, 2, 2 ), painter, TileSet::Bottom );
|
||||||
|
|
||||||
|
int offset = layoutMetric( LM_OuterPaddingTop );
|
||||||
|
int gradient_height = 64 + configuration().buttonSize() - 22;
|
||||||
|
helper().renderWindowBackground(painter, rect, widget, palette, offset, gradient_height );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw bottom line
|
||||||
|
if( configuration().frameBorder() >= NitrogenConfiguration::BorderTiny )
|
||||||
|
{
|
||||||
|
int height = qMin( HFRAMESIZE, layoutMetric( LM_BorderBottom ) );
|
||||||
|
painter->setBrush( bottom );
|
||||||
|
painter->drawRect( QRect( r.bottomLeft()-position-QPoint(0,height), QSize( r.width(), height ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// left and right
|
||||||
|
if( configuration().frameBorder() >= NitrogenConfiguration::BorderTiny )
|
||||||
|
{
|
||||||
|
|
||||||
|
QLinearGradient gradient(0, r.top(), 0, r.height() );
|
||||||
|
gradient.setColorAt(0.0, top);
|
||||||
|
gradient.setColorAt(0.5, color);
|
||||||
|
gradient.setColorAt(1.0, bottom);
|
||||||
|
|
||||||
|
painter->setBrush( gradient );
|
||||||
|
|
||||||
|
// left
|
||||||
|
{
|
||||||
|
int width = qMin( HFRAMESIZE, layoutMetric( LM_BorderLeft ) );
|
||||||
|
painter->drawRect( QRect( r.topLeft()-position, QSize( width, r.height() ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// right
|
||||||
|
{
|
||||||
|
int width = qMin( HFRAMESIZE, layoutMetric( LM_BorderRight ) );
|
||||||
|
painter->drawRect( QRect( r.topRight()-position-QPoint(width,0), QSize( width, r.height() ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// restore painter
|
||||||
|
if (clipRect.isValid()) painter->restore();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//_________________________________________________________
|
||||||
|
void NitrogenClient::renderTitleOutline( QPainter* painter, const QRect& rect, const QPalette& palette ) const
|
||||||
|
{
|
||||||
|
|
||||||
|
// shadow
|
||||||
|
{
|
||||||
|
int shadow_size = 7;
|
||||||
|
int voffset = -shadow_size;
|
||||||
|
if( !isMaximized() ) voffset += HFRAMESIZE;
|
||||||
|
helper().slab( palette.color( widget()->backgroundRole() ), 0, shadow_size )->render( rect.adjusted(0, voffset, 0, 0 ), painter, TileSet::Bottom|TileSet::Left|TileSet::Right );
|
||||||
|
}
|
||||||
|
|
||||||
|
// center
|
||||||
|
{
|
||||||
|
int offset = layoutMetric( LM_OuterPaddingTop );
|
||||||
|
int height = 64 + configuration().buttonSize() - 22;
|
||||||
|
int voffset = isMaximized() ? 0:HFRAMESIZE;
|
||||||
|
helper().renderWindowBackground(painter, rect.adjusted( 4, voffset, -4, -4 ), widget(), palette, offset, height );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//_________________________________________________________
|
//_________________________________________________________
|
||||||
void NitrogenClient::activeChange( void )
|
void NitrogenClient::activeChange( void )
|
||||||
{
|
{
|
||||||
|
@ -406,7 +515,7 @@ namespace Nitrogen
|
||||||
//_________________________________________________________
|
//_________________________________________________________
|
||||||
QPalette NitrogenClient::backgroundPalette( const QWidget* widget, QPalette palette ) const
|
QPalette NitrogenClient::backgroundPalette( const QWidget* widget, QPalette palette ) const
|
||||||
{
|
{
|
||||||
if( !configuration().overwriteColors() )
|
if( configuration().drawTitleOutline() )
|
||||||
{ palette.setColor( widget->window()->backgroundRole(), options()->color( KDecorationDefines::ColorTitleBar, isActive() ) ); }
|
{ palette.setColor( widget->window()->backgroundRole(), options()->color( KDecorationDefines::ColorTitleBar, isActive() ) ); }
|
||||||
|
|
||||||
return palette;
|
return palette;
|
||||||
|
@ -506,15 +615,14 @@ namespace Nitrogen
|
||||||
QRect frame = widget()->rect();
|
QRect frame = widget()->rect();
|
||||||
|
|
||||||
// base color
|
// base color
|
||||||
QColor color = ( configuration().overwriteColors() ) ?
|
QColor color = palette.window().color();
|
||||||
palette.window().color() :
|
|
||||||
options()->color( ColorTitleBar, isActive());
|
|
||||||
|
|
||||||
// draw shadows
|
// draw shadows
|
||||||
if( compositingActive() && !isMaximized() )
|
if( compositingActive() && !isMaximized() )
|
||||||
{
|
{
|
||||||
shadowTiles(
|
shadowTiles(
|
||||||
color,KDecoration::options()->color(ColorTitleBar),
|
backgroundPalette( widget(), palette ).color( widget()->backgroundRole() ),
|
||||||
|
KDecoration::options()->color(ColorTitleBar),
|
||||||
SHADOW_WIDTH, configuration().useOxygenShadows() && isActive() )->render( frame.adjusted( 4, 4, -4, -4),
|
SHADOW_WIDTH, configuration().useOxygenShadows() && isActive() )->render( frame.adjusted( 4, 4, -4, -4),
|
||||||
&painter, TileSet::Ring);
|
&painter, TileSet::Ring);
|
||||||
|
|
||||||
|
@ -559,6 +667,10 @@ namespace Nitrogen
|
||||||
|
|
||||||
// window background
|
// window background
|
||||||
renderWindowBackground( &painter, frame, widget(), palette );
|
renderWindowBackground( &painter, frame, widget(), palette );
|
||||||
|
if( isActive() && configuration().drawTitleOutline() && !isMaximized() )
|
||||||
|
{
|
||||||
|
renderWindowBorder( &painter, frame, widget(), backgroundPalette( widget(), palette ) );
|
||||||
|
}
|
||||||
|
|
||||||
// clipping
|
// clipping
|
||||||
if( compositingActive() ) painter.setClipping(false);
|
if( compositingActive() ) painter.setClipping(false);
|
||||||
|
@ -602,11 +714,29 @@ namespace Nitrogen
|
||||||
buttonsLeftWidth() - buttonsRightWidth() -
|
buttonsLeftWidth() - buttonsRightWidth() -
|
||||||
marginLeft - marginRight;
|
marginLeft - marginRight;
|
||||||
|
|
||||||
|
QRect titleRect( titleLeft, titleTop-1, titleWidth, titleHeight );
|
||||||
|
painter.setFont( options()->font(isActive(), false) );
|
||||||
|
|
||||||
|
if( isActive() && configuration().drawTitleOutline() )
|
||||||
|
{
|
||||||
|
|
||||||
|
// get title bounding rect
|
||||||
|
QRect boundingRect = painter.boundingRect( titleRect, configuration().titleAlignment() | Qt::AlignVCenter, caption() );
|
||||||
|
|
||||||
|
// adjust
|
||||||
|
boundingRect.setTop( frame.top() );
|
||||||
|
boundingRect.setBottom( titleTop+titleHeight );
|
||||||
|
boundingRect.setLeft( qMax( boundingRect.left(), titleLeft ) - 2*HFRAMESIZE );
|
||||||
|
boundingRect.setRight( qMin( boundingRect.right(), titleLeft + titleWidth ) + 2*HFRAMESIZE );
|
||||||
|
|
||||||
|
renderTitleOutline( &painter, boundingRect, backgroundPalette( widget(), palette ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// draw title text
|
// draw title text
|
||||||
painter.setPen( titlebarTextColor( backgroundPalette( widget(), palette ) ) );
|
painter.setPen( titlebarTextColor( backgroundPalette( widget(), palette ) ) );
|
||||||
painter.setFont( options()->font(isActive(), false) );
|
|
||||||
|
|
||||||
painter.drawText(titleLeft, titleTop-1, titleWidth, titleHeight, configuration().titleAlignment() | Qt::AlignVCenter, caption() );
|
painter.drawText( titleRect, configuration().titleAlignment() | Qt::AlignVCenter, caption() );
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
// adjust if there are shadows
|
// adjust if there are shadows
|
||||||
|
@ -617,6 +747,7 @@ namespace Nitrogen
|
||||||
frame.getRect(&x, &y, &w, &h);
|
frame.getRect(&x, &y, &w, &h);
|
||||||
|
|
||||||
// separator
|
// separator
|
||||||
|
//if( isActive() && configuration().drawSeparator() && !configuration().drawTitleOutline() )
|
||||||
if( isActive() && configuration().drawSeparator() )
|
if( isActive() && configuration().drawSeparator() )
|
||||||
{ helper().drawSeparator(&painter, QRect(x, titleTop+titleHeight-1.5, w, 2), color, Qt::Horizontal); }
|
{ helper().drawSeparator(&painter, QRect(x, titleTop+titleHeight-1.5, w, 2), color, Qt::Horizontal); }
|
||||||
|
|
||||||
|
@ -664,7 +795,8 @@ namespace Nitrogen
|
||||||
{
|
{
|
||||||
|
|
||||||
helper().drawFloatFrame(
|
helper().drawFloatFrame(
|
||||||
&painter, frame, color, !compositingActive(), isActive(),
|
&painter, frame, backgroundPalette( widget(), palette ).color( widget()->backgroundRole() ),
|
||||||
|
!compositingActive(), isActive(),
|
||||||
KDecoration::options()->color(ColorTitleBar)
|
KDecoration::options()->color(ColorTitleBar)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -732,13 +864,7 @@ namespace Nitrogen
|
||||||
|
|
||||||
ShadowTilesOption currentOpt = active ? shadowTilesOption_ : glowTilesOption_;
|
ShadowTilesOption currentOpt = active ? shadowTilesOption_ : glowTilesOption_;
|
||||||
|
|
||||||
bool optionChanged = true;
|
bool optionChanged = !(currentOpt == opt );
|
||||||
if (currentOpt.active == opt.active
|
|
||||||
&& currentOpt.width == opt.width
|
|
||||||
&& opt.windowColor == opt.windowColor
|
|
||||||
&& opt.glowColor == opt.glowColor)
|
|
||||||
optionChanged = false;
|
|
||||||
|
|
||||||
if (active && glowTiles_ )
|
if (active && glowTiles_ )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,10 @@ namespace Nitrogen
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! constructor
|
//! constructor
|
||||||
NitrogenClient(KDecorationBridge *b, KDecorationFactory *f);
|
NitrogenClient(KDecorationBridge *b, KDecorationFactory *f);
|
||||||
|
|
||||||
//! destructor
|
//! destructor
|
||||||
virtual ~NitrogenClient();
|
virtual ~NitrogenClient();
|
||||||
|
@ -80,6 +80,13 @@ namespace Nitrogen
|
||||||
//! window background
|
//! window background
|
||||||
virtual void renderWindowBackground( QPainter*, const QRect&, const QWidget*, const QPalette& ) const;
|
virtual void renderWindowBackground( QPainter*, const QRect&, const QWidget*, const QPalette& ) const;
|
||||||
|
|
||||||
|
//! window border
|
||||||
|
// this draws a "blue" border around active window
|
||||||
|
virtual void renderWindowBorder( QPainter*, const QRect&, const QWidget*, const QPalette& ) const;
|
||||||
|
|
||||||
|
//! title outline
|
||||||
|
virtual void renderTitleOutline( QPainter*, const QRect&, const QPalette& ) const;
|
||||||
|
|
||||||
//! triggered when window activity is changed
|
//! triggered when window activity is changed
|
||||||
virtual void activeChange();
|
virtual void activeChange();
|
||||||
|
|
||||||
|
@ -101,11 +108,30 @@ namespace Nitrogen
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct ShadowTilesOption {
|
class ShadowTilesOption {
|
||||||
QColor windowColor;
|
|
||||||
QColor glowColor;
|
public:
|
||||||
qreal width;
|
|
||||||
bool active;
|
//! constructor
|
||||||
|
ShadowTilesOption( void ):
|
||||||
|
width(0),
|
||||||
|
active(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! equal to operator
|
||||||
|
bool operator == ( const ShadowTilesOption& other ) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
windowColor == other.windowColor &&
|
||||||
|
glowColor == other.glowColor &&
|
||||||
|
width == other.width &&
|
||||||
|
active == other.active;
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor windowColor;
|
||||||
|
QColor glowColor;
|
||||||
|
qreal width;
|
||||||
|
bool active;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! palette background
|
//! palette background
|
||||||
|
|
Loading…
Reference in a new issue