Fix standard logout fade when compositing is disabled

pull/2/head
Timothy Pearson 11 years ago
parent 6a40ac081b
commit 3a84ecae5d

@ -113,402 +113,399 @@ void KSMShutdownFeedback::fadeBack( void )
void KSMShutdownFeedback::slotPaintEffect() void KSMShutdownFeedback::slotPaintEffect()
{ {
// determine which fade to use // determine which fade to use
if (TDEConfigGroup(TDEGlobal::config(), "Logout").readBoolEntry("doFancyLogout", true)) if (TDEConfigGroup(TDEGlobal::config(), "Logout").readBoolEntry("doFancyLogout", true)) {
{ // fancy logout fade
float doFancyLogoutAdditionalDarkness = (float)TDEConfigGroup(TDEGlobal::config(), "Logout").readDoubleNumEntry("doFancyLogoutAdditionalDarkness", 0.6);
float doFancyLogoutAdditionalDarkness = (float)TDEConfigGroup(TDEGlobal::config(), "Logout").readDoubleNumEntry("doFancyLogoutAdditionalDarkness", 0.6); float doFancyLogoutFadeTime = (float)TDEConfigGroup(TDEGlobal::config(), "Logout").readDoubleNumEntry("doFancyLogoutFadeTime", 4000);
float doFancyLogoutFadeBackTime = (float)TDEConfigGroup(TDEGlobal::config(), "Logout").readDoubleNumEntry("doFancyLogoutFadeBackTime", 1000);
float doFancyLogoutFadeTime = (float)TDEConfigGroup(TDEGlobal::config(), "Logout").readDoubleNumEntry("doFancyLogoutFadeTime", 4000);
if (kapp->isX11CompositionAvailable()) {
float doFancyLogoutFadeBackTime = (float)TDEConfigGroup(TDEGlobal::config(), "Logout").readDoubleNumEntry("doFancyLogoutFadeBackTime", 1000); // We can do this in a different (simpler) manner because we have compositing support!
// if slotPaintEffect() is called first time, we have to initialize the gray image
if (kapp->isX11CompositionAvailable()) { // we also could do that in the constructor, but then the displaying of the
// We can do this in a different (simpler) manner because we have compositing support! // logout-UI would be too much delayed...
// if slotPaintEffect() is called first time, we have to initialize the gray image if ( m_greyImageCreated == false )
// we also could do that in the constructor, but then the displaying of the {
// logout-UI would be too much delayed... m_greyImageCreated = true;
if ( m_greyImageCreated == false )
{ // eliminate nasty flicker on first show
m_greyImageCreated = true; m_root.resize( width(), height() );
TQImage blendedImage = m_grayImage;
// eliminate nasty flicker on first show TQPainter p;
m_root.resize( width(), height() ); p.begin( &m_root );
TQImage blendedImage = m_grayImage; blendedImage.setAlphaBuffer(false);
TQPainter p; p.drawImage( 0, 0, blendedImage );
p.begin( &m_root ); p.end();
blendedImage.setAlphaBuffer(false);
p.drawImage( 0, 0, blendedImage ); setBackgroundPixmap( m_root );
p.end(); setGeometry( TQApplication::desktop()->geometry() );
setBackgroundMode( TQWidget::NoBackground );
setBackgroundPixmap( m_root );
setGeometry( TQApplication::desktop()->geometry() ); m_unfadedImage = m_grayImage.copy();
setBackgroundMode( TQWidget::NoBackground );
register uchar * r = m_grayImage.bits();
m_unfadedImage = m_grayImage.copy(); uchar * end = m_grayImage.bits() + m_grayImage.numBytes();
register uchar * r = m_grayImage.bits(); while ( r != end ) {
uchar * end = m_grayImage.bits() + m_grayImage.numBytes(); *reinterpret_cast<TQRgb*>(r) = tqRgba(0, 0, 0, 128);
r += 4;
while ( r != end ) { }
*reinterpret_cast<TQRgb*>(r) = tqRgba(0, 0, 0, 128);
r += 4; // start timer which is used for cpu-speed-independent fading
m_fadeTime.start();
m_rowsDone = 0;
} }
// start timer which is used for cpu-speed-independent fading // return if fading is completely done...
m_fadeTime.start(); if ( ( m_grayOpacity >= 1.0f && m_fadeBackwards == FALSE ) || ( m_grayOpacity <= 0.0f && m_fadeBackwards == TRUE ) )
m_rowsDone = 0; return;
}
// return if fading is completely done... if ( m_fadeBackwards == FALSE )
if ( ( m_grayOpacity >= 1.0f && m_fadeBackwards == FALSE ) || ( m_grayOpacity <= 0.0f && m_fadeBackwards == TRUE ) )
return;
if ( m_fadeBackwards == FALSE )
{
m_grayOpacity = m_fadeTime.elapsed() / doFancyLogoutFadeTime;
if ( m_grayOpacity > 1.0f )
m_grayOpacity = 1.0f;
}
else
{
m_grayOpacity = 1.0f - m_fadeTime.elapsed() / doFancyLogoutFadeBackTime - m_compensation;
if ( m_grayOpacity < 0.0f )
m_grayOpacity = 0.0f;
}
const int imgWidth = m_unfadedImage.width();
int imgHeight = m_unfadedImage.height();
int heightUnit = imgHeight / 3;
if( heightUnit < 1 )
heightUnit = 1;
int y1 = static_cast<int>( imgHeight*m_grayOpacity - heightUnit + m_grayOpacity*heightUnit*2.0f );
if( y1 > imgHeight )
y1 = imgHeight;
int y2 = y1+heightUnit;
if( y2 > imgHeight )
y2 = imgHeight;
if( m_fadeBackwards == FALSE )
{
if( y1 > 0 && y1 < imgHeight && y1-m_rowsDone > 0 && m_rowsDone < imgHeight )
{ {
TQImage img( imgWidth, y1-m_rowsDone, 32 ); m_grayOpacity = m_fadeTime.elapsed() / doFancyLogoutFadeTime;
memcpy( img.bits(), m_grayImage.scanLine( m_rowsDone ), imgWidth*(y1-m_rowsDone)*4 ); if ( m_grayOpacity > 1.0f )
bitBlt( this, 0, m_rowsDone, &img ); m_grayOpacity = 1.0f;
m_rowsDone = y1;
} }
} else
else
{
// when fading back we have to blit area which isnt gray anymore to unfaded image
if( y2 > 0 && y2 < imgHeight && m_rowsDone > y2 )
{ {
TQImage img( imgWidth, m_rowsDone-y2, 32 ); m_grayOpacity = 1.0f - m_fadeTime.elapsed() / doFancyLogoutFadeBackTime - m_compensation;
memcpy( img.bits(), m_unfadedImage.scanLine( y2 ), imgWidth*(m_rowsDone-y2)*4 ); if ( m_grayOpacity < 0.0f )
bitBlt( this, 0, y2, &img ); m_grayOpacity = 0.0f;
m_rowsDone = y2;
} }
}
const int imgWidth = m_unfadedImage.width();
int start_y1 = y1; int imgHeight = m_unfadedImage.height();
if( start_y1 < 0 ) int heightUnit = imgHeight / 3;
start_y1 = 0; if( heightUnit < 1 )
if( y2 > start_y1 ) heightUnit = 1;
{
TQImage img( imgWidth, y2-start_y1, 32 ); int y1 = static_cast<int>( imgHeight*m_grayOpacity - heightUnit + m_grayOpacity*heightUnit*2.0f );
memcpy( img.bits(), m_grayImage.scanLine( start_y1 ), ( y2-start_y1 ) * imgWidth * 4 ); if( y1 > imgHeight )
register uchar * rs = m_unfadedImage.scanLine( start_y1 ); y1 = imgHeight;
register uchar * rd = img.bits();
for( int y = start_y1; y < y2; ++y ) int y2 = y1+heightUnit;
if( y2 > imgHeight )
y2 = imgHeight;
if( m_fadeBackwards == FALSE )
{ {
// linear gradients look bad, so use cos-function if( y1 > 0 && y1 < imgHeight && y1-m_rowsDone > 0 && m_rowsDone < imgHeight )
short int opac = static_cast<short int>( 128 - cosf( M_PI*(y-y1)/heightUnit )*128.0f );
for( short int x = 0; x < imgWidth; ++x )
{ {
*reinterpret_cast<TQRgb*>(rd) = tqRgba(0, 0, 0, ((255.0-opac)/(255.0/127.0))); TQImage img( imgWidth, y1-m_rowsDone, 32 );
rs += 4; rd += 4; memcpy( img.bits(), m_grayImage.scanLine( m_rowsDone ), imgWidth*(y1-m_rowsDone)*4 );
bitBlt( this, 0, m_rowsDone, &img );
m_rowsDone = y1;
} }
} }
bitBlt( this, 0, start_y1, &img ); else
} {
// when fading back we have to blit area which isnt gray anymore to unfaded image
TQTimer::singleShot( 5, this, TQT_SLOT( slotPaintEffect() ) ); if( y2 > 0 && y2 < imgHeight && m_rowsDone > y2 )
} {
else { TQImage img( imgWidth, m_rowsDone-y2, 32 );
// if slotPaintEffect() is called first time, we have to initialize the gray image memcpy( img.bits(), m_unfadedImage.scanLine( y2 ), imgWidth*(m_rowsDone-y2)*4 );
// we also could do that in the constructor, but then the displaying of the bitBlt( this, 0, y2, &img );
// logout-UI would be too much delayed... m_rowsDone = y2;
if ( m_greyImageCreated == false ) }
{
m_greyImageCreated = true;
setBackgroundMode( TQWidget::NoBackground );
setGeometry( TQApplication::desktop()->geometry() );
m_root.resize( width(), height() ); // for the default logout
m_unfadedImage = m_grayImage.copy();
register uchar * r = m_grayImage.bits();
register uchar * g = m_grayImage.bits() + 1;
register uchar * b = m_grayImage.bits() + 2;
uchar * end = m_grayImage.bits() + m_grayImage.numBytes();
while ( r != end ) {
*r = *g = *b = (uchar) ( ( (*r)*11 + ((*g)<<4) + (*b)*5 ) * doFancyLogoutAdditionalDarkness / 32.0f );
r += 4;
g += 4;
b += 4;
} }
// start timer which is used for cpu-speed-independent fading int start_y1 = y1;
m_fadeTime.start(); if( start_y1 < 0 )
m_rowsDone = 0; start_y1 = 0;
} if( y2 > start_y1 )
// return if fading is completely done...
if ( ( m_grayOpacity >= 1.0f && m_fadeBackwards == FALSE ) || ( m_grayOpacity <= 0.0f && m_fadeBackwards == TRUE ) )
return;
if ( m_fadeBackwards == FALSE )
{
m_grayOpacity = m_fadeTime.elapsed() / doFancyLogoutFadeTime;
if ( m_grayOpacity > 1.0f )
m_grayOpacity = 1.0f;
}
else
{
m_grayOpacity = 1.0f - m_fadeTime.elapsed() / doFancyLogoutFadeBackTime - m_compensation;
if ( m_grayOpacity < 0.0f )
m_grayOpacity = 0.0f;
}
const int imgWidth = m_unfadedImage.width();
int imgHeight = m_unfadedImage.height();
int heightUnit = imgHeight / 3;
if( heightUnit < 1 )
heightUnit = 1;
int y1 = static_cast<int>( imgHeight*m_grayOpacity - heightUnit + m_grayOpacity*heightUnit*2.0f );
if( y1 > imgHeight )
y1 = imgHeight;
int y2 = y1+heightUnit;
if( y2 > imgHeight )
y2 = imgHeight;
if( m_fadeBackwards == FALSE )
{
if( y1 > 0 && y1 < imgHeight && y1-m_rowsDone > 0 && m_rowsDone < imgHeight )
{ {
TQImage img( imgWidth, y1-m_rowsDone, 32 ); TQImage img( imgWidth, y2-start_y1, 32 );
memcpy( img.bits(), m_grayImage.scanLine( m_rowsDone ), imgWidth*(y1-m_rowsDone)*4 ); memcpy( img.bits(), m_grayImage.scanLine( start_y1 ), ( y2-start_y1 ) * imgWidth * 4 );
// conversion is slow as hell if desktop-depth != 24bpp... register uchar * rs = m_unfadedImage.scanLine( start_y1 );
//Pixmap pm = m_pmio.convertToPixmap( img ); register uchar * rd = img.bits();
//bitBlt( this, 0, m_rowsDone, &pm ); for( int y = start_y1; y < y2; ++y )
//TQImage pm = m_pmio.convertToImage( img ); {
bitBlt( this, 0, m_rowsDone, &img ); // linear gradients look bad, so use cos-function
m_rowsDone = y1; short int opac = static_cast<short int>( 128 - cosf( M_PI*(y-y1)/heightUnit )*128.0f );
for( short int x = 0; x < imgWidth; ++x )
{
*reinterpret_cast<TQRgb*>(rd) = tqRgba(0, 0, 0, ((255.0-opac)/(255.0/127.0)));
rs += 4; rd += 4;
}
}
bitBlt( this, 0, start_y1, &img );
} }
TQTimer::singleShot( 5, this, TQT_SLOT( slotPaintEffect() ) );
} }
else else {
{ // if slotPaintEffect() is called first time, we have to initialize the gray image
// when fading back we have to blit area which isnt gray anymore to unfaded image // we also could do that in the constructor, but then the displaying of the
if( y2 > 0 && y2 < imgHeight && m_rowsDone > y2 ) // logout-UI would be too much delayed...
if ( m_greyImageCreated == false )
{ {
TQImage img( imgWidth, m_rowsDone-y2, 32 ); m_greyImageCreated = true;
memcpy( img.bits(), m_unfadedImage.scanLine( y2 ), imgWidth*(m_rowsDone-y2)*4 );
// conversion is slow as hell if desktop-depth != 24bpp... setBackgroundMode( TQWidget::NoBackground );
//TQPixmap pm = m_pmio.convertToPixmap( img ); setGeometry( TQApplication::desktop()->geometry() );
//bitBlt( this, 0, y2, &pm ); m_root.resize( width(), height() ); // for the default logout
bitBlt( this, 0, y2, &img );
m_rowsDone = y2; m_unfadedImage = m_grayImage.copy();
register uchar * r = m_grayImage.bits();
register uchar * g = m_grayImage.bits() + 1;
register uchar * b = m_grayImage.bits() + 2;
uchar * end = m_grayImage.bits() + m_grayImage.numBytes();
while ( r != end ) {
*r = *g = *b = (uchar) ( ( (*r)*11 + ((*g)<<4) + (*b)*5 ) * doFancyLogoutAdditionalDarkness / 32.0f );
r += 4;
g += 4;
b += 4;
}
// start timer which is used for cpu-speed-independent fading
m_fadeTime.start();
m_rowsDone = 0;
} }
}
// return if fading is completely done...
int start_y1 = y1; if ( ( m_grayOpacity >= 1.0f && m_fadeBackwards == FALSE ) || ( m_grayOpacity <= 0.0f && m_fadeBackwards == TRUE ) )
if( start_y1 < 0 ) return;
start_y1 = 0;
if( y2 > start_y1 )
{ if ( m_fadeBackwards == FALSE )
TQImage img( imgWidth, y2-start_y1, 32 );
memcpy( img.bits(), m_grayImage.scanLine( start_y1 ), ( y2-start_y1 ) * imgWidth * 4 );
register uchar * rs = m_unfadedImage.scanLine( start_y1 );
register uchar * gs = rs + 1;
register uchar * bs = gs + 1;
register uchar * rd = img.bits();
register uchar * gd = rd + 1;
register uchar * bd = gd + 1;
for( int y = start_y1; y < y2; ++y )
{ {
// linear gradients look bad, so use cos-function m_grayOpacity = m_fadeTime.elapsed() / doFancyLogoutFadeTime;
short int opac = static_cast<short int>( 128 - cosf( M_PI*(y-y1)/heightUnit )*128.0f ); if ( m_grayOpacity > 1.0f )
for( short int x = 0; x < imgWidth; ++x ) m_grayOpacity = 1.0f;
}
else
{
m_grayOpacity = 1.0f - m_fadeTime.elapsed() / doFancyLogoutFadeBackTime - m_compensation;
if ( m_grayOpacity < 0.0f )
m_grayOpacity = 0.0f;
}
const int imgWidth = m_unfadedImage.width();
int imgHeight = m_unfadedImage.height();
int heightUnit = imgHeight / 3;
if( heightUnit < 1 )
heightUnit = 1;
int y1 = static_cast<int>( imgHeight*m_grayOpacity - heightUnit + m_grayOpacity*heightUnit*2.0f );
if( y1 > imgHeight )
y1 = imgHeight;
int y2 = y1+heightUnit;
if( y2 > imgHeight )
y2 = imgHeight;
if( m_fadeBackwards == FALSE )
{
if( y1 > 0 && y1 < imgHeight && y1-m_rowsDone > 0 && m_rowsDone < imgHeight )
{
TQImage img( imgWidth, y1-m_rowsDone, 32 );
memcpy( img.bits(), m_grayImage.scanLine( m_rowsDone ), imgWidth*(y1-m_rowsDone)*4 );
// conversion is slow as hell if desktop-depth != 24bpp...
//Pixmap pm = m_pmio.convertToPixmap( img );
//bitBlt( this, 0, m_rowsDone, &pm );
//TQImage pm = m_pmio.convertToImage( img );
bitBlt( this, 0, m_rowsDone, &img );
m_rowsDone = y1;
}
}
else
{
// when fading back we have to blit area which isnt gray anymore to unfaded image
if( y2 > 0 && y2 < imgHeight && m_rowsDone > y2 )
{
TQImage img( imgWidth, m_rowsDone-y2, 32 );
memcpy( img.bits(), m_unfadedImage.scanLine( y2 ), imgWidth*(m_rowsDone-y2)*4 );
// conversion is slow as hell if desktop-depth != 24bpp...
//TQPixmap pm = m_pmio.convertToPixmap( img );
//bitBlt( this, 0, y2, &pm );
bitBlt( this, 0, y2, &img );
m_rowsDone = y2;
}
}
int start_y1 = y1;
if( start_y1 < 0 )
start_y1 = 0;
if( y2 > start_y1 )
{
TQImage img( imgWidth, y2-start_y1, 32 );
memcpy( img.bits(), m_grayImage.scanLine( start_y1 ), ( y2-start_y1 ) * imgWidth * 4 );
register uchar * rs = m_unfadedImage.scanLine( start_y1 );
register uchar * gs = rs + 1;
register uchar * bs = gs + 1;
register uchar * rd = img.bits();
register uchar * gd = rd + 1;
register uchar * bd = gd + 1;
for( int y = start_y1; y < y2; ++y )
{ {
*rd += ( ( ( *rs - *rd ) * opac ) >> 8 ); // linear gradients look bad, so use cos-function
rs += 4; rd += 4; short int opac = static_cast<short int>( 128 - cosf( M_PI*(y-y1)/heightUnit )*128.0f );
*gd += ( ( ( *gs - *gd ) * opac ) >> 8 ); for( short int x = 0; x < imgWidth; ++x )
gs += 4; gd += 4; {
*bd += ( ( ( *bs - *bd ) * opac ) >> 8 ); *rd += ( ( ( *rs - *rd ) * opac ) >> 8 );
bs += 4; bd += 4; rs += 4; rd += 4;
*gd += ( ( ( *gs - *gd ) * opac ) >> 8 );
gs += 4; gd += 4;
*bd += ( ( ( *bs - *bd ) * opac ) >> 8 );
bs += 4; bd += 4;
}
} }
// conversion is slow as hell if desktop-depth != 24bpp...
//TQPixmap pm = m_pmio.convertToPixmap( img );
//bitBlt( this, 0, start_y1, &pm );
bitBlt( this, 0, start_y1, &img );
} }
// conversion is slow as hell if desktop-depth != 24bpp...
//TQPixmap pm = m_pmio.convertToPixmap( img ); TQTimer::singleShot( 5, this, TQT_SLOT( slotPaintEffect() ) );
//bitBlt( this, 0, start_y1, &pm );
bitBlt( this, 0, start_y1, &img );
} }
TQTimer::singleShot( 5, this, TQT_SLOT( slotPaintEffect() ) );
} }
else {
} // standard logout fade
// standard logout fade
else
{
if (kapp->isX11CompositionAvailable()) { if (kapp->isX11CompositionAvailable()) {
// We can do this in a different (simpler) manner because we have compositing support! // We can do this in a different (simpler) manner because we have compositing support!
// The end effect will be very similar to the old style logout // The end effect will be very similar to the old style logout
float doFancyLogoutFadeTime = 1000; float doFancyLogoutFadeTime = 1000;
float doFancyLogoutFadeBackTime = 0; float doFancyLogoutFadeBackTime = 0;
if ( m_greyImageCreated == false ) if ( m_greyImageCreated == false ) {
{ m_greyImageCreated = true;
m_greyImageCreated = true;
// eliminate nasty flicker on first show
// eliminate nasty flicker on first show m_root.resize( width(), height() );
m_root.resize( width(), height() ); TQImage blendedImage = m_grayImage;
TQImage blendedImage = m_grayImage; TQPainter p;
TQPainter p; p.begin( &m_root );
p.begin( &m_root ); blendedImage.setAlphaBuffer(false);
blendedImage.setAlphaBuffer(false); p.drawImage( 0, 0, blendedImage );
p.drawImage( 0, 0, blendedImage ); p.end();
p.end();
setBackgroundPixmap( m_root );
setBackgroundPixmap( m_root ); setGeometry( TQApplication::desktop()->geometry() );
setGeometry( TQApplication::desktop()->geometry() ); setBackgroundMode( TQWidget::NoBackground );
setBackgroundMode( TQWidget::NoBackground );
m_unfadedImage = m_grayImage.copy();
m_unfadedImage = m_grayImage.copy();
register uchar * r = m_grayImage.bits();
register uchar * r = m_grayImage.bits(); uchar * end = m_grayImage.bits() + m_grayImage.numBytes();
uchar * end = m_grayImage.bits() + m_grayImage.numBytes();
while ( r != end ) {
while ( r != end ) { *reinterpret_cast<TQRgb*>(r) = tqRgba(0, 0, 0, 107);
*reinterpret_cast<TQRgb*>(r) = tqRgba(0, 0, 0, 107); r += 4;
r += 4; }
// start timer which is used for cpu-speed-independent fading
m_fadeTime.start();
m_rowsDone = 0;
}
// return if fading is completely done...
if ( ( m_grayOpacity >= 1.0f && m_fadeBackwards == FALSE ) || ( m_grayOpacity <= 0.0f && m_fadeBackwards == TRUE ) ) {
return;
} }
// start timer which is used for cpu-speed-independent fading if ( m_fadeBackwards == FALSE ) {
m_fadeTime.start(); m_grayOpacity = m_fadeTime.elapsed() / doFancyLogoutFadeTime;
m_rowsDone = 0; if ( m_grayOpacity > 1.0f )
} m_grayOpacity = 1.0f;
}
// return if fading is completely done... else {
if ( ( m_grayOpacity >= 1.0f && m_fadeBackwards == FALSE ) || ( m_grayOpacity <= 0.0f && m_fadeBackwards == TRUE ) ) m_grayOpacity = 1.0f - m_fadeTime.elapsed() / doFancyLogoutFadeBackTime - m_compensation;
return; if ( m_grayOpacity < 0.0f )
m_grayOpacity = 0.0f;
}
if ( m_fadeBackwards == FALSE )
{
m_grayOpacity = m_fadeTime.elapsed() / doFancyLogoutFadeTime;
if ( m_grayOpacity > 1.0f )
m_grayOpacity = 1.0f;
}
else
{
m_grayOpacity = 1.0f - m_fadeTime.elapsed() / doFancyLogoutFadeBackTime - m_compensation;
if ( m_grayOpacity < 0.0f )
m_grayOpacity = 0.0f;
}
const int imgWidth = m_unfadedImage.width();
int imgHeight = m_unfadedImage.height();
int heightUnit = imgHeight / 3;
if( heightUnit < 1 )
heightUnit = 1;
int y1 = static_cast<int>( imgHeight*m_grayOpacity - heightUnit + m_grayOpacity*heightUnit*2.0f ); const int imgWidth = m_unfadedImage.width();
if( y1 > imgHeight ) int imgHeight = m_unfadedImage.height();
y1 = imgHeight; int heightUnit = imgHeight / 3;
if( heightUnit < 1 )
heightUnit = 1;
int y2 = y1+heightUnit; int y1 = static_cast<int>( imgHeight*m_grayOpacity - heightUnit + m_grayOpacity*heightUnit*2.0f );
if( y2 > imgHeight ) if( y1 > imgHeight ) {
y2 = imgHeight; y1 = imgHeight;
}
if( m_fadeBackwards == FALSE ) int y2 = y1+heightUnit;
{ if( y2 > imgHeight ) {
if( y1 > 0 && y1 < imgHeight && y1-m_rowsDone > 0 && m_rowsDone < imgHeight ) y2 = imgHeight;
{
TQImage img( imgWidth, y1-m_rowsDone, 32 );
memcpy( img.bits(), m_grayImage.scanLine( m_rowsDone ), imgWidth*(y1-m_rowsDone)*4 );
bitBlt( this, 0, m_rowsDone, &img );
m_rowsDone = y1;
} }
}
else if( m_fadeBackwards == FALSE )
{
// when fading back we have to blit area which isnt gray anymore to unfaded image
if( y2 > 0 && y2 < imgHeight && m_rowsDone > y2 )
{ {
TQImage img( imgWidth, m_rowsDone-y2, 32 ); if( y1 > 0 && y1 < imgHeight && y1-m_rowsDone > 0 && m_rowsDone < imgHeight )
memcpy( img.bits(), m_unfadedImage.scanLine( y2 ), imgWidth*(m_rowsDone-y2)*4 ); {
bitBlt( this, 0, y2, &img ); TQImage img( imgWidth, y1-m_rowsDone, 32 );
m_rowsDone = y2; memcpy( img.bits(), m_grayImage.scanLine( m_rowsDone ), imgWidth*(y1-m_rowsDone)*4 );
bitBlt( this, 0, m_rowsDone, &img );
m_rowsDone = y1;
}
} }
} else {
// when fading back we have to blit area which isnt gray anymore to unfaded image
int start_y1 = y1; if( y2 > 0 && y2 < imgHeight && m_rowsDone > y2 )
if( start_y1 < 0 )
start_y1 = 0;
if( y2 > start_y1 )
{
TQImage img( imgWidth, y2-start_y1, 32 );
memcpy( img.bits(), m_grayImage.scanLine( start_y1 ), ( y2-start_y1 ) * imgWidth * 4 );
register uchar * rs = m_unfadedImage.scanLine( start_y1 );
register uchar * rd = img.bits();
for( int y = start_y1; y < y2; ++y )
{
// linear gradients look bad, so use cos-function
for( short int x = 0; x < imgWidth; ++x )
{ {
*reinterpret_cast<TQRgb*>(rd) = tqRgba(0, 0, 0, 107); TQImage img( imgWidth, m_rowsDone-y2, 32 );
rs += 4; rd += 4; memcpy( img.bits(), m_unfadedImage.scanLine( y2 ), imgWidth*(m_rowsDone-y2)*4 );
bitBlt( this, 0, y2, &img );
m_rowsDone = y2;
} }
} }
bitBlt( this, 0, start_y1, &img );
} int start_y1 = y1;
if( start_y1 < 0 ) {
TQTimer::singleShot( 1, this, TQT_SLOT( slotPaintEffect() ) ); start_y1 = 0;
}
if( y2 > start_y1 ) {
TQImage img( imgWidth, y2-start_y1, 32 );
memcpy( img.bits(), m_grayImage.scanLine( start_y1 ), ( y2-start_y1 ) * imgWidth * 4 );
register uchar * rs = m_unfadedImage.scanLine( start_y1 );
register uchar * rd = img.bits();
for( int y = start_y1; y < y2; ++y )
{
// linear gradients look bad, so use cos-function
for( short int x = 0; x < imgWidth; ++x )
{
*reinterpret_cast<TQRgb*>(rd) = tqRgba(0, 0, 0, 107);
rs += 4; rd += 4;
}
}
bitBlt( this, 0, start_y1, &img );
}
TQTimer::singleShot( 1, this, TQT_SLOT( slotPaintEffect() ) );
} }
else { else {
if ( m_currentY >= height() ) { if ( m_currentY >= height() ) {
if ( backgroundMode() == TQWidget::NoBackground ) { if ( backgroundMode() == TQWidget::NoBackground ) {
setBackgroundMode( TQWidget::NoBackground ); setBackgroundMode( TQWidget::NoBackground );
setBackgroundPixmap( m_root ); setBackgroundPixmap( m_root );
}
return;
} }
return;
} if ( m_currentY == 0 ) {
setBackgroundMode( TQWidget::NoBackground );
if ( m_currentY == 0 ) { setGeometry( TQApplication::desktop()->geometry() );
KPixmap pixmap; m_root.resize( width(), height() ); // for the default logout
pixmap = TQPixmap(TQPixmap::grabWindow( tqt_xrootwin(), 0, 0, width(), height() ));
bitBlt( this, 0, 0, &pixmap );
bitBlt( &m_root, 0, 0, &pixmap );
}
KPixmap pixmap; KPixmap pixmap;
pixmap = TQPixmap(TQPixmap::grabWindow( tqt_xrootwin(), 0, m_currentY, width(), 10 )); pixmap = TQPixmap(TQPixmap::grabWindow( tqt_xrootwin(), 0, 0, width(), height() ));
TQImage image = pixmap.convertToImage(); bitBlt( this, 0, 0, &pixmap );
KImageEffect::blend( Qt::black, image, 0.4 ); bitBlt( &m_root, 0, 0, &pixmap );
KImageEffect::toGray( image, true ); }
pixmap.convertFromImage( image );
bitBlt( this, 0, m_currentY, &pixmap ); KPixmap pixmap;
bitBlt( &m_root, 0, m_currentY, &pixmap ); pixmap = TQPixmap(TQPixmap::grabWindow( tqt_xrootwin(), 0, m_currentY, width(), 10 ));
m_currentY += 10; TQImage image = pixmap.convertToImage();
TQTimer::singleShot( 1, this, TQT_SLOT( slotPaintEffect() ) ); KImageEffect::blend( Qt::black, image, 0.4 );
KImageEffect::toGray( image, true );
pixmap.convertFromImage( image );
bitBlt( this, 0, m_currentY, &pixmap );
bitBlt( &m_root, 0, m_currentY, &pixmap );
m_currentY += 10;
TQTimer::singleShot( 1, this, TQT_SLOT( slotPaintEffect() ) );
} }
} }

Loading…
Cancel
Save