From abd2f3d6fd114c87f3202f70b5e771442064968a Mon Sep 17 00:00:00 2001 From: Rik Hemsley Date: Fri, 27 Oct 2000 02:16:14 +0000 Subject: [PATCH] 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 --- clients/riscos/Button.cpp | 17 +- clients/riscos/Button.h | 2 + clients/riscos/Manager.cpp | 465 ++++++++++++++++--------------------- clients/riscos/Manager.h | 39 +--- clients/riscos/Static.cpp | 214 ++++++++++------- clients/riscos/Static.h | 15 +- 6 files changed, 369 insertions(+), 383 deletions(-) diff --git a/clients/riscos/Button.cpp b/clients/riscos/Button.cpp index 3ab19c08d4..4e72b75015 100644 --- a/clients/riscos/Button.cpp +++ b/clients/riscos/Button.cpp @@ -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 diff --git a/clients/riscos/Button.h b/clients/riscos/Button.h index 01c9128939..f6f9966dc6 100644 --- a/clients/riscos/Button.h +++ b/clients/riscos/Button.h @@ -44,6 +44,8 @@ class Button : public QWidget Alignment alignment() const; + void update(); + protected slots: void setActive(bool); diff --git a/clients/riscos/Manager.cpp b/clients/riscos/Manager.cpp index 405c5c5e6e..5f1a9f1ca9 100644 --- a/clients/riscos/Manager.cpp +++ b/clients/riscos/Manager.cpp @@ -22,11 +22,13 @@ #include // for usleep #include // for usleep on non-linux platforms +#include // for sin and cos #include #include #include +#include #include #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