Textures for buttons too. Necessary now that titlebar can be large

enough for you to see them. Oh yes, the titlebar now changes size
with your font size. See http://www.geoid.clara.net/silly.jpg for
a (silly) example of this. This is in fact an essential feature
IMO, for people who can't read titlebar text at the restricted
sizes that the other styles allow.

New funky iconify animation, but I haven't made it available via
a config key yet, so you can't use it :P

svn path=/trunk/kdebase/kwin/; revision=69021
icc-effect-5.14.5
Rik Hemsley 2000-10-27 02:16:14 +00:00
parent 8f36a1cb5c
commit abd2f3d6fd
6 changed files with 369 additions and 383 deletions

View File

@ -34,8 +34,8 @@ Button::Button(QWidget * parent)
active_ (false)
{
setBackgroundColor(Qt::black);
setFixedSize(19, 20);
connect(parent, SIGNAL(activeChanged(bool)), this, SLOT(setActive(bool)));
update();
}
Button::~Button()
@ -77,6 +77,15 @@ Button::mouseReleaseEvent(QMouseEvent *)
repaint();
}
void
Button::update()
{
setFixedSize(
Static::instance()->titleHeight() - 1,
Static::instance()->titleHeight()
);
}
void
Button::setPixmap(const QPixmap & p)
{
@ -128,10 +137,12 @@ Button::paintEvent(QPaintEvent *)
bitBlt(this, alignment_ == Left ? 1 : 0, 0,
&Static::instance()->buttonBase(active_, down_));
int i = width() / 2 - 6;
if (active_)
bitBlt(this, alignment_ == Left ? 4 : 3, 4, &aPixmap_);
bitBlt(this, alignment_ == Left ? i + 1 : i, i + 1, &aPixmap_);
else
bitBlt(this, alignment_ == Left ? 4 : 3, 4, &iPixmap_);
bitBlt(this, alignment_ == Left ? i + 1 : i, i + 1, &iPixmap_);
}
} // End namespace

View File

@ -44,6 +44,8 @@ class Button : public QWidget
Alignment alignment() const;
void update();
protected slots:
void setActive(bool);

View File

@ -22,11 +22,13 @@
#include <unistd.h> // for usleep
#include <config.h> // for usleep on non-linux platforms
#include <math.h> // for sin and cos
#include <qpainter.h>
#include <qimage.h>
#include <qlayout.h>
#include <kapp.h>
#include <netwm.h>
#include "../../options.h"
@ -106,8 +108,14 @@ Manager::Manager(
if (buttonDict_[*it])
titleLayout->addWidget(buttonDict_[*it]);
titleSpacer_ = new QSpacerItem(0, 20, QSizePolicy::Expanding,
QSizePolicy::Fixed);
titleSpacer_ =
new QSpacerItem(
0,
Static::instance()->titleHeight(),
QSizePolicy::Expanding,
QSizePolicy::Fixed
);
titleLayout->addItem(titleSpacer_);
for (it = rightButtons.begin(); it != rightButtons.end(); ++it)
@ -120,7 +128,7 @@ Manager::Manager(
midLayout->addWidget(windowWrapper());
midLayout->addSpacing(1);
l->addSpacing(10);
l->addSpacing(Static::instance()->resizeHeight());
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
}
@ -157,36 +165,42 @@ Manager::paintEvent(QPaintEvent * e)
bool active = isActive();
QRect tr = titleSpacer_->geometry();
// Title bar.
p.drawPixmap(tr.left(), 0, s->titleTextLeft(active));
p.drawTiledPixmap(tr.left() + 3, 0, tr.width() - 6, 20, s->titleTextMid(active));
p.setPen(options->color(Options::Font, active));
p.setFont(options->font(true)); // XXX false doesn't work right at the moment
p.drawText(tr.left() + 4, 0, tr.width() - 8, 18, AlignCenter, caption());
p.drawPixmap(tr.right() - 2, 0, s->titleTextRight(active));
QRect tr = titleSpacer_->geometry();
bitBlt(this, tr.topLeft(), &titleBuf_);
// Resize bar.
int rbt = height() - 10; // Resize bar top.
int rbt = height() - Static::instance()->resizeHeight(); // Resize bar top.
p.drawPixmap(0, rbt, s->resize(active));
bitBlt(this, 0, rbt, &(s->resize(active)));
bitBlt(this, 30, rbt, &(s->resizeMidLeft(active)));
p.drawPixmap(30, rbt, s->resizeMidLeft(active));
p.drawTiledPixmap(32, rbt, width() - 34, 10, s->resizeMidMid(active));
p.drawPixmap(width() - 32, rbt, s->resizeMidRight(active));
p.drawTiledPixmap(
32,
rbt,
width() - 34,
Static::instance()->resizeHeight(),
s->resizeMidMid(active)
);
p.drawPixmap(width() - 30, rbt, s->resize(active));
bitBlt(this, width() - 32, rbt, &(s->resizeMidRight(active)));
bitBlt(this, width() - 30, rbt, &(s->resize(active)));
}
void
Manager::resizeEvent(QResizeEvent * e)
{
Client::resizeEvent(e);
updateButtonVisibility();
updateTitleBuffer();
repaint();
}
void
Manager::updateButtonVisibility()
{
int sizeProblem = 0;
if (width() < 80) sizeProblem = 3;
@ -233,8 +247,44 @@ Manager::resizeEvent(QResizeEvent * e)
close_ ->show();
break;
}
}
repaint();
void
Manager::updateTitleBuffer()
{
bool active = isActive();
Static * s = Static::instance();
QRect tr = titleSpacer_->geometry();
titleBuf_.resize(tr.size());
QPainter p(&titleBuf_);
p.drawPixmap(0, 0, s->titleTextLeft(active));
p.drawTiledPixmap(
3,
0,
tr.width() - 6,
Static::instance()->titleHeight(),
s->titleTextMid(active)
);
p.setPen(options->color(Options::Font, active));
p.setFont(options->font(true)); // XXX false doesn't work right at the moment
p.drawText(
4,
2,
tr.width() - 8,
Static::instance()->titleHeight() - 4,
AlignCenter, caption()
);
p.drawPixmap(tr.width() - 3, 0, s->titleTextRight(active));
}
Client::MousePosition
@ -242,7 +292,7 @@ Manager::mousePosition(const QPoint & p) const
{
MousePosition m = Center;
if (p.y() > (height() - 10)) {
if (p.y() > (height() - Static::instance()->resizeHeight())) {
// Keep order !
if (p.x() >= (width() - 30))
m = BottomRight;
@ -267,6 +317,8 @@ Manager::mouseDoubleClickEvent(QMouseEvent * e)
void
Manager::slotReset()
{
for (QDictIterator<Button> it(buttonDict_); it.current(); ++it)
it.current()->update();
Static::instance()->update();
repaint();
}
@ -274,20 +326,21 @@ Manager::slotReset()
void
Manager::captionChange(const QString &)
{
updateTitleBuffer();
repaint();
}
void
Manager::paletteChange(const QPalette &)
{
Static::instance()->update();
repaint();
slotReset();
}
void
Manager::activeChange(bool b)
{
emit(activeChanged(b));
updateTitleBuffer();
repaint();
}
@ -336,43 +389,146 @@ Manager::slotHelp()
void
Manager::animateIconifyOrDeiconify(bool iconify)
{
NETRect r = netWinInfo()->iconGeometry();
animate(iconify, Static::instance()->animationStyle());
}
QRect icongeom(r.pos.x, r.pos.y, r.size.width, r.size.height);
void Manager::animate(bool iconify, int style)
{
switch (style) {
if (!icongeom.isValid())
return;
case 1:
{
// Double twisting double back, with pike ;)
QRect wingeom(x(), y(), width(), height());
if (!iconify) // No animation for restore.
return;
XGrabServer(qt_xdisplay());
// Go away quick.
hide();
qApp->syncX();
QPainter p(workspace()->desktopWidget());
NETRect r = netWinInfo()->iconGeometry();
p.setRasterOp(Qt::NotROP);
if (!QRect(r.pos.x, r.pos.y, r.size.width, r.size.height).isValid())
return;
if (iconify)
p.setClipRegion(QRegion(workspace()->desktopWidget()->rect()) - wingeom);
// Algorithm taken from Window Maker (http://www.windowmaker.org)
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
p.drawLine(wingeom.topRight(), icongeom.topRight());
int sx = x();
int sy = y();
int sw = width();
int sh = height();
int dx = r.pos.x;
int dy = r.pos.y;
int dw = r.size.width;
int dh = r.size.height;
p.flush();
double steps = 12;
XSync( qt_xdisplay(), FALSE );
double xstep = double((dx-sx)/steps);
double ystep = double((dy-sy)/steps);
double wstep = double((dw-sw)/steps);
double hstep = double((dh-sh)/steps);
usleep(30000);
double cx = sx;
double cy = sy;
double cw = sw;
double ch = sh;
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
p.drawLine(wingeom.topRight(), icongeom.topRight());
double finalAngle = 3.14159265358979323846;
p.end();
double delta = finalAngle / steps;
XUngrabServer( qt_xdisplay() );
QPainter p(workspace()->desktopWidget());
p.setRasterOp(Qt::NotROP);
for (double angle = 0; ; angle += delta) {
if (angle > finalAngle)
angle = finalAngle;
double dx = (cw / 10) - ((cw / 5) * sin(angle));
double dch = (ch / 2) * cos(angle);
double midy = cy + (ch / 2);
QPoint p1(cx + dx, midy - dch);
QPoint p2(cx + cw - dx, p1.y());
QPoint p3(cx + dw + dx, midy + dch);
QPoint p4(cx - dx, p3.y());
XGrabServer(qt_xdisplay());
p.drawLine(p1, p2);
p.drawLine(p2, p3);
p.drawLine(p3, p4);
p.drawLine(p4, p1);
p.flush();
usleep(500);
p.drawLine(p1, p2);
p.drawLine(p2, p3);
p.drawLine(p3, p4);
p.drawLine(p4, p1);
XUngrabServer(qt_xdisplay());
kapp->processEvents();
cx += xstep;
cy += ystep;
cw += wstep;
ch += hstep;
if (angle >= finalAngle)
break;
}
}
break;
default:
{
NETRect r = netWinInfo()->iconGeometry();
QRect icongeom(r.pos.x, r.pos.y, r.size.width, r.size.height);
if (!icongeom.isValid())
return;
QRect wingeom(x(), y(), width(), height());
QPainter p(workspace()->desktopWidget());
p.setRasterOp(Qt::NotROP);
if (iconify)
p.setClipRegion(
QRegion(workspace()->desktopWidget()->rect()) - wingeom
);
XGrabServer(qt_xdisplay());
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
p.drawLine(wingeom.topRight(), icongeom.topRight());
p.flush();
qApp->syncX();
usleep(30000);
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
p.drawLine(wingeom.topRight(), icongeom.topRight());
XUngrabServer(qt_xdisplay());
}
break;
}
}
@ -382,231 +538,14 @@ ToolManager::ToolManager(
QWidget * parent,
const char * name
)
: Client(workSpace, id, parent, name)
: Manager(workSpace, id, parent, name)
{
setBackgroundMode(NoBackground);
QStringList leftButtons = Static::instance()->leftButtons();
QStringList rightButtons = Static::instance()->rightButtons();
QVBoxLayout * l = new QVBoxLayout(this, 0, 0);
close_ = new CloseButton (this);
help_ = new HelpButton (this);
buttonDict_.insert("Close", close_);
buttonDict_.insert("Help", help_);
if (!providesContextHelp())
help_->hide();
QStringList::ConstIterator it;
for (it = leftButtons.begin(); it != leftButtons.end(); ++it)
if (buttonDict_[*it])
buttonDict_[*it]->setAlignment(Button::Left);
for (it = rightButtons.begin(); it != rightButtons.end(); ++it)
if (buttonDict_[*it])
buttonDict_[*it]->setAlignment(Button::Left);
QHBoxLayout * titleLayout = new QHBoxLayout(l);
for (it = leftButtons.begin(); it != leftButtons.end(); ++it)
if (buttonDict_[*it])
titleLayout->addWidget(buttonDict_[*it]);
titleSpacer_ = new QSpacerItem(0, 20);
titleLayout->addItem(titleSpacer_);
for (it = rightButtons.begin(); it != rightButtons.end(); ++it)
if (buttonDict_[*it])
titleLayout->addWidget(buttonDict_[*it]);
QHBoxLayout * midLayout = new QHBoxLayout(l);
midLayout->addSpacing(1);
midLayout->addWidget(windowWrapper());
midLayout->addSpacing(1);
l->addSpacing(10);
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
}
ToolManager::~ToolManager()
{
}
void
ToolManager::paintEvent(QPaintEvent * e)
{
QPainter p(this);
QRect r(e->rect());
bool intersectsLeft =
r.intersects(QRect(0, 0, 1, height()));
bool intersectsRight =
r.intersects(QRect(width() - 1, 0, width(), height()));
if (intersectsLeft || intersectsRight) {
p.setPen(Qt::black);
if (intersectsLeft)
p.drawLine(0, r.top(), 0, r.bottom());
if (intersectsRight)
p.drawLine(width() - 1, r.top(), width() - 1, r.bottom());
}
Static * s = Static::instance();
bool active = isActive();
QRect tr = titleSpacer_->geometry();
// Title bar.
p.drawPixmap(tr.left(), 0, s->titleTextLeft(active));
p.drawTiledPixmap(tr.left() + 3, 0, tr.width() - 6, 20, s->titleTextMid(active));
p.setPen(options->color(Options::Font, active));
p.setFont(options->font(active));
p.drawText(tr.left() + 4, 0, tr.width() - 8, 18, AlignCenter, caption());
p.drawPixmap(tr.right() - 2, 0, s->titleTextRight(active));
// Resize bar.
int rbt = height() - 10; // Resize bar top.
p.drawPixmap(0, rbt, s->resize(active));
p.drawPixmap(30, rbt, s->resizeMidLeft(active));
p.drawTiledPixmap(32, rbt, width() - 34, 10, s->resizeMidMid(active));
p.drawPixmap(width() - 32, rbt, s->resizeMidRight(active));
p.drawPixmap(width() - 30, rbt, s->resize(active));
}
void
ToolManager::resizeEvent(QResizeEvent *)
{
if (width() < 80) {
help_ ->hide();
close_ ->hide();
} else {
if (providesContextHelp())
help_ ->show();
close_ ->show();
}
repaint();
}
Client::MousePosition
ToolManager::mousePosition(const QPoint & p) const
{
MousePosition m = Center;
if (p.y() > (height() - 10)) {
// Keep order !
if (p.x() >= (width() - 30))
m = BottomRight;
else if (p.x() <= 30)
m = BottomLeft;
else
m = Bottom;
}
return m;
}
void
ToolManager::mouseDoubleClickEvent(QMouseEvent * e)
{
if (titleSpacer_->geometry().contains(e->pos()))
workspace()
->performWindowOperation(this, options->operationTitlebarDblClick());
workspace()->requestFocus(this);
}
void
ToolManager::slotReset()
{
Static::instance()->update();
repaint();
}
void
ToolManager::captionChange(const QString &)
{
repaint();
}
void
ToolManager::paletteChange(const QPalette &)
{
Static::instance()->update();
repaint();
}
void
ToolManager::activeChange(bool b)
{
emit(activeChanged(b));
repaint();
}
void
ToolManager::slotHelp()
{
contextHelp();
}
void
ToolManager::animateIconifyOrDeiconify(bool iconify)
{
NETRect r = netWinInfo()->iconGeometry();
QRect icongeom(r.pos.x, r.pos.y, r.size.width, r.size.height);
if (!icongeom.isValid())
return;
QRect wingeom(x(), y(), width(), height());
XGrabServer(qt_xdisplay());
QPainter p(workspace()->desktopWidget());
p.setRasterOp(Qt::NotROP);
if (iconify)
p.setClipRegion(QRegion(workspace()->desktopWidget()->rect()) - wingeom);
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
p.drawLine(wingeom.topRight(), icongeom.topRight());
p.flush();
XSync( qt_xdisplay(), FALSE );
usleep(30000);
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
p.drawLine(wingeom.topRight(), icongeom.topRight());
p.end();
XUngrabServer( qt_xdisplay() );
}
} // End namespace
// vim:ts=2:sw=2:tw=78

View File

@ -74,6 +74,9 @@ class Manager : public Client
void resizeEvent(QResizeEvent *);
void mouseDoubleClickEvent(QMouseEvent *);
void animateIconifyOrDeiconify(bool);
void animate(bool, int);
void updateButtonVisibility();
void updateTitleBuffer();
protected slots:
@ -92,9 +95,11 @@ class Manager : public Client
QSpacerItem * titleSpacer_;
QDict<Button> buttonDict_;
QPixmap titleBuf_;
};
class ToolManager : public Client
class ToolManager : public Manager
{
Q_OBJECT
@ -102,38 +107,6 @@ class ToolManager : public Client
ToolManager(Workspace *, WId, QWidget * parent = 0, const char * name = 0);
~ToolManager();
signals:
void activeChanged(bool);
public slots:
void slotHelp();
protected:
Client::MousePosition mousePosition(const QPoint &) const;
void paletteChange(const QPalette &);
void activeChange(bool);
void paintEvent(QPaintEvent *);
void resizeEvent(QResizeEvent *);
void mouseDoubleClickEvent(QMouseEvent *);
void animateIconifyOrDeiconify(bool);
protected slots:
void captionChange(const QString &);
void slotReset();
private:
CloseButton * close_;
HelpButton * help_;
QSpacerItem * titleSpacer_;
QDict<Button> buttonDict_;
};

View File

@ -57,12 +57,6 @@ static const char * const texture_xpm[] = {
" a a aab b b aa aab a b ",
" b a b b aaa a b bb b b b b"};
void
Static::_drawButtonBorder(QPixmap & pix)
{
_drawBorder(pix, 17, 17);
}
void
Static::_drawBorder(QPixmap & pix, int w, int h)
{
@ -149,46 +143,10 @@ Static * Static::instance_ = 0L;
void
Static::_init()
{
aResize_ .resize(30, 10);
iResize_ .resize(30, 10);
aTitleTextLeft_ .resize(3, 20);
aTitleTextRight_ .resize(3, 20);
iTitleTextLeft_ .resize(3, 20);
iTitleTextRight_ .resize(3, 20);
aTitleTextMid_ .resize(64, 20);
iTitleTextMid_ .resize(64, 20);
aResizeMidLeft_ .resize(3, 12);
aResizeMidRight_ .resize(3, 12);
iResizeMidLeft_ .resize(3, 12);
iResizeMidRight_ .resize(3, 12);
aResizeMid_ .resize(64, 10);
iResizeMid_ .resize(64, 10);
aButtonUp_ .resize(19, 19);
iButtonUp_ .resize(19, 19);
aButtonDown_ .resize(19, 19);
iButtonDown_ .resize(19, 19);
animationStyle_ = 0;
aResize_ .fill(Qt::black);
iResize_ .fill(Qt::black);
aTitleTextLeft_ .fill(Qt::black);
aTitleTextRight_ .fill(Qt::black);
iTitleTextLeft_ .fill(Qt::black);
iTitleTextRight_ .fill(Qt::black);
aTitleTextMid_ .fill(Qt::black);
iTitleTextMid_ .fill(Qt::black);
aResizeMidLeft_ .fill(Qt::black);
aResizeMidRight_ .fill(Qt::black);
iResizeMidLeft_ .fill(Qt::black);
iResizeMidRight_ .fill(Qt::black);
aResizeMid_ .fill(Qt::black);
iResizeMid_ .fill(Qt::black);
aButtonUp_ .fill(Qt::black);
iButtonUp_ .fill(Qt::black);
aButtonDown_ .fill(Qt::black);
iButtonDown_ .fill(Qt::black);
aButtonUp_ .setOptimization(QPixmap::MemoryOptim);
aButtonDown_ .setOptimization(QPixmap::MemoryOptim);
aButtonUp_ .setOptimization(QPixmap::BestOptim);
aButtonDown_ .setOptimization(QPixmap::BestOptim);
iButtonUp_ .setOptimization(QPixmap::MemoryOptim);
iButtonDown_ .setOptimization(QPixmap::MemoryOptim);
@ -218,6 +176,61 @@ Static::_init()
void
Static::update()
{
QFont f(options->font(true)); // XXX false doesn't work right at the moment
QFontMetrics fm(f);
int h = fm.height();
titleHeight_ = h + 6;
if (titleHeight_ < 20)
titleHeight_ = 20;
int buttonSize = titleHeight_ - 1;
resizeHeight_ = 10;
// Sizes.
aResize_ .resize(30, resizeHeight_);
iResize_ .resize(30, resizeHeight_);
aTitleTextLeft_ .resize(3, titleHeight_);
aTitleTextRight_ .resize(3, titleHeight_);
iTitleTextLeft_ .resize(3, titleHeight_);
iTitleTextRight_ .resize(3, titleHeight_);
aTitleTextMid_ .resize(64, titleHeight_);
iTitleTextMid_ .resize(64, titleHeight_);
aResizeMidLeft_ .resize(3, resizeHeight_);
aResizeMidRight_ .resize(3, resizeHeight_);
iResizeMidLeft_ .resize(3, resizeHeight_);
iResizeMidRight_ .resize(3, resizeHeight_);
aResizeMid_ .resize(64, resizeHeight_);
iResizeMid_ .resize(64, resizeHeight_);
aButtonUp_ .resize(buttonSize, buttonSize);
iButtonUp_ .resize(buttonSize, buttonSize);
aButtonDown_ .resize(buttonSize, buttonSize);
iButtonDown_ .resize(buttonSize, buttonSize);
aResize_ .fill(Qt::black);
iResize_ .fill(Qt::black);
aTitleTextLeft_ .fill(Qt::black);
aTitleTextRight_ .fill(Qt::black);
iTitleTextLeft_ .fill(Qt::black);
iTitleTextRight_ .fill(Qt::black);
aTitleTextMid_ .fill(Qt::black);
iTitleTextMid_ .fill(Qt::black);
aResizeMidLeft_ .fill(Qt::black);
aResizeMidRight_ .fill(Qt::black);
iResizeMidLeft_ .fill(Qt::black);
iResizeMidRight_ .fill(Qt::black);
aResizeMid_ .fill(Qt::black);
iResizeMid_ .fill(Qt::black);
aButtonUp_ .fill(Qt::black);
iButtonUp_ .fill(Qt::black);
aButtonDown_ .fill(Qt::black);
iButtonDown_ .fill(Qt::black);
// -------------------------------------------------------------------------
// Palettes
// -------------------------------------------------------------------------
@ -239,6 +252,10 @@ Static::update()
setPalette(aResizePal_, options->color(Options::TitleBar, true));
setPalette(iResizePal_, options->color(Options::TitleBar, false));
// -----------------------------------------------------------------------
// Convert colours in texture to match colour scheme.
// -----------------------------------------------------------------------
QRgb light, dark;
QRgb * data;
QRgb w = qRgb(255,255,255);
@ -276,19 +293,18 @@ Static::update()
}
// -------------------------------------------------------------------------
// Bevels
// Title text area sides
// -------------------------------------------------------------------------
QPixmap temp(4, titleHeight_);
transx = transy = 0.0;
// Create sides of title text area and resize bar middle.
QPixmap temp(4, 20);
temp.fill(Qt::black);
palette_ = aTitlePal_;
down_ = false;
_drawBorder(temp, 4, 18);
_drawBorder(temp, 4, titleHeight_ - 2);
painter_.begin(&aTitleTextLeft_);
painter_.drawPixmap(1, 1, temp, 0, 1);
@ -299,7 +315,7 @@ Static::update()
painter_.end();
palette_ = iTitlePal_;
_drawBorder(temp, 4, 18);
_drawBorder(temp, 4, titleHeight_ - 2);
painter_.begin(&iTitleTextLeft_);
painter_.drawPixmap(1, 1, temp, 0, 1);
@ -309,12 +325,18 @@ Static::update()
painter_.drawPixmap(0, 1, temp, 2, 1);
painter_.end();
// -------------------------------------------------------------------------
// Resize central area sides.
// -------------------------------------------------------------------------
transy = 1.0;
palette_ = aResizePal_;
temp.resize(4, 10);
temp.resize(4, resizeHeight_);
temp.fill(Qt::black);
_drawBorder(temp, 4, 7);
_drawBorder(temp, 4, resizeHeight_ - 3);
painter_.begin(&aResizeMidLeft_);
painter_.drawPixmap(0, 1, temp, 0, 1);
@ -325,7 +347,7 @@ Static::update()
painter_.end();
palette_ = iResizePal_;
_drawBorder(temp, 4, 7);
_drawBorder(temp, 4, resizeHeight_ - 3);
painter_.begin(&iResizeMidLeft_);
painter_.drawPixmap(0, 1, temp, 0, 1);
@ -335,41 +357,48 @@ Static::update()
painter_.drawPixmap(0, 1, temp, 2, 1);
painter_.end();
transx = transy = 0.0;
temp.resize(70, 20);
// -------------------------------------------------------------------------
// Title text area background
// -------------------------------------------------------------------------
transx = transy = 0.0;
temp.resize(70, titleHeight_);
temp.fill(Qt::black);
palette_ = aTitlePal_;
_drawBorder(temp, 70, 17);
_drawBorder(temp, 70, titleHeight_ - 3);
painter_.begin(&aTitleTextMid_);
painter_.drawPixmap(0, 1, temp, 2, 0);
if (hicolour)
painter_.drawPixmap(0, 4, aTexture);
painter_.drawTiledPixmap(0, 4, 64, titleHeight_ - 8, aTexture);
painter_.end();
palette_ = iTitlePal_;
_drawBorder(temp, 70, 17);
_drawBorder(temp, 70, titleHeight_ - 3);
painter_.begin(&iTitleTextMid_);
painter_.drawPixmap(0, 1, temp, 2, 0);
if (hicolour)
painter_.drawPixmap(0, 4, iTexture);
painter_.drawTiledPixmap(0, 4, 64, titleHeight_ - 8, iTexture);
painter_.end();
transy = 1.0;
// -------------------------------------------------------------------------
// Resize central area background
// -------------------------------------------------------------------------
transy = 1.0;
temp.fill(Qt::black);
palette_ = aResizePal_;
_drawBorder(temp, 70, 7);
_drawBorder(temp, 70, resizeHeight_ - 3);
painter_.begin(&aResizeMid_);
painter_.drawPixmap(0, 0, temp, 2, 0);
if (hicolour)
painter_.drawPixmap(0, 3, aTexture, 0, 0, 64, 4);
painter_.drawTiledPixmap(0, 4, 64, resizeHeight_ - 8, aTexture);
painter_.end();
palette_ = iResizePal_;
@ -378,23 +407,9 @@ Static::update()
painter_.begin(&iResizeMid_);
painter_.drawPixmap(0, 0, temp, 2, 0);
if (hicolour)
painter_.drawPixmap(0, 3, iTexture, 0, 0, 64, 4);
painter_.drawTiledPixmap(0, 4, 64, resizeHeight_ - 8, iTexture);
painter_.end();
down_ = false;
transx = 0.0;
palette_ = aBut;
_drawButtonBorder(aButtonUp_);
down_ = true;
_drawButtonBorder(aButtonDown_);
palette_ = iBut;
_drawButtonBorder(iButtonDown_);
down_ = false;
_drawButtonBorder(iButtonUp_);
// -------------------------------------------------------------------------
// Resize handles
// -------------------------------------------------------------------------
@ -404,23 +419,56 @@ Static::update()
down_ = false;
palette_ = aResizePal_;
_drawBorder(aResize_, 28, 7);
_drawBorder(aResize_, 28, resizeHeight_ - 3);
if (hicolour) {
painter_.begin(&aResize_);
painter_.drawPixmap(3, 3, aTexture, 0, 0, 24, 4);
painter_.drawTiledPixmap(4, 4, 20, resizeHeight_ - 8, aTexture);
painter_.end();
}
palette_ = iResizePal_;
_drawBorder(iResize_, 28, 7);
_drawBorder(iResize_, 28, resizeHeight_ - 3);
if (hicolour) {
painter_.begin(&iResize_);
painter_.drawPixmap(3, 3, iTexture, 0, 0, 24, 4);
painter_.drawTiledPixmap(4, 4, 20, resizeHeight_ - 8, iTexture);
painter_.end();
}
// -------------------------------------------------------------------------
// Button backgrounds
// -------------------------------------------------------------------------
qDebug("buttonSize == %d", buttonSize);
buttonSize -=2;
down_ = false;
transx = 0.0;
transy = 1.0;
palette_ = aBut;
_drawBorder(aButtonUp_, buttonSize, buttonSize);
down_ = true;
_drawBorder(aButtonDown_, buttonSize, buttonSize);
palette_ = iBut;
_drawBorder(iButtonDown_, buttonSize, buttonSize);
down_ = false;
_drawBorder(iButtonUp_, buttonSize, buttonSize);
painter_.begin(&aButtonUp_);
if (hicolour)
painter_.drawTiledPixmap(4, 4, buttonSize - 8, buttonSize - 8, aTexture);
painter_.end();
painter_.begin(&iButtonUp_);
if (hicolour)
painter_.drawTiledPixmap(4, 4, buttonSize - 8, buttonSize - 8, iTexture);
painter_.end();
// ------------------------------------------------------------------------
// Button order
// ------------------------------------------------------------------------

View File

@ -92,9 +92,17 @@ class Static
const QStringList & rightButtons() const
{ return rightButtons_; }
int animationStyle() const
{ return animationStyle_; }
int titleHeight() const
{ return titleHeight_; }
int resizeHeight() const
{ return resizeHeight_; }
private:
void _drawButtonBorder (QPixmap &);
void _drawBorder (QPixmap &, int, int);
void _init();
@ -121,6 +129,11 @@ class Static
double transx, transy;
QStringList leftButtons_, rightButtons_;
int animationStyle_;
int titleHeight_;
int resizeHeight_;
};
} // End namespace