Prettify filter box by adding frame around it and prepending "Filter:" to the filter text.
Also add some comments. svn path=/trunk/KDE/kdebase/workspace/; revision=704435
This commit is contained in:
parent
a7ab423f93
commit
38bc48cb11
2 changed files with 24 additions and 9 deletions
|
@ -126,12 +126,17 @@ void PresentWindowsEffect::paintScreen( int mask, QRegion region, ScreenPaintDat
|
||||||
{
|
{
|
||||||
effects->paintScreen( mask, region, data );
|
effects->paintScreen( mask, region, data );
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
if( filterTexture && region.intersects( filterTextureRect ))
|
if( filterTexture && region.intersects( filterFrameRect ))
|
||||||
{
|
{
|
||||||
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
|
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
|
||||||
filterTexture->bind();
|
|
||||||
glEnable( GL_BLEND );
|
glEnable( GL_BLEND );
|
||||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||||
|
// First render the frame
|
||||||
|
QColor color = QPalette().color( QPalette::Highlight );
|
||||||
|
glColor4f( color.redF(), color.greenF(), color.blueF(), 0.75f );
|
||||||
|
renderRoundBoxWithEdge( filterFrameRect );
|
||||||
|
// And then the text on top of it
|
||||||
|
filterTexture->bind();
|
||||||
filterTexture->render( mask, region, filterTextureRect );
|
filterTexture->render( mask, region, filterTextureRect );
|
||||||
filterTexture->unbind();
|
filterTexture->unbind();
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
|
@ -771,25 +776,34 @@ void PresentWindowsEffect::updateFilterTexture()
|
||||||
discardFilterTexture();
|
discardFilterTexture();
|
||||||
if( windowFilter.isEmpty())
|
if( windowFilter.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
// Create font for filter text
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setPointSize( font.pointSize() * 2 );
|
font.setPointSize( font.pointSize() * 2 );
|
||||||
font.setBold( true );
|
font.setBold( true );
|
||||||
QRect rect = QFontMetrics( font ).boundingRect( windowFilter );
|
// Get size of the rect containing filter text
|
||||||
const int border = 10;
|
QFontMetrics fm( font );
|
||||||
rect.adjust( -border, -border, border, border );
|
QRect rect;
|
||||||
|
QString translatedString = i18n( "Filter:\n%1", windowFilter );
|
||||||
|
rect.setSize( fm.size( 0, translatedString ));
|
||||||
QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop());
|
QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop());
|
||||||
|
// Create image
|
||||||
QImage im( rect.width(), rect.height(), QImage::Format_ARGB32 );
|
QImage im( rect.width(), rect.height(), QImage::Format_ARGB32 );
|
||||||
QColor col = QPalette().color( QPalette::Highlight );
|
im.fill( Qt::transparent );
|
||||||
col.setAlpha( 128 ); // 0.5
|
// Paint the filter text to it
|
||||||
im.fill( col.rgba());
|
|
||||||
QPainter p( &im );
|
QPainter p( &im );
|
||||||
p.setFont( font );
|
p.setFont( font );
|
||||||
p.setPen( QPalette().color( QPalette::HighlightedText ) );
|
p.setPen( QPalette().color( QPalette::HighlightedText ) );
|
||||||
p.drawText( -rect.topLeft(), windowFilter );
|
p.drawText( rect, Qt::AlignCenter, translatedString );
|
||||||
p.end();
|
p.end();
|
||||||
|
// Create GL texture
|
||||||
filterTexture = new GLTexture( im );
|
filterTexture = new GLTexture( im );
|
||||||
|
// Get position for filter text and it's frame
|
||||||
filterTextureRect = QRect( area.x() + ( area.width() - rect.width()) / 2,
|
filterTextureRect = QRect( area.x() + ( area.width() - rect.width()) / 2,
|
||||||
area.y() + ( area.height() - rect.height()) / 2, rect.width(), rect.height());
|
area.y() + ( area.height() - rect.height()) / 2, rect.width(), rect.height());
|
||||||
|
const int borderh = 10;
|
||||||
|
const int borderw = 20;
|
||||||
|
filterFrameRect = filterTextureRect.adjusted( -borderw, -borderh, borderw, borderh );
|
||||||
|
// Schedule repaint
|
||||||
effects->addRepaint( filterTextureRect );
|
effects->addRepaint( filterTextureRect );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,7 @@ class PresentWindowsEffect
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
GLTexture* filterTexture;
|
GLTexture* filterTexture;
|
||||||
QRect filterTextureRect;
|
QRect filterTextureRect;
|
||||||
|
QRect filterFrameRect;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ElectricBorder borderActivate;
|
ElectricBorder borderActivate;
|
||||||
|
|
Loading…
Reference in a new issue