[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Patch for the B2 style
From: Antonio Larrosa <larrosa () kde ! org>
Date: 2000-09-26 19:00:14
[Download RAW message or body]
Hi,
I've noticed that the B2 style sets a minimum width to each window. I don't
think the window manager should impose those restrictions to an application, so
I've made this patch that allows to resize it until a real minimum size (16
pixels instead of over 80).
To see the kind of problems this may cause, just open a 16x16 icon with xv,
it's impossible to do that with the current B2, while it works much better with
the patch.
I've implemented autohiding of buttons (which, btw, is a bit tricky, as it
doesn't use a real layout, because of efficiency I suppose).
Anybody objects to commit this ?
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/26 18:42:58
@@ -302,10 +302,16 @@
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);
+ int x=client->button[B2Client::BtnMenu]->x()
+ + (!client->button[B2Client::BtnMenu]->isHidden() ? 17 : 0)
+ + (!client->button[B2Client::BtnSticky]->isHidden() ? 17 : 0)
+ + (client->providesContextHelp() ? 17 : 0);
+ t.setX(x);
+ x = width()
+ - (!client->button[B2Client::BtnClose]->isHidden() ? 17 : 0)
+ - (!client->button[B2Client::BtnMax]->isHidden() ? 17 : 0)
+ - (!client->button[B2Client::BtnIconify]->isHidden() ? 17 : 0);
+ t.setRight(x);
p.drawText(t, AlignLeft | AlignVCenter, client->caption());
p.end();
@@ -344,10 +350,16 @@
p.setPen(options->color(Options::Font, false));
p.setFont(options->font(false));
- t.setX(client->providesContextHelp() ?
- client->button[B2Client::BtnHelp]->x()+17 :
- client->button[B2Client::BtnSticky]->x()+17);
- t.setRight(client->button[B2Client::BtnIconify]->x()-1);
+ int x=client->button[B2Client::BtnMenu]->x()
+ + (!client->button[B2Client::BtnMenu]->isHidden() ? 17 : 0)
+ + (!client->button[B2Client::BtnSticky]->isHidden() ? 17 : 0)
+ + (client->providesContextHelp() ? 17 : 0);
+ t.setX(x);
+ x = width()
+ - (!client->button[B2Client::BtnClose]->isHidden() ? 17 : 0)
+ - (!client->button[B2Client::BtnMax]->isHidden() ? 17 : 0)
+ - (!client->button[B2Client::BtnIconify]->isHidden() ? 17 : 0);
+ t.setRight(x);
p.drawText(t, AlignLeft | AlignVCenter, client->caption());
}
}
@@ -408,7 +420,7 @@
g->addColSpacing(0, 4);
- g->addColSpacing(1, providesContextHelp() ? 102 : 85);
+ g->addColSpacing(1, 16);
g->setColStretch(2, 1);
@@ -420,6 +432,8 @@
g->addRowSpacing(0, 20);
titlebar = new B2Titlebar(this);
+ titlebar->setMinimumWidth(16);
+ titlebar->setFixedHeight(20);
int i;
for(i=0; i < 6; ++i){
button[i] = new B2Button(this, titlebar/*this*/);
@@ -472,6 +486,54 @@
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;
+ }
+
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 */
@@ -900,26 +962,49 @@
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;
+ int btnWidth = 0;
+ if ( !button[BtnMenu]->isHidden() )
+ {
+ button[BtnMenu]->move(xpos, 2);
+ xpos+=17; btnWidth+=17;
+ }
+ if ( !button[BtnSticky]->isHidden() )
+ {
+ button[BtnSticky]->move(xpos, 2);
+ xpos+=17; btnWidth+=17;
+ }
if(providesContextHelp()){
- button[BtnHelp]->move(xpos, 2);
- xpos+=17;
+ button[BtnHelp]->move(xpos, 2);
+ xpos+=17; btnWidth+=17;
}
+
- if(xpos + textLen+52 < width()-3)
+ int rButtonsWidth= 1 + (!button[BtnIconify]->isHidden() ? 17 : 0 )
+ + (!button[BtnMax]->isHidden() ? 17 : 0 )
+ + (!button[BtnClose]->isHidden() ? 17 : 0 );
+
+ if(xpos + textLen+rButtonsWidth < width()-3)
xpos += textLen+1;
else
- xpos = width()-3-52;
+ xpos = width()-3-rButtonsWidth;
+
+ if ( !button[BtnIconify]->isHidden() )
+ {
+ button[BtnIconify]->move(xpos, 2);
+ xpos+=17; btnWidth+=17;
+ }
+ if ( !button[BtnMax]->isHidden() )
+ {
+ button[BtnMax]->move(xpos, 2);
+ xpos+=17; btnWidth+=17;
+ }
+ if ( !button[BtnClose]->isHidden() )
+ {
+ button[BtnClose]->move(xpos, 2);
+ xpos+=17; btnWidth+=17;
+ }
- 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(xpos+4,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