added 'use animations' and 'animations duration' to configuration (although not shown in configuration dialog). added smooth fading of window title when changed
svn path=/trunk/KDE/kdebase/workspace/; revision=1030276
This commit is contained in:
parent
67f1fa6451
commit
e7cdbe7e0d
4 changed files with 148 additions and 6 deletions
|
@ -69,6 +69,7 @@ namespace Oxygen
|
|||
colorCacheInvalid_(true),
|
||||
sizeGrip_( 0 ),
|
||||
timeLine_( 200, this ),
|
||||
titleTimeLine_( 200, this ),
|
||||
helper_(*oxygenHelper()),
|
||||
initialized_( false )
|
||||
{ qAddPostRoutine(oxkwincleanupBefore); }
|
||||
|
@ -100,6 +101,13 @@ namespace Oxygen
|
|||
connect( &timeLine_, SIGNAL( frameChanged( int ) ), widget(), SLOT( update() ) );
|
||||
connect( &timeLine_, SIGNAL( finished() ), widget(), SLOT( update() ) );
|
||||
|
||||
// initialize titleTimeLine
|
||||
titleTimeLine_.setFrameRange( 0, maxAnimationIndex );
|
||||
titleTimeLine_.setCurveShape( QTimeLine::EaseInOutCurve );
|
||||
connect( &titleTimeLine_, SIGNAL( frameChanged( int ) ), widget(), SLOT( update() ) );
|
||||
connect( &titleTimeLine_, SIGNAL( finished() ), widget(), SLOT( update() ) );
|
||||
connect( &titleTimeLine_, SIGNAL( finished() ), this, SLOT( updateOldCaption() ) );
|
||||
|
||||
initialized_ = true;
|
||||
|
||||
// in case of preview, one wants to make the label used
|
||||
|
@ -589,6 +597,40 @@ namespace Oxygen
|
|||
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
void OxygenClient::renderTitleText( QPainter* painter, const QRect& rect, Qt::Alignment alignment, QColor color) const
|
||||
{
|
||||
if( titleTimeLineIsRunning() )
|
||||
{
|
||||
|
||||
// if alignment is left, or right, need to get the common part of both strings
|
||||
// and draw that with full opacity and mask et out for the rest
|
||||
if( alignment & Qt::AlignLeft )
|
||||
{}
|
||||
|
||||
if( !oldCaption().isEmpty() )
|
||||
{
|
||||
color.setAlphaF( 1.0 - titleOpacity() );
|
||||
painter->setPen( color );
|
||||
painter->drawText( rect, alignment, oldCaption() );
|
||||
}
|
||||
|
||||
if( !caption().isEmpty() )
|
||||
{
|
||||
color.setAlphaF( titleOpacity() );
|
||||
painter->setPen( color );
|
||||
painter->drawText( rect, alignment, caption() );
|
||||
}
|
||||
|
||||
} else if( !caption().isEmpty() ) {
|
||||
|
||||
painter->setPen( color );
|
||||
painter->drawText( rect, alignment, caption() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
void OxygenClient::activeChange( void )
|
||||
{
|
||||
|
@ -628,6 +670,17 @@ namespace Oxygen
|
|||
KCommonDecorationUnstable::shadeChange();
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
void OxygenClient::captionChange( void )
|
||||
{
|
||||
KCommonDecorationUnstable::captionChange();
|
||||
|
||||
if( !animateTitleChange() ) return;
|
||||
if( titleTimeLineIsRunning() ) titleTimeLine_.stop();
|
||||
titleTimeLine_.start();
|
||||
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
QPalette OxygenClient::backgroundPalette( const QWidget* widget, QPalette palette ) const
|
||||
{
|
||||
|
@ -690,6 +743,13 @@ namespace Oxygen
|
|||
|
||||
configuration_ = OxygenFactory::configuration( *this );
|
||||
|
||||
// animations duration
|
||||
timeLine_.setDuration( configuration_.animationsDuration() );
|
||||
titleTimeLine_.setDuration( configuration_.animationsDuration() );
|
||||
|
||||
// need to update old caption
|
||||
updateOldCaption();
|
||||
|
||||
// handle size grip
|
||||
if( configuration_.drawSizeGrip() )
|
||||
{
|
||||
|
@ -825,9 +885,8 @@ namespace Oxygen
|
|||
if( drawSeparator() ) renderSeparator(&painter, frame, widget(), color );
|
||||
|
||||
// draw title text
|
||||
painter.setPen( titlebarTextColor( backgroundPalette( widget(), palette ) ) );
|
||||
renderTitleText( &painter, titleRect, configuration().titleAlignment() | Qt::AlignVCenter, titlebarTextColor( backgroundPalette( widget(), palette ) ) );
|
||||
|
||||
painter.drawText( titleRect, configuration().titleAlignment() | Qt::AlignVCenter, caption() );
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
// adjust if there are shadows
|
||||
|
|
|
@ -139,6 +139,9 @@ namespace Oxygen
|
|||
//! title outline
|
||||
virtual void renderTitleOutline( QPainter*, const QRect&, const QPalette& ) const;
|
||||
|
||||
//! title text
|
||||
virtual void renderTitleText( QPainter*, const QRect&, Qt::Alignment, QColor ) const;
|
||||
|
||||
//! triggered when window activity is changed
|
||||
virtual void activeChange();
|
||||
|
||||
|
@ -148,6 +151,9 @@ namespace Oxygen
|
|||
//! triggered when window shade is changed
|
||||
virtual void shadeChange();
|
||||
|
||||
//! triggered when window shade is changed
|
||||
virtual void captionChange();
|
||||
|
||||
public slots:
|
||||
|
||||
//! reset configuration
|
||||
|
@ -158,15 +164,46 @@ namespace Oxygen
|
|||
//! paint
|
||||
void paintEvent( QPaintEvent* );
|
||||
|
||||
protected slots:
|
||||
|
||||
//! update old caption with current
|
||||
void updateOldCaption( void )
|
||||
{ setOldCaption( caption() ); }
|
||||
|
||||
private:
|
||||
|
||||
//! title timeline
|
||||
bool titleTimeLineIsRunning( void ) const
|
||||
{ return titleTimeLine_.state() == QTimeLine::Running; }
|
||||
|
||||
//! title opacity
|
||||
qreal titleOpacity( void ) const
|
||||
{ return qreal( titleTimeLine_.currentFrame() )/qreal( titleTimeLine_.endFrame() ); }
|
||||
|
||||
//! old caption if any
|
||||
const QString& oldCaption( void ) const
|
||||
{ return oldCaption_; }
|
||||
|
||||
//! old caption
|
||||
void setOldCaption( const QString& value )
|
||||
{ oldCaption_ = value; }
|
||||
|
||||
//! return true when activity change are animated
|
||||
bool animateActiveChange( void ) const
|
||||
{
|
||||
if( isPreview() ) return false;
|
||||
if( configuration().useAnimations() && !isPreview() ) return false;
|
||||
else return true;
|
||||
}
|
||||
|
||||
//! return true when activity change are animated
|
||||
bool animateTitleChange( void ) const
|
||||
{
|
||||
return
|
||||
configuration().useAnimations() &&
|
||||
!configuration().drawTitleOutline() &&
|
||||
!isPreview();
|
||||
}
|
||||
|
||||
//! calculate mask
|
||||
QRegion calcMask( void ) const;
|
||||
|
||||
|
@ -210,6 +247,12 @@ namespace Oxygen
|
|||
//! animation timeLine
|
||||
QTimeLine timeLine_;
|
||||
|
||||
//! title animation timeLine
|
||||
QTimeLine titleTimeLine_;
|
||||
|
||||
//! old caption
|
||||
QString oldCaption_;
|
||||
|
||||
//! helper
|
||||
OxygenHelper& helper_;
|
||||
|
||||
|
|
|
@ -39,7 +39,9 @@ namespace Oxygen
|
|||
sizeGripMode_( SizeGripWhenNeeded ),
|
||||
drawSeparator_( false ),
|
||||
drawTitleOutline_( false ),
|
||||
useOxygenShadows_( true )
|
||||
useOxygenShadows_( true ),
|
||||
useAnimations_( true ),
|
||||
animationsDuration_( 150 )
|
||||
{}
|
||||
|
||||
//__________________________________________________
|
||||
|
@ -88,6 +90,16 @@ namespace Oxygen
|
|||
setUseOxygenShadows( group.readEntry(
|
||||
OxygenConfig::USE_OXYGEN_SHADOWS,
|
||||
defaultConfiguration.useOxygenShadows() ) );
|
||||
|
||||
// animations
|
||||
setUseAnimations( group.readEntry(
|
||||
OxygenConfig::USE_ANIMATIONS,
|
||||
defaultConfiguration.useAnimations() ) );
|
||||
|
||||
// animations
|
||||
setAnimationsDuration( group.readEntry(
|
||||
OxygenConfig::ANIMATIONS_DURATION,
|
||||
defaultConfiguration.animationsDuration() ) );
|
||||
}
|
||||
|
||||
//__________________________________________________
|
||||
|
@ -103,7 +115,8 @@ namespace Oxygen
|
|||
group.writeEntry( OxygenConfig::DRAW_SEPARATOR, drawSeparator() );
|
||||
group.writeEntry( OxygenConfig::DRAW_TITLE_OUTLINE, drawTitleOutline() );
|
||||
group.writeEntry( OxygenConfig::USE_OXYGEN_SHADOWS, useOxygenShadows() );
|
||||
|
||||
group.writeEntry( OxygenConfig::USE_ANIMATIONS, useAnimations() );
|
||||
group.writeEntry( OxygenConfig::ANIMATIONS_DURATION, animationsDuration() );
|
||||
}
|
||||
|
||||
//__________________________________________________
|
||||
|
@ -267,7 +280,10 @@ namespace Oxygen
|
|||
sizeGripMode() == other.sizeGripMode() &&
|
||||
drawSeparator() == other.drawSeparator() &&
|
||||
drawTitleOutline() == other.drawTitleOutline() &&
|
||||
useOxygenShadows() == other.useOxygenShadows();
|
||||
useOxygenShadows() == other.useOxygenShadows() &&
|
||||
useAnimations() == other.useAnimations() &&
|
||||
animationsDuration() == other.animationsDuration();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ namespace OxygenConfig
|
|||
static const QString BLEND_COLOR = "BlendColor";
|
||||
static const QString SIZE_GRIP_MODE = "SizeGripMode";
|
||||
static const QString USE_OXYGEN_SHADOWS = "UseOxygenShadows";
|
||||
static const QString USE_ANIMATIONS = "UseAnimations";
|
||||
static const QString ANIMATIONS_DURATION = "AnimationsDuration";
|
||||
|
||||
}
|
||||
|
||||
|
@ -231,6 +233,22 @@ namespace Oxygen
|
|||
virtual void setUseOxygenShadows( bool value )
|
||||
{ useOxygenShadows_ = value; }
|
||||
|
||||
//! animations
|
||||
virtual bool useAnimations( void ) const
|
||||
{ return useAnimations_; }
|
||||
|
||||
//! animations
|
||||
virtual void setUseAnimations( bool value )
|
||||
{ useAnimations_ = value; }
|
||||
|
||||
//! animations
|
||||
virtual int animationsDuration( void ) const
|
||||
{ return animationsDuration_; }
|
||||
|
||||
//! animations
|
||||
virtual void setAnimationsDuration( int value )
|
||||
{ animationsDuration_ = value; }
|
||||
|
||||
private:
|
||||
|
||||
//! title alignment
|
||||
|
@ -257,6 +275,12 @@ namespace Oxygen
|
|||
//! oxygen shadows
|
||||
bool useOxygenShadows_;
|
||||
|
||||
//! animations
|
||||
bool useAnimations_;
|
||||
|
||||
//! animations
|
||||
int animationsDuration_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue