[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/lib/kofficeui
From:       Ariya Hidayat <ariya () kde ! org>
Date:       2005-11-10 18:21:04
Message-ID: 1131646864.929684.20843.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 479494 by ariya:

GUI
new look of the tabbar
for screenshot: http://ariya.blogspot.com/2005/10/asymmetrical-tabs.html



 M  +38 -21    kotabbar.cpp  


--- trunk/koffice/lib/kofficeui/kotabbar.cpp #479493:479494
@@ -199,7 +199,7 @@
                 QString text = tabs[ c ];
                 int tw = fm.width( text ) + 4;
                 rect = QRect( x, 0, tw + 20, tabbar->height() );
-                x = x + tw + 10;
+                x = x + tw + 20;
             }
             tabRects.append( rect );
         }
@@ -224,7 +224,7 @@
                 QString text = tabs[ c ];
                 int tw = fm.width( text ) + 4;
                 rect = QRect( x - tw - 20, 0, tw + 20, tabbar->height() );
-                x = x - tw - 10;
+                x = x - tw - 20;
             }
             tabRects.append( rect );
         }
@@ -253,26 +253,40 @@
 
 void KoTabBarPrivate::drawTab( QPainter& painter, QRect& rect, const QString& text, bool active )
 {
-    QPointArray pa;
-    pa.setPoints( 4, rect.x(), rect.y(), rect.x()+10, rect.bottom()-1,
-      rect.right()-10, rect.bottom()-1, rect.right(), rect.top() );
+    QPointArray polygon;
+    
+    if( !reverseLayout )
+        polygon.setPoints( 6, rect.x(), rect.y(),
+            rect.x(), rect.bottom()-3,
+            rect.x()+2, rect.bottom(),
+            rect.right()-4, rect.bottom(),
+            rect.right()-2, rect.bottom()-2,
+            rect.right()+5, rect.top() );
+    else      
+        polygon.setPoints( 6, rect.right(), rect.top(),
+            rect.right(), rect.bottom()-3,
+            rect.right()-2, rect.bottom(),
+            rect.x()+4, rect.bottom(),
+            rect.x()+2, rect.bottom()-2,
+            rect.x()-5, rect.top() );
 
-    QColor bgcolor = tabbar->colorGroup().background();
-    if( active ) bgcolor = tabbar->colorGroup().base();
+    painter.save();
 
-    painter.setClipping( true );
-    painter.setClipRegion( QRegion( pa ) );
-    painter.setBackgroundColor( bgcolor );
-    painter.eraseRect( rect );
-    painter.setClipping( false );
+    // fill it first  
+    QBrush bg = tabbar->colorGroup().background();
+    if( active ) bg = tabbar->colorGroup().base();
+    painter.setBrush( bg );
+    painter.setPen( QPen( Qt::NoPen ) );
+    painter.drawPolygon( polygon );
 
-    painter.drawLine( rect.x(), rect.y(), rect.x()+10, rect.bottom()-1 );
-    painter.drawLine( rect.x()+10, rect.bottom()-1, rect.right()-10, rect.bottom()-1 );
-    painter.drawLine( rect.right()-10, rect.bottom()-1, rect.right(), rect.top() );
+    // draw the lines
+    painter.setPen( tabbar->colorGroup().dark() );
     if( !active )
-      painter.drawLine( rect.x(), rect.y(), rect.right(), rect.y() );
+      painter.drawLine( rect.x()-25, rect.y(), rect.right()+25, rect.top() );
+    // Qt4: painter.setRenderHint( QPainter::Antialiasing );
+    painter.drawPolyline( polygon );
 
-    painter.save();
+    painter.setPen( tabbar->colorGroup().buttonText() );
     QFont f = painter.font();
     if( active ) f.setBold( true );
     painter.setFont( f );
@@ -280,6 +294,7 @@
     int tx =  rect.x() + ( rect.width() - fm.width( text ) ) / 2;
     int ty =  rect.y() + ( rect.height() - fm.height() ) / 2 + fm.ascent();
     painter.drawText( tx, ty, text );
+
     painter.restore();
 }
 
@@ -648,15 +663,17 @@
     pm.fill( colorGroup().background() );
     painter.begin( &pm, this );
 
-    QBrush fill( colorGroup().brush( QColorGroup::Background ) );
-    qDrawShadePanel( &painter, 0, 0, width(),
-                     height(), colorGroup(), FALSE, 1, &fill );
+    painter.setPen( colorGroup().dark() );
+    painter.drawLine( 0, 0, width(), 0 );
 
+    if( !d->reverseLayout )
+        painter.translate( 5, 0 );
+
     d->layoutTabs();
     d->updateButtons();
     
     // draw first all non-active, visible tabs
-    for( unsigned c = 0; c < d->tabRects.count(); c++ )
+    for( int c = d->tabRects.count()-1; c>=0; c-- )
     {
         QRect rect = d->tabRects[ c ];
         if( rect.isNull() ) continue;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic