- minor changes to button drawing

- button icon changes: don't use recolored+scaled .xpm files as icons, instead
  create bitmaps on the fly in code which can easily be colored and don't need
  to be scaled... looks much cleaner IMHO.

svn path=/trunk/kdebase/kwin/; revision=399001
icc-effect-5.14.5
Sandro Giessl 2005-03-19 16:16:33 +00:00
parent 50a21c6be9
commit 4e10228f75
18 changed files with 471 additions and 633 deletions

View File

@ -20,6 +20,7 @@
Boston, MA 02111-1307, USA.
*/
#include <qbitmap.h>
#include <qpainter.h>
#include <qimage.h>
@ -27,32 +28,19 @@
#include <kpixmap.h>
#include <kpixmapeffect.h>
#include "xpm/close.xpm"
#include "xpm/minimize.xpm"
#include "xpm/maximize.xpm"
#include "xpm/restore.xpm"
#include "xpm/help.xpm"
#include "xpm/sticky.xpm"
#include "xpm/unsticky.xpm"
#include "xpm/shade.xpm"
#include "xpm/unshade.xpm"
#include "xpm/keepabove.xpm"
#include "xpm/notkeepabove.xpm"
#include "xpm/keepbelow.xpm"
#include "xpm/notkeepbelow.xpm"
#include "xpm/empty.xpm"
#include "misc.h"
#include "plastik.h"
#include "plastik.moc"
#include "plastikclient.h"
#include "plastikbutton.h"
namespace KWinPlastik
{
PlastikHandler::PlastikHandler()
{
memset(m_pixmaps, 0, sizeof(QPixmap*)*(NumPixmaps+NumButtonPixmaps*2)*2*2); // set elements to 0
memset(m_pixmaps, 0, sizeof(QPixmap*)*NumPixmaps*2*2); // set elements to 0
memset(m_bitmaps, 0, sizeof(QBitmap*)*NumButtonIcons*2);
reset(0);
}
@ -61,8 +49,11 @@ PlastikHandler::~PlastikHandler()
{
for (int t=0; t < 2; ++t)
for (int a=0; a < 2; ++a)
for (int i=0; i < NumPixmaps+NumButtonPixmaps*2; ++i)
for (int i=0; i < NumPixmaps; ++i)
delete m_pixmaps[t][a][i];
for (int t=0; t < 2; ++t)
for (int i=0; i < NumButtonIcons; ++i)
delete m_bitmaps[t][i];
}
bool PlastikHandler::reset(unsigned long changed)
@ -105,7 +96,7 @@ bool PlastikHandler::reset(unsigned long changed)
// pixmaps probably need to be updated, so delete the cache.
for (int t=0; t < 2; ++t) {
for (int a=0; a < 2; ++a) {
for (int i=0; i < NumPixmaps+NumButtonPixmaps*2; i++) {
for (int i=0; i < NumPixmaps; i++) {
if (m_pixmaps[t][a][i]) {
delete m_pixmaps[t][a][i];
m_pixmaps[t][a][i] = 0;
@ -113,6 +104,14 @@ bool PlastikHandler::reset(unsigned long changed)
}
}
}
for (int t=0; t < 2; ++t) {
for (int i=0; i < NumButtonIcons; i++) {
if (m_bitmaps[t][i]) {
delete m_bitmaps[t][i];
m_bitmaps[t][i] = 0;
}
}
}
// Do we need to "hit the wooden hammer" ?
bool needHardReset = true;
@ -170,11 +169,17 @@ void PlastikHandler::readConfig()
int titleHeightMin = config.readNumEntry("MinTitleHeight", 16);
// The title should strech with bigger font sizes!
m_titleHeight = QMAX(titleHeightMin, fm.height() + 4); // 4 px for the shadow etc.
// have an even title/button size so the button icons are fully centered...
if ( m_titleHeight%2 == 0)
m_titleHeight++;
fm = QFontMetrics(m_titleFontTool); // active font = inactive font
int titleHeightToolMin = config.readNumEntry("MinTitleHeightTool", 13);
// The title should strech with bigger font sizes!
m_titleHeightTool = QMAX(titleHeightToolMin, fm.height() ); // don't care about the shadow etc.
// have an even title/button size so the button icons are fully centered...
if ( m_titleHeightTool%2 == 0)
m_titleHeightTool++;
QString value = config.readEntry("TitleAlignment", "AlignHCenter");
if (value == "AlignLeft") m_titleAlign = Qt::AlignLeft;
@ -189,7 +194,7 @@ QColor PlastikHandler::getColor(KWinPlastik::ColorType type, const bool active)
{
switch (type) {
case WindowContour:
return KDecoration::options()->color(ColorTitleBar, active).dark(190);
return KDecoration::options()->color(ColorTitleBar, active).dark(200);
case TitleGradient1:
return hsvRelative(KDecoration::options()->color(ColorTitleBar, active), 0,-10,+10);
break;
@ -274,9 +279,9 @@ const QPixmap &PlastikHandler::pixmap(Pixmaps type, bool active, bool toolWindow
}
}
const QPixmap &PlastikHandler::buttonPixmap(ButtonPixmaps type, const QSize &size, bool pressed, bool active, bool toolWindow)
const QBitmap &PlastikHandler::buttonBitmap(ButtonIcon type, const QSize &size, bool toolWindow)
{
int typeIndex = NumPixmaps+(pressed?type*2:type);
int typeIndex = NumPixmaps+type;
// btn icon size...
int reduceW = 0, reduceH = 0;
@ -293,67 +298,18 @@ const QPixmap &PlastikHandler::buttonPixmap(ButtonPixmaps type, const QSize &siz
int w = size.width() - reduceW;
int h = size.height() - reduceH;
if (m_pixmaps[toolWindow][active][typeIndex] && m_pixmaps[toolWindow][active][typeIndex]->size()==QSize(w,h) )
return *m_pixmaps[toolWindow][active][typeIndex];
if (m_bitmaps[toolWindow][typeIndex] && m_bitmaps[toolWindow][typeIndex]->size()==QSize(w,h) )
return *m_bitmaps[toolWindow][typeIndex];
// no matching pixmap found, create a new one...
delete m_pixmaps[toolWindow][active][typeIndex];
m_pixmaps[toolWindow][active][typeIndex] = 0;
QColor iconColor = alphaBlendColors(getColor(TitleGradient3, active), pressed ? Qt::white : Qt::black, 50);
QImage img;
switch (type) {
case BtnHelp:
img = QImage(help_xpm);
break;
case BtnMax:
img = QImage(maximize_xpm);
break;
case BtnMaxRestore:
img = QImage(restore_xpm);
break;
case BtnMin:
img = QImage(minimize_xpm);
break;
case BtnClose:
img = QImage(close_xpm);
break;
case BtnOnAllDesktops:
img = QImage(sticky_xpm);
break;
case BtnNotOnAllDesktops:
img = QImage(unsticky_xpm);
break;
case BtnAbove:
img = QImage(keepabove_xpm);
break;
case BtnNotAbove:
img = QImage(notkeepabove_xpm);
break;
case BtnBelow:
img = QImage(keepbelow_xpm);
case BtnNotBelow:
img = QImage(notkeepbelow_xpm);
break;
case BtnShade:
img = QImage(shade_xpm);
break;
case BtnShadeRestore:
img = QImage(unshade_xpm);
break;
default:
img = QImage(empty_xpm);
break;
}
QPixmap *pixmap = new QPixmap(recolorImage(&img, iconColor).smoothScale(w,h) );
m_pixmaps[toolWindow][active][typeIndex] = pixmap;
return *pixmap;
delete m_bitmaps[toolWindow][typeIndex];
m_bitmaps[toolWindow][typeIndex] = 0;
QBitmap bmp = IconEngine::icon(type /*icon*/, QMIN(w,h) );
QBitmap *bitmap = new QBitmap(bmp);
m_bitmaps[toolWindow][typeIndex] = bitmap;
return *bitmap;
}
QValueList< PlastikHandler::BorderSize >

View File

@ -49,21 +49,21 @@ enum Pixmaps {
NumPixmaps
};
enum ButtonPixmaps {
BtnHelp = 0,
BtnMax,
BtnMaxRestore,
BtnMin,
BtnClose,
BtnOnAllDesktops,
BtnNotOnAllDesktops,
BtnAbove,
BtnNotAbove,
BtnBelow,
BtnNotBelow,
BtnShade,
BtnShadeRestore,
NumButtonPixmaps
enum ButtonIcon {
CloseIcon = 0,
MaxIcon,
MaxRestoreIcon,
MinIcon,
HelpIcon,
OnAllDesktopsIcon,
NotOnAllDesktopsIcon,
KeepAboveIcon,
NoKeepAboveIcon,
KeepBelowIcon,
NoKeepBelowIcon,
ShadeIcon,
UnShadeIcon,
NumButtonIcons
};
class PlastikHandler: public QObject, public KDecorationFactory
@ -78,7 +78,7 @@ public:
virtual bool supports( Ability ability );
const QPixmap &pixmap(Pixmaps type, bool active, bool toolWindow);
const QPixmap &buttonPixmap(ButtonPixmaps type, const QSize &size, bool pressed, bool active, bool toolWindow);
const QBitmap &buttonBitmap(ButtonIcon type, const QSize &size, bool toolWindow);
int titleHeight() { return m_titleHeight; }
int titleHeightTool() { return m_titleHeightTool; }
@ -109,7 +109,8 @@ private:
Qt::AlignmentFlags m_titleAlign;
// pixmap cache
QPixmap *m_pixmaps[2][2][NumPixmaps+NumButtonPixmaps*2]; // button pixmaps have normal+pressed state...
QPixmap *m_pixmaps[2][2][NumPixmaps]; // button pixmaps have normal+pressed state...
QBitmap *m_bitmaps[2][NumButtonIcons];
};
PlastikHandler* Handler();

View File

@ -47,7 +47,7 @@ static const uint ANIMATIONSTEPS = 4;
PlastikButton::PlastikButton(ButtonType type, PlastikClient *parent, const char *name)
: KCommonDecorationButton(type, parent, name),
m_client(parent),
m_pixmapType(BtnClose),
m_iconType(NumButtonIcons),
hover(false)
{
setBackgroundMode(NoBackground);
@ -68,51 +68,51 @@ void PlastikButton::reset(unsigned long changed)
if (changed&DecorationReset || changed&ManualReset || changed&SizeChange || changed&StateChange) {
switch (type() ) {
case CloseButton:
m_pixmapType = BtnClose;
m_iconType = CloseIcon;
break;
case HelpButton:
m_pixmapType = BtnHelp;
m_iconType = HelpIcon;
break;
case MinButton:
m_pixmapType = BtnMin;
m_iconType = MinIcon;
break;
case MaxButton:
if (isOn()) {
m_pixmapType = BtnMaxRestore;
m_iconType = MaxRestoreIcon;
} else {
m_pixmapType = BtnMax;
m_iconType = MaxIcon;
}
break;
case OnAllDesktopsButton:
if (isOn()) {
m_pixmapType = BtnNotOnAllDesktops;
m_iconType = NotOnAllDesktopsIcon;
} else {
m_pixmapType = BtnOnAllDesktops;
m_iconType = OnAllDesktopsIcon;
}
break;
case ShadeButton:
if (isOn()) {
m_pixmapType = BtnShadeRestore;
m_iconType = UnShadeIcon;
} else {
m_pixmapType = BtnShade;
m_iconType = ShadeIcon;
}
break;
case AboveButton:
if (isOn()) {
m_pixmapType = BtnNotAbove;
m_iconType = NoKeepAboveIcon;
} else {
m_pixmapType = BtnAbove;
m_iconType = KeepAboveIcon;
}
break;
case BelowButton:
if (isOn()) {
m_pixmapType = BtnNotBelow;
m_iconType = NoKeepBelowIcon;
} else {
m_pixmapType = BtnBelow;
m_iconType = KeepBelowIcon;
}
break;
default:
m_pixmapType = NumButtonPixmaps; // invalid...
m_iconType = NumButtonIcons; // empty...
break;
}
@ -179,13 +179,13 @@ void PlastikButton::drawButton(QPainter *painter)
}
QColor contourTop = alphaBlendColors(Handler()->getColor(TitleGradient2, active),
Qt::black, 220);
Qt::white, 215);
QColor contourBottom = alphaBlendColors(Handler()->getColor(TitleGradient3, active),
Qt::black, 220);
Qt::white, 215);
QColor sourfaceTop = alphaBlendColors(Handler()->getColor(TitleGradient2, active),
Qt::white, 220);
Qt::black, 225);
QColor sourfaceBottom = alphaBlendColors(Handler()->getColor(TitleGradient3, active),
Qt::white, 220);
Qt::black, 225);
int highlightAlpha = static_cast<int>(255-((60/static_cast<double>(ANIMATIONSTEPS))*
static_cast<double>(animProgress) ) );
@ -265,12 +265,24 @@ void PlastikButton::drawButton(QPainter *painter)
else
{
int dX,dY;
const QPixmap &icon = Handler()->buttonPixmap(m_pixmapType, size(), isDown(), active, decoration()->isToolWindow() );
const QBitmap &icon = Handler()->buttonBitmap(m_iconType, size(), decoration()->isToolWindow() );
dX = r.x()+(r.width()-icon.width())/2;
dY = r.y()+(r.height()-icon.height())/2;
if (isDown() ) {
dY++;
}
if(!isDown() && Handler()->titleShadow() ) {
QColor shadowColor;
if (qGray(Handler()->getColor(TitleFont,active).rgb()) < 100)
shadowColor = QColor(255, 255, 255);
else
shadowColor = QColor(0,0,0);
bP.setPen(alphaBlendColors(sourfaceTop, shadowColor, 180) );
bP.drawPixmap(dX+1, dY+1, icon);
}
bP.setPen(Handler()->getColor(TitleFont,active) );
bP.drawPixmap(dX, dY, icon);
}
@ -278,4 +290,367 @@ void PlastikButton::drawButton(QPainter *painter)
painter->drawPixmap(0, 0, buffer);
}
QBitmap IconEngine::icon(ButtonIcon icon, int size)
{
if (size%2 == 0)
--size;
QBitmap bitmap(size,size);
bitmap.fill(Qt::color0);
QPainter p(&bitmap);
p.setPen(Qt::color1);
QRect r = bitmap.rect();
// line widths
int lwTitleBar = 1;
if (r.width() > 16) {
lwTitleBar = 4;
} else if (r.width() > 4) {
lwTitleBar = 2;
}
int lwArrow = 1;
if (r.width() > 16) {
lwArrow = 4;
} else if (r.width() > 7) {
lwArrow = 2;
}
switch(icon) {
case CloseIcon:
{
int lineWidth = 1;
if (r.width() > 16) {
lineWidth = 3;
} else if (r.width() > 4) {
lineWidth = 2;
}
drawObject(p, DiagonalLine, r.x(), r.y(), r.width(), lineWidth);
drawObject(p, CrossDiagonalLine, r.x(), r.bottom(), r.width(), lineWidth);
break;
}
case MaxIcon:
{
int lineWidth2 = 1; // frame
if (r.width() > 16) {
lineWidth2 = 2;
} else if (r.width() > 4) {
lineWidth2 = 1;
}
drawObject(p, HorizontalLine, r.x(), r.top(), r.width(), lwTitleBar);
drawObject(p, HorizontalLine, r.x(), r.bottom()-(lineWidth2-1), r.width(), lineWidth2);
drawObject(p, VerticalLine, r.x(), r.top(), r.height(), lineWidth2);
drawObject(p, VerticalLine, r.right()-(lineWidth2-1), r.top(), r.height(), lineWidth2);
break;
}
case MaxRestoreIcon:
{
int lineWidth2 = 1; // frame
if (r.width() > 16) {
lineWidth2 = 2;
} else if (r.width() > 4) {
lineWidth2 = 1;
}
int margin1, margin2;
margin1 = margin2 = lineWidth2*2;
if (r.width() < 8)
margin1 = 1;
// background window
drawObject(p, HorizontalLine, r.x()+margin1, r.top(), r.width()-margin1, lineWidth2);
drawObject(p, HorizontalLine, r.right()-margin2, r.bottom()-(lineWidth2-1)-margin1, margin2, lineWidth2);
drawObject(p, VerticalLine, r.x()+margin1, r.top(), margin2, lineWidth2);
drawObject(p, VerticalLine, r.right()-(lineWidth2-1), r.top(), r.height()-margin1, lineWidth2);
// foreground window
drawObject(p, HorizontalLine, r.x(), r.top()+margin2, r.width()-margin2, lwTitleBar);
drawObject(p, HorizontalLine, r.x(), r.bottom()-(lineWidth2-1), r.width()-margin2, lineWidth2);
drawObject(p, VerticalLine, r.x(), r.top()+margin2, r.height(), lineWidth2);
drawObject(p, VerticalLine, r.right()-(lineWidth2-1)-margin2, r.top()+margin2, r.height(), lineWidth2);
break;
}
case MinIcon:
{
drawObject(p, HorizontalLine, r.x(), r.bottom()-(lwTitleBar-1), r.width(), lwTitleBar);
break;
}
case HelpIcon:
{
int center = r.x()+r.width()/2 -1;
int side = r.width()/4;
// paint a question mark... code is quite messy, to be cleaned up later...! :o
if (r.width() > 16) {
int lineWidth = 3;
// top bar
drawObject(p, HorizontalLine, center-side+3, r.y(), 2*side-3-1, lineWidth);
// top bar rounding
drawObject(p, CrossDiagonalLine, center-side-1, r.y()+5, 6, lineWidth);
drawObject(p, DiagonalLine, center+side-3, r.y(), 5, lineWidth);
// right bar
drawObject(p, VerticalLine, center+side+2-lineWidth, r.y()+3, r.height()-(2*lineWidth+side+2+1), lineWidth);
// bottom bar
drawObject(p, CrossDiagonalLine, center, r.bottom()-2*lineWidth, side+2, lineWidth);
drawObject(p, HorizontalLine, center, r.bottom()-3*lineWidth+2, lineWidth, lineWidth);
// the dot
drawObject(p, HorizontalLine, center, r.bottom()-(lineWidth-1), lineWidth, lineWidth);
} else if (r.width() > 8) {
int lineWidth = 2;
// top bar
drawObject(p, HorizontalLine, center-(side-1), r.y(), 2*side-1, lineWidth);
// top bar rounding
if (r.width() > 9) {
drawObject(p, CrossDiagonalLine, center-side-1, r.y()+3, 3, lineWidth);
} else {
drawObject(p, CrossDiagonalLine, center-side-1, r.y()+2, 3, lineWidth);
}
drawObject(p, DiagonalLine, center+side-1, r.y(), 3, lineWidth);
// right bar
drawObject(p, VerticalLine, center+side+2-lineWidth, r.y()+2, r.height()-(2*lineWidth+side+1), lineWidth);
// bottom bar
drawObject(p, CrossDiagonalLine, center, r.bottom()-2*lineWidth+1, side+2, lineWidth);
// the dot
drawObject(p, HorizontalLine, center, r.bottom()-(lineWidth-1), lineWidth, lineWidth);
} else {
int lineWidth = 1;
// top bar
drawObject(p, HorizontalLine, center-(side-1), r.y(), 2*side, lineWidth);
// top bar rounding
drawObject(p, CrossDiagonalLine, center-side-1, r.y()+1, 2, lineWidth);
// right bar
drawObject(p, VerticalLine, center+side+1, r.y(), r.height()-(side+2+1), lineWidth);
// bottom bar
drawObject(p, CrossDiagonalLine, center, r.bottom()-2, side+2, lineWidth);
// the dot
drawObject(p, HorizontalLine, center, r.bottom(), 1, 1);
}
break;
}
case NotOnAllDesktopsIcon:
{
int lwMark = 1;
if (r.width() > 16) {
lwMark = 3;
} else if (r.width() > 7) {
lwMark = 2;
}
int l = r.width()/3;
if (l < 1)
l = 1;
drawObject(p, DiagonalLine, r.x()+l, r.y()+l, r.width()-2*l, lwMark);
drawObject(p, CrossDiagonalLine, r.x()+l, r.bottom()-l, r.width()-2*l, lwMark);
// Fall through to OnAllDesktopsIcon intended!
}
case OnAllDesktopsIcon:
{
int circleLineWidth = 1;
if (r.width() > 16) {
circleLineWidth = 4;
} else if (r.width() > 7) {
circleLineWidth = 2;
}
int l = r.width()/4;
if (l < 1)
l = 1;
int l2 = r.width()/3;
if (l2 < 1)
l = 1;
// horizontal bars
drawObject(p, HorizontalLine, r.x()+l, r.y(), r.width()-2*l, circleLineWidth);
drawObject(p, HorizontalLine, r.x()+l, r.bottom()-(circleLineWidth-1), r.width()-2*l, circleLineWidth);
// vertical bars
drawObject(p, VerticalLine, r.x(), r.y()+l, r.height()-2*l, circleLineWidth);
drawObject(p, VerticalLine, r.right()-(circleLineWidth-1), r.y()+l, r.height()-2*l, circleLineWidth);
break;
}
case NoKeepAboveIcon:
{
int center = r.x()+r.width()/2;
// arrow
drawObject(p, CrossDiagonalLine, r.x(), center+2*lwArrow, center-r.x(), lwArrow);
drawObject(p, DiagonalLine, r.x()+center, r.y()+1+2*lwArrow, center-r.x(), lwArrow);
if (lwArrow>1)
drawObject(p, HorizontalLine, center-(lwArrow-2), r.y()+2*lwArrow, (lwArrow-2)*2, lwArrow);
// Fall through to KeepAboveIcon intended!
}
case KeepAboveIcon:
{
int center = r.x()+r.width()/2;
// arrow
drawObject(p, CrossDiagonalLine, r.x(), center, center-r.x(), lwArrow);
drawObject(p, DiagonalLine, r.x()+center, r.y()+1, center-r.x(), lwArrow);
if (lwArrow>1)
drawObject(p, HorizontalLine, center-(lwArrow-2), r.y(), (lwArrow-2)*2, lwArrow);
break;
}
case NoKeepBelowIcon:
{
int center = r.x()+r.width()/2;
// arrow
drawObject(p, DiagonalLine, r.x(), center-2*lwArrow, center-r.x(), lwArrow);
drawObject(p, CrossDiagonalLine, r.x()+center, r.bottom()-1-2*lwArrow, center-r.x(), lwArrow);
if (lwArrow>1)
drawObject(p, HorizontalLine, center-(lwArrow-2), r.bottom()-(lwArrow-1)-2*lwArrow, (lwArrow-2)*2, lwArrow);
// Fall through to KeepBelowIcon intended!
}
case KeepBelowIcon:
{
int center = r.x()+r.width()/2;
// arrow
drawObject(p, DiagonalLine, r.x(), center, center-r.x(), lwArrow);
drawObject(p, CrossDiagonalLine, r.x()+center, r.bottom()-1, center-r.x(), lwArrow);
if (lwArrow>1)
drawObject(p, HorizontalLine, center-(lwArrow-2), r.bottom()-(lwArrow-1), (lwArrow-2)*2, lwArrow);
break;
}
case ShadeIcon:
{
drawObject(p, HorizontalLine, r.x(), r.y(), r.width(), lwTitleBar);
break;
}
case UnShadeIcon:
{
int lw1 = 1;
int lw2 = 1;
if (r.width() > 16) {
lw1 = 4;
lw2 = 2;
} else if (r.width() > 7) {
lw1 = 2;
lw2 = 1;
}
int h = QMAX( (r.width()/2), (lw1+2*lw2) );
// horizontal bars
drawObject(p, HorizontalLine, r.x(), r.y(), r.width(), lw1);
drawObject(p, HorizontalLine, r.x(), r.x()+h-(lw2-1), r.width(), lw2);
// vertical bars
drawObject(p, VerticalLine, r.x(), r.y(), h, lw2);
drawObject(p, VerticalLine, r.right()-(lw2-1), r.y(), h, lw2);
break;
}
default:
break;
}
p.end();
bitmap.setMask(bitmap);
return bitmap;
}
void IconEngine::drawObject(QPainter &p, Object object, int x, int y, int length, int lineWidth)
{
switch(object) {
case DiagonalLine:
if (lineWidth <= 1) {
for (int i = 0; i < length; ++i) {
p.drawPoint(x+i,y+i);
}
} else if (lineWidth <= 2) {
for (int i = 0; i < length; ++i) {
p.drawPoint(x+i,y+i);
}
for (int i = 0; i < (length-1); ++i) {
p.drawPoint(x+1+i,y+i);
p.drawPoint(x+i,y+1+i);
}
} else {
for (int i = 1; i < (length-1); ++i) {
p.drawPoint(x+i,y+i);
}
for (int i = 0; i < (length-1); ++i) {
p.drawPoint(x+1+i,y+i);
p.drawPoint(x+i,y+1+i);
}
for (int i = 0; i < (length-2); ++i) {
p.drawPoint(x+2+i,y+i);
p.drawPoint(x+i,y+2+i);
}
}
break;
case CrossDiagonalLine:
if (lineWidth <= 1) {
for (int i = 0; i < length; ++i) {
p.drawPoint(x+i,y-i);
}
} else if (lineWidth <= 2) {
for (int i = 0; i < length; ++i) {
p.drawPoint(x+i,y-i);
}
for (int i = 0; i < (length-1); ++i) {
p.drawPoint(x+1+i,y-i);
p.drawPoint(x+i,y-1-i);
}
} else {
for (int i = 1; i < (length-1); ++i) {
p.drawPoint(x+i,y-i);
}
for (int i = 0; i < (length-1); ++i) {
p.drawPoint(x+1+i,y-i);
p.drawPoint(x+i,y-1-i);
}
for (int i = 0; i < (length-2); ++i) {
p.drawPoint(x+2+i,y-i);
p.drawPoint(x+i,y-2-i);
}
}
break;
case HorizontalLine:
for (int i = 0; i < lineWidth; ++i) {
p.drawLine(x,y+i, x+length-1, y+i);
}
break;
case VerticalLine:
for (int i = 0; i < lineWidth; ++i) {
p.drawLine(x+i,y, x+i, y+length-1);
}
break;
default:
break;
}
}
} // KWinPlastik

