[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: [PATCH] semi transparent rubberband
From: aviv bergman <aviv_brg () yahoo ! com>
Date: 2004-02-08 11:21:57
Message-ID: 200402081321.57358.aviv_brg () yahoo ! com
[Download RAW message or body]
hi
i like the gnome/xp semi-transparent rubberband better then the XOR one, so i
added this to kde.
the patch have 4 parts:
qiconview.diff: patch for qt's iconview - since it's coded specificly for XOR
style rubberbad, i had to change that to a double-buffer (the double-buffer
is active only while the rubberband is active). the patch also disables the
focus rect drawing.
kstyle.diff: the actuall rubberband. color is taken from the text highlight
background.
kiconview.diff/kfileividesktop.diff: add round rect background to the text of
selected icons (i think it looks better this way) in konqueror/kdesktop
aviv
(patches are against qt 3.3.0/kde 3.2rc1)
["qiconview.diff" (text/x-diff)]
--- qt/src/iconview/qiconview.cpp 2004-02-07 22:31:30.000000000 +0200
+++ qt/src/iconview/qiconview.cpp 2004-02-07 23:45:59.000000000 +0200
@@ -261,6 +261,7 @@
QIconViewToolTip *toolTip;
QPixmapCache maskCache;
+ QPixmap *backrubber;
QPtrDict<QIconViewItem> selectedItems;
struct ItemContainer {
@@ -2062,6 +2063,7 @@
void QIconViewItem::paintFocus( QPainter *p, const QColorGroup &cg )
{
+ return;
if ( !view )
return;
@@ -2778,6 +2780,7 @@
d->renamingItem = 0;
d->drawActiveSelection = TRUE;
d->drawDragShapes = FALSE;
+ d->backrubber = NULL;
connect( d->adjustTimer, SIGNAL( timeout() ),
this, SLOT( adjustItems() ) );
@@ -3324,30 +3327,28 @@
viewport()->setUpdatesEnabled( TRUE );
blockSignals( block );
- QRect r = *d->rubber;
- *d->rubber = oldRubber;
+ ensureVisible( pos.x(), pos.y() );
- QPainter p;
- p.begin( viewport() );
- p.setRasterOp( NotROP );
- p.setPen( QPen( color0, 1 ) );
- p.setBrush( NoBrush );
- drawRubber( &p );
+ QRect all_r = oldRubber.normalize();
+ if ( changed )
+ all_r |= rr;
+ all_r |= *d->rubber;
+ QPoint p1 = contentsToViewport(all_r.topLeft());
+ all_r = QRect(p1.x(),p1.y(),all_r.width(),all_r.height());
+ all_r &= viewport()->rect();
+ all_r.addCoords(-2,-2,2,2);
d->dragging = FALSE;
- p.end();
-
- *d->rubber = r;
- if ( changed ) {
- d->drawAllBack = FALSE;
- d->clipRegion = region;
- repaintContents( rr, FALSE );
- d->drawAllBack = TRUE;
+ if (d->backrubber == 0) {
+ d->backrubber = new QPixmap(viewport()->rect().size());
+ d->backrubber->fill(viewport(),viewport()->rect().topLeft());
}
+ QPainter p(d->backrubber);
+ p.save();
+ p.translate(-contentsX(),-contentsY());
+ drawContents(&p, contentsX()+all_r.left(), contentsY()+all_r.top(),all_r.width(), \
all_r.height() ); + p.restore();
- ensureVisible( pos.x(), pos.y() );
-
- p.begin( viewport() );
p.setRasterOp( NotROP );
p.setPen( QPen( color0, 1 ) );
p.setBrush( NoBrush );
@@ -3353,9 +3354,10 @@
p.setBrush( NoBrush );
drawRubber( &p );
d->dragging = TRUE;
-
p.end();
+ bitBlt( viewport(), all_r.topLeft(), d->backrubber, all_r );
+
if ( changed ) {
emit selectionChanged();
if ( d->selectionMode == Single )
@@ -3386,8 +3388,6 @@
void QIconView::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
{
- if ( d->dragging && d->rubber )
- drawRubber( p );
QRect r = QRect( cx, cy, cw, ch );
@@ -3461,9 +3461,6 @@
d->currentItem->rect().intersects( r ) ) {
d->currentItem->paintFocus( p, colorGroup() );
}
-
- if ( d->dragging && d->rubber )
- drawRubber( p );
}
/*!
@@ -4364,15 +4361,13 @@
if ( d->rubber ) {
QPainter p;
p.begin( viewport() );
- p.setRasterOp( NotROP );
- p.setPen( QPen( color0, 1 ) );
- p.setBrush( NoBrush );
-
- drawRubber( &p );
+ repaintContents(d->rubber->normalize(),FALSE);
d->dragging = FALSE;
p.end();
delete d->rubber;
d->rubber = 0;
+ delete d->backrubber;
+ d->backrubber = 0;
if ( d->scrollTimer ) {
disconnect( d->scrollTimer, SIGNAL( timeout() ), this, SLOT( doAutoScroll() ) \
); @@ -4559,11 +4554,7 @@
if ( d->rubber ) {
QPainter p;
p.begin( viewport() );
- p.setRasterOp( NotROP );
- p.setPen( QPen( color0, 1 ) );
- p.setBrush( NoBrush );
-
- drawRubber( &p );
+ repaintContents(d->rubber->normalize(),FALSE);
d->dragging = FALSE;
p.end();
@@ -4572,6 +4563,8 @@
emitClicked = FALSE;
delete d->rubber;
d->rubber = 0;
+ delete d->backrubber;
+ d->backrubber = 0;
d->currentItem = d->tmpCurrentItem;
d->tmpCurrentItem = 0;
if ( d->currentItem )
["kfileividesktop.diff" (text/x-diff)]
--- kdebase/kdesktop/kfileividesktop.cpp 2004-02-07 23:55:58.000000000 +0200
+++ kdebase/kdesktop/kfileividesktop.cpp 2004-02-08 00:06:39.000000000 +0200
@@ -81,6 +81,11 @@
// draw the pixmap as in KIconViewItem::paintItem(...)
paintPixmap(p, colors);
+ if (isSelected()) {
+ p->setBrush(QBrush(cg.highlight()));
+ p->setPen(QPen(cg.highlight()));
+ p->drawRoundRect( textRect( false ) ,1000/textRect(false).width(),1000/textRect(false).height() );
+ }
//
// Paint the text as shadowed if the shadow is available
//
["kstyle.diff" (text/x-diff)]
--- kdelibs/kdefx/kstyle.cpp 2004-02-07 23:53:39.000000000 +0200
+++ kdelibs/kdefx/kstyle.cpp 2004-02-07 23:59:18.000000000 +0200
@@ -550,7 +550,24 @@
else
// General handle, probably a kicker applet handle.
drawKStylePrimitive( KPE_GeneralHandle, p, widget, r, cg, flags, opt );
+#ifdef HAVE_XRENDER
+ } else if (pe == PE_RubberBand) {
+
+ XRenderColor clr = \
{cg.highlight().red()*255,cg.highlight().green()*255,cg.highlight().blue()*255,0x7000};
+ QRect r2 = r.normalize();
+ QPoint zp(0,0);
+ zp = p->xForm(zp);
+ XRenderFillRectangle(p->device()->x11Display(),PictOpOver,p->device()->x11RenderHandle(),
+ &clr,r2.x()+zp.x(),r2.y()+zp.y(),r2.width(),r2.height());
+
+ r2.addCoords(1,1,0,0);
+ p->setRasterOp(Qt::CopyROP);
+ p->setPen(QPen(cg.highlight(),2));
+ p->setBrush(NoBrush);
+ p->drawRect(r2);
+
+#endif
} else
QCommonStyle::drawPrimitive( pe, p, r, cg, flags, opt );
}
["kiconview.diff" (text/x-diff)]
--- kdelibs/kdeui/kiconview.cpp 2004-02-07 23:54:35.000000000 +0200
+++ kdelibs/kdeui/kiconview.cpp 2004-02-08 00:04:17.000000000 +0200
@@ -593,7 +593,9 @@
int textY = textRect( false ).y();
if ( isSelected() ) {
- p->fillRect( textRect( false ), cg.highlight() );
+ p->setBrush(QBrush(cg.highlight()));
+ p->setPen(QPen(cg.highlight()));
+ p->drawRoundRect( textRect( false ) ,1000/textRect(false).width(),1000/textRect(false).height() );
p->setPen( QPen( cg.highlightedText() ) );
} else {
if ( iconView()->itemTextBackground() != NoBrush )
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic