[Kstars-devel] KDE/kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Mon Aug 18 04:07:19 CEST 2008


SVN commit 848533 by harris:

Committing patch from Mederic Boquien.  Use alpha transparency in InfoBoxes
instead of a bitmap pattern.  Also, use transparency to fade transient labels,
instead of fading them to the background color.

We should probably use transparency to fade planet trails as well.

Thanks a lot for the patch, Mederic!  Sorry for misspelling your name; my SVN 
editor freaked out at non-ascii characters :(

CCMAIL: kstars-devel at kde.org



 M  +5 -1      infobox.cpp  
 M  +7 -14     skymap.cpp  
 M  +2 -1      skyobject.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/infobox.cpp #848532:848533
@@ -150,7 +150,11 @@
     constrain( QRect( 0, 0, p.window().width(), p.window().height() ) );
 
     //Draw the box boundary and the text
-    if ( bgMode==1 ) p.fillRect( x(), y(), width(), height(), QBrush( bgColor, Qt::Dense4Pattern ) );
+    if ( bgMode==1 ) {
+        QColor bgColorAlpha = bgColor;
+        bgColorAlpha.setAlpha(127);
+        p.fillRect( x(), y(), width(), height(), QBrush( bgColorAlpha ) );
+    }
     if ( bgMode==2 ) p.fillRect( x(), y(), width(), height(), QBrush( bgColor ) );
 
     p.drawText( x() + padx(), y() + ShadedTextHeight/2 + pady(), text1() );
--- trunk/KDE/kdeedu/kstars/kstars/skymap.cpp #848532:848533
@@ -107,7 +107,7 @@
     pmenu = new KSPopupMenu( ks );
 
     //Initialize Transient label stuff
-    TransientTimeout = 100; //fade label color every 0.2 sec
+    TransientTimeout = 100; //fade label color every 0.1 sec
     HoverTimer.setSingleShot( true ); // using this timer as a single shot timer
 
     connect( &HoverTimer, SIGNAL( timeout() ), this, SLOT( slotTransientLabel() ) );
@@ -223,24 +223,17 @@
         return;
     }
 
-    //to fade the labels, we will need to smoothly transition from UserLabelColor to SkyColor.
-    QColor c1 = data->colorScheme()->colorNamed( "UserLabelColor" );
-    QColor c2 = data->colorScheme()->colorNamed( "SkyColor" );
+    //to fade the labels, we will need to smoothly transition the alpha
+    //channel from opaque (255) to transparent (0) by step of stepAlpha
+    static const int stepAlpha = 12;
 
-    int dRed =   ( c2.red()   - c1.red()   )/20;
-    int dGreen = ( c2.green() - c1.green() )/20;
-    int dBlue =  ( c2.blue()  - c1.blue()  )/20;
-    int newRed   = TransientColor.red()   + dRed;
-    int newGreen = TransientColor.green() + dGreen;
-    int newBlue  = TransientColor.blue()  + dBlue;
-
-    //Check to see if we have arrived at the target color (SkyColor).
+    //Check to see if next step produces a transparent label
     //If so, point TransientObject to NULL.
-    if ( abs(newRed-c2.red()) < abs(dRed) || abs(newGreen-c2.green()) < abs(dGreen) || abs(newBlue-c2.blue()) < abs(dBlue) ) {
+    if ( TransientColor.alpha() <= stepAlpha ) {
         setTransientObject( NULL );
         TransientTimer.stop();
     } else {
-        TransientColor.setRgb( newRed, newGreen, newBlue );
+        TransientColor.setAlpha(TransientColor.alpha()-stepAlpha);
     }
 
     update();
--- trunk/KDE/kdeedu/kstars/kstars/skyobject.cpp #848532:848533
@@ -481,7 +481,8 @@
 
     //FIXME: Implement label background options
     QColor color( KStarsData::Instance()->colorScheme()->colorNamed( "SkyColor" ) );
-    psky.fillRect( rect2, QBrush( color, Qt::Dense4Pattern ) );
+    color.setAlpha( psky.pen().color().alpha() ); //same transparency for the text and the background
+    psky.fillRect( rect2, QBrush( color ) );
     psky.drawText( rect.topLeft(), sLabel );
 }
 


More information about the Kstars-devel mailing list