View File

@ -55,13 +55,36 @@ private:
private:
PlastikClient *m_client;
ButtonPixmaps m_pixmapType;
ButtonIcon m_iconType;
bool hover;
QTimer *animTmr;
uint animProgress;
};
/**
* This class creates bitmaps which can be used as icons on buttons. The icons
* are "hardcoded".
* Over the previous "Gimp->xpm->QImage->recolor->SmoothScale->QPixmap" solution
* it has the important advantage that icons are more scalable and at the same
* time sharp and not blurred.
*/
class IconEngine
{
public:
static QBitmap icon(ButtonIcon icon, int size);
private:
enum Object {
HorizontalLine,
VerticalLine,
DiagonalLine,
CrossDiagonalLine
};
static void drawObject(QPainter &p, Object object, int x, int y, int length, int lineWidth);
};
} // namespace KWinPlastik
#endif // PLASTIKBUTTON_H

View File

@ -1,37 +0,0 @@
/* XPM */
static const char * close_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" ... ... ",
" ..... ..... ",
" ...... ...... ",
" ....... ....... ",
" ....... ....... ",
" ....... ....... ",
" ....... ....... ",
" ....... ....... ",
" ....... ....... ",
" ....... ....... ",
" ....... ....... ",
" .............. ",
" ............ ",
" .......... ",
" ........ ",
" ........ ",
" .......... ",
" ............ ",
" .............. ",
" ....... ....... ",
" ....... ....... ",
" ....... ....... ",
" ....... ....... ",
" ....... ....... ",
" ....... ....... ",
" ....... ....... ",
" ....... ....... ",
" ...... ...... ",
" ..... ..... ",
" ... ... ",
" "};

View File

@ -1,36 +0,0 @@
/* XPM */
static const char * empty_xpm[] = {
"32 32 1 1",
" c None",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@ -1,37 +0,0 @@
/* XPM */
static const char * help_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" .......... ",
" ............... ",
" .................. ",
" ...... ........ ",
" ..... ....... ",
" .... ....... ",
" .... ....... ",
" ... ....... ",
" ....... ",
" ....... ",
" ....... ",
" ....... ",
" ........ ",
" ........ ",
" ......... ",
" ......... ",
" ....... ",
" ..... ",
" ..... ",
" ..... ",
" ... ",
" ",
" ",
" ... ",
" ..... ",
" ....... ",
" ....... ",
" ....... ",
" ..... ",
" ... ",
" "};

View File

@ -1,37 +0,0 @@
/* XPM */
const char * keepabove_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" .. ",
" .... ",
" ...... ",
" ........ ",
" .......... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" .... .... ",
" .............................. ",
" .............................. ",
" ............................ ",
" .......................... ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@ -1,37 +0,0 @@
/* XPM */
const char * keepbelow_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" ",
" ",
" ",
" ",
" ",
" .......................... ",
" ............................ ",
" .............................. ",
" .............................. ",
" .... .... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" .......... ",
" ........ ",
" ...... ",
" .... ",
" .. ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@ -1,37 +0,0 @@
/* XPM */
static const char * maximize_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" ............................ ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" .............................. ",
" .............................. ",
" ............................ ",
" "};

View File

@ -1,37 +0,0 @@
/* XPM */
static const char * minimize_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ............................ ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" ............................ ",
" "};

View File

@ -1,37 +0,0 @@
/* XPM */
const char * notkeepabove_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" .. ",
" .... ",
" ...... ",
" ........ ",
" .......... ",
" ............ ",
" .............. ",
" ................ ",
" .................. ",
" .................... ",
" ...................... ",
" ........................ ",
" .......................... ",
" ............................ ",
" ............................ ",
" .............................. ",
" .............................. ",
" ............................ ",
" .......................... ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@ -1,37 +0,0 @@
/* XPM */
const char * notkeepbelow_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" ",
" ",
" ",
" ",
" ",
" .......................... ",
" ............................ ",
" .............................. ",
" .............................. ",
" ............................ ",
" ............................ ",
" .......................... ",
" ........................ ",
" ...................... ",
" .................... ",
" .................. ",
" ................ ",
" .............. ",
" ............ ",
" .......... ",
" ........ ",
" ...... ",
" .... ",
" .. ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@ -1,37 +0,0 @@
/* XPM */
static const char * restore_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" ...................... ",
" ........................ ",
" ........................ ",
" ........................ ",
" .. .. ",
" .. .. ",
" .. .. ",
" .. .. ",
" ..................... .. ",
" ....................... .. ",
" ....................... .. ",
" ....................... .. ",
" ....................... .. ",
" ....................... .. ",
" ... ... .. ",
" ... ... .. ",
" ... ... .. ",
" ... ... .. ",
" ... ... .. ",
" ... ... .. ",
" ... ... .. ",
" ... ... .. ",
" ... ... .. ",
" ... ... .. ",
" ... .......... ",
" ... .......... ",
" ... ... ",
" ....................... ",
" ....................... ",
" ..................... ",
" "};

View File

@ -1,37 +0,0 @@
/* XPM */
const char * shade_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" ............................ ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" .............................. ",
" .............................. ",
" ............................ ",
" ",
" ",
" ",
" ",
" .. ",
" .... ",
" ...... ",
" ........ ",
" .......... ",
" ............ ",
" .............. ",
" ................ ",
" .................. ",
" .................... ",
" ...................... ",
" ........................ ",
" "};

View File

@ -1,37 +0,0 @@
/* XPM */
static const char * sticky_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" ........ ",
" .............. ",
" ................ ",
" .................... ",
" ........ ........ ",
" ...... ...... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" .... .... ",
" .... .... ",
" ..... ..... ",
" .... .... ",
" .... .... ",
" .... .... ",
" .... .... ",
" .... .... ",
" .... .... ",
" ..... ..... ",
" .... .... ",
" .... .... ",
" ..... ..... ",
" ..... ..... ",
" ..... ..... ",
" ...... ...... ",
" ........ ........ ",
" .................... ",
" ................ ",
" .............. ",
" ........ ",
" "};

View File

@ -1,37 +0,0 @@
/* XPM */
const char * unshade_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" ............................ ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" ... .................... ... ",
" ... .................. ... ",
" ... ................ ... ",
" ... .............. ... ",
" ... ............ ... ",
" ... .......... ... ",
" ... ........ ... ",
" ... ...... ... ",
" ... .... ... ",
" ... .. ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" .............................. ",
" .............................. ",
" ............................ ",
" "};

View File

@ -1,37 +0,0 @@
/* XPM */
static const char * unsticky_xpm[] = {
"32 32 2 1",
" c None",
". c #0000FF",
" ",
" ........ ",
" .............. ",
" ................ ",
" .................... ",
" ........ ........ ",
" ...... ...... ",
" ..... ..... ",
" ..... ...... ..... ",
" ..... .......... ..... ",
" .... ............ .... ",
" .... .............. .... ",
" ..... .............. ..... ",
" .... ................ .... ",
" .... ................ .... ",
" .... ................ .... ",
" .... ................ .... ",
" .... ................ .... ",
" .... ................ .... ",
" ..... .............. ..... ",
" .... .............. .... ",
" .... ............ .... ",
" ..... .......... ..... ",
" ..... ...... ..... ",
" ..... ..... ",
" ...... ...... ",
" ........ ........ ",
" .................... ",
" ................ ",
" .............. ",
" ........ ",
" "};