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

List:       kde-commits
Subject:    branches/KDE/3.5/kdebase/kicker/libkicker
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2005-08-13 8:07:43
Message-ID: 1123920463.307447.19209.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 448821 by aseigo:

translating 2,2 is lame. shrink the icon and recenter it, this gives the
impression that it's receding. simple yet effective?


 M  +12 -8     panelbutton.cpp  
 M  +16 -10    simplebutton.cpp  
 M  +0 -1      simplebutton.h  


--- branches/KDE/3.5/kdebase/kicker/libkicker/panelbutton.cpp #448820:448821
@@ -536,12 +536,15 @@
 
 void PanelButton::drawButtonLabel(QPainter *p)
 {
-    if (isDown() || isOn())
+    QPixmap icon = labelIcon();
+    bool active = isDown() || isOn();
+
+    if (active)
     {
-        p->translate(2,2);
+        icon = icon.convertToImage().smoothScale(icon.width() - 2,
+                                                 icon.height() - 2);
     }
 
-    const QPixmap& icon = labelIcon();
     if (!m_buttonText.isEmpty() && orientation() == Horizontal)
     {
         int h = height();
@@ -549,6 +552,12 @@
         int y = (h - icon.height())/2;
         p->save();
         QFont f = font();
+
+        double fontPercent = m_fontPercent;
+        if (active)
+        {
+            fontPercent *= .8;
+        }
         f.setPixelSize(KMIN(h, KMAX(int(float(h) * m_fontPercent), 16)));
         QFontMetrics fm(f);
         p->setFont(f);
@@ -655,11 +664,6 @@
         }
         style().drawPrimitive(e, p, r, colorGroup(), flags);
     }
-
-    if (isDown() || isOn())
-    {
-        p->translate(-2,-2);
-    }
 }
 
 // return the icon size that would be used if the panel were proposed_size
--- branches/KDE/3.5/kdebase/kicker/libkicker/simplebutton.cpp #448820:448821
@@ -24,6 +24,7 @@
 
 #include <kapplication.h>
 #include <kcursor.h>
+#include <kdialog.h>
 #include <kglobalsettings.h>
 #include <kiconeffect.h>
 #include <kicontheme.h>
@@ -72,11 +73,11 @@
 
     if (m_orientation == Qt::Horizontal)
     {
-        return QSize(pm->width() + margin(), pm->height());
+        return QSize(pm->width() + KDialog::spacingHint(), pm->height());
     }
     else
     {
-        return QSize(pm->width(), pm->height() + margin());
+        return QSize(pm->width(), pm->height() + KDialog::spacingHint());
     }
 }
 
@@ -109,22 +110,27 @@
 
     QPixmap pix = m_highlight? m_activeIcon : m_normalIcon;
 
-    if ( isOn() || isDown() )
+    if (isOn() || isDown())
     {
-        p->translate( 2, 2 );
+        pix = pix.convertToImage().smoothScale(pix.width() - 2,
+                                               pix.height() - 2);;
     }
 
-    int point = margin() / 2;
-    QPoint origin(point, point);
+    int h = height();
+    int w = width();
+    int ph = pix.height();
+    int pw = pix.width();
+    int margin = KDialog::spacingHint();
+    QPoint origin(margin / 2, margin / 2);
 
-    if (pix.height() < (height() - margin()))
+    if (ph < (h - margin))
     {
-        origin.setY(origin.y() + ((height() - pix.height()) / 2));
+        origin.setY((h - ph) / 2);
     }
 
-    if (pix.width() < (width() - margin()))
+    if (pw < (w - margin))
     {
-        origin.setX(origin.x() + ((width() - pix.width()) / 2));
+        origin.setX((w - pw) / 2);
     }
 
     p->drawPixmap(origin, pix);
--- branches/KDE/3.5/kdebase/kicker/libkicker/simplebutton.h #448820:448821
@@ -39,7 +39,6 @@
     protected:
         void drawButton( QPainter *p );
         void drawButtonLabel( QPainter *p );
-        int margin() const { return 6; }
         void generateIcons();
 
         void enterEvent( QEvent *e );
[prev in list] [next in list] [prev in thread] [next in thread] 

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