improved animated transition in title-outline mode, by using mixed color rather than painter opacity
svn path=/trunk/KDE/kdebase/workspace/; revision=1028173
This commit is contained in:
parent
4e0f2a4d08
commit
edf8167f3c
2 changed files with 43 additions and 14 deletions
|
@ -37,7 +37,6 @@
|
|||
#include <cmath>
|
||||
|
||||
#include <kdeversion.h>
|
||||
#include <KGlobal>
|
||||
#include <KLocale>
|
||||
#include <KColorUtils>
|
||||
#include <KDebug>
|
||||
|
@ -444,7 +443,6 @@ namespace Oxygen
|
|||
|
||||
// save painter
|
||||
painter->save();
|
||||
if( timeLineIsRunning() ) painter->setOpacity( opacity() );
|
||||
if( clipRect.isValid() ) painter->setClipRegion(clipRect,Qt::IntersectClip);
|
||||
|
||||
QRect r = (isPreview()) ? OxygenClient::widget()->rect():window->rect();
|
||||
|
@ -460,6 +458,8 @@ namespace Oxygen
|
|||
if( tiles&TileSet::Top )
|
||||
{
|
||||
int shadowSize = 5;
|
||||
if( timeLineIsRunning() ) shadowSize*=opacity();
|
||||
|
||||
int height = HFRAMESIZE;
|
||||
QRect rect( r.topLeft()-position, QSize( r.width(), height ) );
|
||||
helper().slab( palette.color( widget->backgroundRole() ), 0, shadowSize )->render( rect.adjusted(-shadowSize-1, 0, shadowSize+1, 2 ), painter, TileSet::Bottom );
|
||||
|
@ -559,27 +559,24 @@ namespace Oxygen
|
|||
void OxygenClient::renderTitleOutline( QPainter* painter, const QRect& rect, const QPalette& palette ) const
|
||||
{
|
||||
|
||||
if( timeLineIsRunning() )
|
||||
{
|
||||
painter->save();
|
||||
painter->setOpacity( opacity() );
|
||||
}
|
||||
|
||||
// shadow
|
||||
{
|
||||
int shadowSize = 7;
|
||||
if( timeLineIsRunning() ) shadowSize *= opacity();
|
||||
int voffset = -shadowSize;
|
||||
if( !isMaximized() ) voffset += HFRAMESIZE;
|
||||
helper().slab( palette.color( widget()->backgroundRole() ), 0, shadowSize )->render( rect.adjusted(0, voffset, 0, 0 ), painter, TileSet::Bottom|TileSet::Left|TileSet::Right );
|
||||
|
||||
}
|
||||
|
||||
// center
|
||||
{
|
||||
int voffset = isMaximized() ? 0:HFRAMESIZE;
|
||||
renderWindowBackground(painter, rect.adjusted( 4, voffset, -4, -4 ), widget(), palette );
|
||||
}
|
||||
int offset = 4;
|
||||
if( timeLineIsRunning() ) offset *= opacity();
|
||||
|
||||
if( timeLineIsRunning() ) painter->restore();
|
||||
int voffset = isMaximized() ? 0:HFRAMESIZE;
|
||||
renderWindowBackground(painter, rect.adjusted( offset, voffset, -offset, -offset ), widget(), palette );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -624,13 +621,38 @@ namespace Oxygen
|
|||
QPalette OxygenClient::backgroundPalette( const QWidget* widget, QPalette palette ) const
|
||||
{
|
||||
|
||||
if( configuration().drawTitleOutline() && isActive() )
|
||||
{ palette.setColor( widget->window()->backgroundRole(), options()->color( KDecorationDefines::ColorTitleBar, true ) ); }
|
||||
if( configuration().drawTitleOutline() )
|
||||
{
|
||||
if( timeLineIsRunning() )
|
||||
{
|
||||
|
||||
QColor inactiveColor( backgroundColor( widget, palette, false ) );
|
||||
QColor activeColor( backgroundColor( widget, palette, true ) );
|
||||
QColor mixed( KColorUtils::mix( inactiveColor, activeColor, opacity() ) );
|
||||
palette.setColor( widget->window()->backgroundRole(), mixed );
|
||||
|
||||
} else if( isActive() ) {
|
||||
|
||||
palette.setColor( widget->window()->backgroundRole(), options()->color( KDecorationDefines::ColorTitleBar, true ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return palette;
|
||||
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
QColor OxygenClient::backgroundColor( const QWidget* widget, QPalette palette, bool active ) const
|
||||
{
|
||||
|
||||
return ( configuration().drawTitleOutline() && active ) ?
|
||||
options()->color( KDecorationDefines::ColorTitleBar, true ):
|
||||
palette.color( widget->window()->backgroundRole() );
|
||||
|
||||
}
|
||||
|
||||
//________________________________________________________________
|
||||
void OxygenClient::updateWindowShape()
|
||||
{
|
||||
|
|
|
@ -119,6 +119,13 @@ namespace Oxygen
|
|||
//! palette background
|
||||
QPalette backgroundPalette( const QWidget*, QPalette ) const;
|
||||
|
||||
//! background
|
||||
QColor backgroundColor( const QWidget* widget, QPalette palette ) const
|
||||
{ return backgroundColor( widget, palette, isActive() ); }
|
||||
|
||||
//! background
|
||||
QColor backgroundColor( const QWidget*, QPalette, bool ) const;
|
||||
|
||||
//! window background
|
||||
virtual void renderWindowBackground( QPainter*, const QRect&, const QWidget*, const QPalette& ) const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue