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

List:       kde-core-devel
Subject:    Re: Patch for the B2 style
From:       Antonio Larrosa <antlarr () arrakis ! es>
Date:       2000-09-28 17:03:27
[Download RAW message or body]

mosfet wrote:
> 
> 
> You may want to check out the default style, as I did a much simpler way
> to do the same thing there.

Ok, I thought using a layout was a no-no. It's much better this way.

What do you think ? (I'm not sure if the right border in the titlebar is ok,
I think it's too thin, so please test it)

Greetings,

--
Antonio Larrosa Jimenez
KDE Core developer
antonio@larrosa.org        larrosa@kde.org
http://www.larrosa.org
KDE - The development framework of the future, today.
["b2.diff" (text/plain)]

Index: b2client.cpp
===================================================================
RCS file: /home/kde/kdebase/kwin/clients/b2/b2client.cpp,v
retrieving revision 1.10
diff -u -r1.10 b2client.cpp
--- b2client.cpp	2000/09/25 15:30:50	1.10
+++ b2client.cpp	2000/09/28 17:02:26
@@ -302,10 +302,12 @@
     p.setPen(options->color(Options::Font, true));
     p.setFont(options->font(true));
 
-    t.setX(client->providesContextHelp() ?
-           client->button[B2Client::BtnHelp]->x()+17 :
-           client->button[B2Client::BtnSticky]->x()+17);
-    t.setRight(client->button[B2Client::BtnIconify]->x()-1);
+    QLayoutIterator it=layout()->iterator();
+    ++it;
+    ++it;
+    ++it;
+    t=(++it)->geometry();
+
     p.drawText(t, AlignLeft | AlignVCenter, client->caption());
     p.end();
 
@@ -343,11 +345,13 @@
         // and the caption
         p.setPen(options->color(Options::Font, false));
         p.setFont(options->font(false));
+
+	QLayoutIterator it=layout()->iterator();
+	++it;
+	++it;
+	++it;
+	t=(++it)->geometry();
 
-        t.setX(client->providesContextHelp() ?
-               client->button[B2Client::BtnHelp]->x()+17 :
-               client->button[B2Client::BtnSticky]->x()+17);
-        t.setRight(client->button[B2Client::BtnIconify]->x()-1);
         p.drawText(t, AlignLeft | AlignVCenter, client->caption());
     }
 }
@@ -408,7 +412,7 @@
 
     g->addColSpacing(0, 4);
 
-    g->addColSpacing(1, providesContextHelp() ? 102 : 85);
+    g->addColSpacing(1, 16);
 
     g->setColStretch(2, 1);
 
@@ -420,18 +424,34 @@
     g->addRowSpacing(0, 20);
 
     titlebar = new B2Titlebar(this);
-    int i;
+    titlebar->setMinimumWidth(16);
+    titlebar->setFixedHeight(20);
+
+   int i;
     for(i=0; i < 6; ++i){
         button[i] = new B2Button(this, titlebar/*this*/);
         button[i]->setFixedSize(16, 16);
     }
-
+    
+    QHBoxLayout *titleLayout=new QHBoxLayout(titlebar);
+    titleLayout->setSpacing(1);
+   
+    titleLayout->addSpacing(3);
+    titleLayout->addWidget(button[BtnMenu]);
+    titleLayout->addWidget(button[BtnSticky]);
+    titleLayout->addWidget(button[BtnHelp]);
+    titleLayout->addStretch(1);
+    titleLayout->addWidget(button[BtnIconify]);
+    titleLayout->addWidget(button[BtnMax]);
+    titleLayout->addWidget(button[BtnClose]);
+    titleLayout->addSpacing(3);
+ 
     button[BtnSticky]->setToggle();
     button[BtnSticky]->setDown(isSticky());
     button[BtnMenu]->setUseMiniIcon();
 
     if(!providesContextHelp())
-        button[5]->hide();
+        button[BtnHelp]->hide();
 
     button[BtnMenu]->setPixmaps(aMenuPix, aMenuPixDown, iMenuPix,
                                 iMenuPixDown);
@@ -472,11 +492,62 @@
 void B2Client::resizeEvent( QResizeEvent* e)
 {
     Client::resizeEvent( e );
+  
+    int sizeProblem = 0;
+
+    if (width() < 45) sizeProblem = 3;
+    else if (width() < 70) sizeProblem = 2;
+    else if (width() < 120) sizeProblem = 1;
+ 
+    switch (sizeProblem) {
+ 
+      case 1:
+        button[BtnMenu]    ->show();
+        button[BtnClose]   ->show();
+        button[BtnSticky]  ->hide();
+	button[BtnIconify] ->show();
+	button[BtnMax] 	   ->hide();
+	button[BtnHelp]    ->hide();
+	break;
+
+      case 2:
+        button[BtnMenu]    ->show();
+	button[BtnClose]   ->show();
+        button[BtnSticky]  ->hide();
+	button[BtnIconify] ->hide();
+	button[BtnMax] 	   ->hide();
+	button[BtnHelp]    ->hide();
+	break;
+
+      case 3:
+        button[BtnMenu]    ->hide();
+	button[BtnClose]   ->hide();
+        button[BtnSticky]  ->hide();
+	button[BtnIconify] ->hide();
+	button[BtnMax] 	   ->hide();
+	button[BtnHelp]    ->hide();
+	break;
+ 
+      case 0:
+      default:
+        button[BtnMenu]    ->show();
+	button[BtnClose]   ->show();
+        button[BtnSticky]  ->show();
+	button[BtnIconify] ->show();
+	button[BtnMax] 	   ->show();
+	if(providesContextHelp())
+	  button[BtnHelp]->show();
+	break;
+    }   
+
+    titlebar->layout()->activate();
+
     positionButtons();
     /* may be the resize cuted off some space occupied by titlebar, which
        was moved, so instead of reducing it, we first try to move it */
     titleMoveAbs(bar_x_ofs);
     doShape();
+
     /*
     What does this? (MM)
     if ( isVisibleToTLW() && !testWFlags( WNorthWestGravity )) {
@@ -898,28 +969,16 @@
     QFontMetrics fm(options->font(isActive()));
 
     int textLen = fm.width(caption());
-    //int xpos = bar_x_ofs+4;
-    int xpos = 4;
-    button[BtnMenu]->move(xpos, 2);
-    xpos+=17;
-    button[BtnSticky]->move(xpos, 2);
-    xpos+=17;
-    if(providesContextHelp()){
-        button[BtnHelp]->move(xpos, 2);
-        xpos+=17;
-    }
+    QLayoutIterator it=titlebar->layout()->iterator();
+    ++it;
+    ++it;
+    ++it;
 
-    if(xpos + textLen+52 < width()-3)
-        xpos += textLen+1;
-    else
-        xpos = width()-3-52;
+    int titleWidth=titlebar->width()-(++it)->geometry().width()+textLen+2;
+   
+    if( titleWidth > width()) titleWidth=width();
 
-    button[BtnIconify]->move(xpos, 2);
-    xpos+=17;
-    button[BtnMax]->move(xpos, 2);
-    xpos+=17;
-    button[BtnClose]->move(xpos, 2);
-    titlebar->setFixedSize(xpos+17+4,20);
+    titlebar->resize(titleWidth,20);
     titlebar->move(bar_x_ofs, 0);
 }
 


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

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