Added the wide-borders feature to the Keramik decoration
svn path=/trunk/kdebase/kwin/; revision=254531
This commit is contained in:
parent
aba6c4993b
commit
5b518b57b0
7 changed files with 167 additions and 12 deletions
|
@ -32,7 +32,9 @@ tiles.h: pics/caption-large-left.png pics/caption-small-right.png pics/titlebar-
|
||||||
pics/caption-small-center.png pics/grabbar-left.png pics/titlebar-right.png \
|
pics/caption-small-center.png pics/grabbar-left.png pics/titlebar-right.png \
|
||||||
pics/caption-large-center.png pics/caption-small-left.png pics/grabbar-right.png \
|
pics/caption-large-center.png pics/caption-small-left.png pics/grabbar-right.png \
|
||||||
pics/titlebutton-round.png pics/bottom-left.png pics/bottom-right.png \
|
pics/titlebutton-round.png pics/bottom-left.png pics/bottom-right.png \
|
||||||
pics/bottom-center.png
|
pics/bottom-center.png \
|
||||||
|
pics/titlebutton-square-large.png pics/titlebutton-square-huge.png \
|
||||||
|
pics/titlebutton-round-large.png pics/titlebutton-round-huge.png \
|
||||||
|
|
||||||
tiles.h: embedtool
|
tiles.h: embedtool
|
||||||
pics=`ls $(srcdir)/pics/*.png 2>/dev/null` ;\
|
pics=`ls $(srcdir)/pics/*.png 2>/dev/null` ;\
|
||||||
|
|
|
@ -182,6 +182,41 @@ KeramikHandler::~KeramikHandler()
|
||||||
|
|
||||||
void KeramikHandler::createPixmaps()
|
void KeramikHandler::createPixmaps()
|
||||||
{
|
{
|
||||||
|
int heightOffset;
|
||||||
|
int widthOffset;
|
||||||
|
switch(options()->preferredBorderSize(this)) {
|
||||||
|
case BorderLarge:
|
||||||
|
widthOffset = 4;
|
||||||
|
heightOffset = 0;
|
||||||
|
break;
|
||||||
|
case BorderVeryLarge:
|
||||||
|
widthOffset = 8;
|
||||||
|
heightOffset = 0;
|
||||||
|
break;
|
||||||
|
case BorderHuge:
|
||||||
|
widthOffset = 14;
|
||||||
|
heightOffset = 0;
|
||||||
|
break;
|
||||||
|
case BorderVeryHuge:
|
||||||
|
widthOffset = 23;
|
||||||
|
heightOffset = 10;
|
||||||
|
break;
|
||||||
|
case BorderOversized:
|
||||||
|
widthOffset = 36;
|
||||||
|
heightOffset = 25;
|
||||||
|
break;
|
||||||
|
case BorderTiny:
|
||||||
|
case BorderNormal:
|
||||||
|
default:
|
||||||
|
widthOffset = 0;
|
||||||
|
heightOffset = 0;
|
||||||
|
}
|
||||||
|
int fontHeight = QFontMetrics(options()->font(true)).height();
|
||||||
|
if (fontHeight > heightOffset + 20)
|
||||||
|
heightOffset = fontHeight - 20;
|
||||||
|
|
||||||
|
QString size = (heightOffset < 8) ? "" : (heightOffset < 20) ? "-large" : "-huge";
|
||||||
|
|
||||||
QColor titleColor, captionColor, buttonColor;
|
QColor titleColor, captionColor, buttonColor;
|
||||||
QImage *titleCenter = NULL, *captionLeft = NULL,
|
QImage *titleCenter = NULL, *captionLeft = NULL,
|
||||||
*captionRight = NULL, *captionCenter = NULL;
|
*captionRight = NULL, *captionCenter = NULL;
|
||||||
|
@ -290,8 +325,8 @@ void KeramikHandler::createPixmaps()
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
buttonColor = QColor(); //KDecoration::options()->color( ButtonBg, true );
|
buttonColor = QColor(); //KDecoration::options()->color( ButtonBg, true );
|
||||||
|
|
||||||
titleButtonRound = loadPixmap( "titlebutton-round", buttonColor );
|
titleButtonRound = loadPixmap( "titlebutton-round"+size, buttonColor );
|
||||||
titleButtonSquare = loadPixmap( "titlebutton-square", buttonColor );
|
titleButtonSquare = loadPixmap( "titlebutton-square"+size, buttonColor );
|
||||||
|
|
||||||
|
|
||||||
// Prepare the tiles for use
|
// Prepare the tiles for use
|
||||||
|
@ -330,6 +365,42 @@ void KeramikHandler::createPixmaps()
|
||||||
pretile( inactiveTiles[ GrabBarCenter ], 128, Qt::Horizontal );
|
pretile( inactiveTiles[ GrabBarCenter ], 128, Qt::Horizontal );
|
||||||
pretile( inactiveTiles[ BorderLeft ], 128, Qt::Vertical );
|
pretile( inactiveTiles[ BorderLeft ], 128, Qt::Vertical );
|
||||||
pretile( inactiveTiles[ BorderRight ], 128, Qt::Vertical );
|
pretile( inactiveTiles[ BorderRight ], 128, Qt::Vertical );
|
||||||
|
|
||||||
|
if (heightOffset > 0) {
|
||||||
|
addHeight (heightOffset, activeTiles[TitleLeft]);
|
||||||
|
addHeight (heightOffset, activeTiles[TitleCenter]);
|
||||||
|
addHeight (heightOffset, activeTiles[TitleRight]);
|
||||||
|
addHeight (heightOffset, activeTiles[CaptionSmallLeft]);
|
||||||
|
addHeight (heightOffset, activeTiles[CaptionSmallCenter]);
|
||||||
|
addHeight (heightOffset, activeTiles[CaptionSmallRight]);
|
||||||
|
addHeight (heightOffset, activeTiles[CaptionLargeLeft]);
|
||||||
|
addHeight (heightOffset, activeTiles[CaptionLargeCenter]);
|
||||||
|
addHeight (heightOffset, activeTiles[CaptionLargeRight]);
|
||||||
|
|
||||||
|
addHeight (heightOffset, inactiveTiles[TitleLeft]);
|
||||||
|
addHeight (heightOffset, inactiveTiles[TitleCenter]);
|
||||||
|
addHeight (heightOffset, inactiveTiles[TitleRight]);
|
||||||
|
addHeight (heightOffset, inactiveTiles[CaptionSmallLeft]);
|
||||||
|
addHeight (heightOffset, inactiveTiles[CaptionSmallCenter]);
|
||||||
|
addHeight (heightOffset, inactiveTiles[CaptionSmallRight]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widthOffset > 0) {
|
||||||
|
addWidth (widthOffset, activeTiles[BorderLeft], true, activeTiles[GrabBarCenter]);
|
||||||
|
addWidth (widthOffset, activeTiles[BorderRight], false, activeTiles[GrabBarCenter]);
|
||||||
|
addWidth (widthOffset, inactiveTiles[BorderLeft], true, inactiveTiles[GrabBarCenter]);
|
||||||
|
addWidth (widthOffset, inactiveTiles[BorderRight], false, inactiveTiles[GrabBarCenter]);
|
||||||
|
|
||||||
|
if (largeGrabBars)
|
||||||
|
widthOffset = widthOffset*3/2;
|
||||||
|
|
||||||
|
addHeight (widthOffset, activeTiles[GrabBarLeft]);
|
||||||
|
addHeight (widthOffset, activeTiles[GrabBarCenter]);
|
||||||
|
addHeight (widthOffset, activeTiles[GrabBarRight]);
|
||||||
|
addHeight (widthOffset, inactiveTiles[GrabBarLeft]);
|
||||||
|
addHeight (widthOffset, inactiveTiles[GrabBarCenter]);
|
||||||
|
addHeight (widthOffset, inactiveTiles[GrabBarRight]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -348,6 +419,57 @@ void KeramikHandler::destroyPixmaps()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KeramikHandler::addWidth (int width, QPixmap *&pix, bool left, QPixmap *bottomPix) {
|
||||||
|
int w = pix->width()+width;
|
||||||
|
int h = pix->height();
|
||||||
|
|
||||||
|
QPixmap *tmp = new QPixmap (w, h);
|
||||||
|
tmp->fill ();
|
||||||
|
QPainter p;
|
||||||
|
p.begin (tmp);
|
||||||
|
|
||||||
|
for (int i = 0; i < h; i++)
|
||||||
|
p.drawPixmap (0, i, *bottomPix, i%2, 0, w,1);
|
||||||
|
|
||||||
|
if (left)
|
||||||
|
p.drawPixmap(0, 0, *pix);
|
||||||
|
else
|
||||||
|
p.drawPixmap(width, 0, *pix);
|
||||||
|
|
||||||
|
p.end();
|
||||||
|
|
||||||
|
delete pix;
|
||||||
|
pix = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KeramikHandler::addHeight (int height, QPixmap *&pix) {
|
||||||
|
int w = pix->width();
|
||||||
|
int h = pix->height()+height;
|
||||||
|
|
||||||
|
QPixmap *tmp = new QPixmap (w, h);
|
||||||
|
QPainter p;
|
||||||
|
p.begin (tmp);
|
||||||
|
if (pix->height() > 10) {
|
||||||
|
p.drawPixmap(0, 0, *pix, 0, 0, w, 11);
|
||||||
|
for (int i = 0; i < height; i+=2)
|
||||||
|
p.drawPixmap(0, 11+i, *pix, 0, 11, w, 2);
|
||||||
|
p.drawPixmap(0, 11+height, *pix, 0, 11, w, -1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int lines = h-3;
|
||||||
|
int factor = pix->height()-3;
|
||||||
|
for (int i = 0; i < lines; i++)
|
||||||
|
p.drawPixmap(0, i, *pix, 0, i*factor/lines, w, 1);
|
||||||
|
p.drawPixmap(0, lines, *pix, 0, factor, w, 3);
|
||||||
|
}
|
||||||
|
p.end();
|
||||||
|
|
||||||
|
delete pix;
|
||||||
|
pix = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void KeramikHandler::flip( QPixmap *&pix1, QPixmap *&pix2 )
|
void KeramikHandler::flip( QPixmap *&pix1, QPixmap *&pix2 )
|
||||||
{
|
{
|
||||||
// Flip the pixmaps horizontally
|
// Flip the pixmaps horizontally
|
||||||
|
@ -402,6 +524,7 @@ void KeramikHandler::readConfig()
|
||||||
if ( ! settings_cache ) {
|
if ( ! settings_cache ) {
|
||||||
settings_cache = new SettingsCache;
|
settings_cache = new SettingsCache;
|
||||||
settings_cache->largeGrabBars = largeGrabBars;
|
settings_cache->largeGrabBars = largeGrabBars;
|
||||||
|
settings_cache->smallCaptionBubbles = smallCaptionBubbles;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete c;
|
delete c;
|
||||||
|
@ -488,6 +611,16 @@ bool KeramikHandler::reset( unsigned long changed )
|
||||||
// Re-read the config file
|
// Re-read the config file
|
||||||
readConfig();
|
readConfig();
|
||||||
|
|
||||||
|
if ( changed & SettingBorder )
|
||||||
|
{
|
||||||
|
pixmapsInvalid = true;
|
||||||
|
needHardReset = true;
|
||||||
|
}
|
||||||
|
if ( changed & SettingFont )
|
||||||
|
{
|
||||||
|
pixmapsInvalid = true;
|
||||||
|
needHardReset = true;
|
||||||
|
}
|
||||||
// Check if the color scheme has changed
|
// Check if the color scheme has changed
|
||||||
if ( changed & SettingColors )
|
if ( changed & SettingColors )
|
||||||
{
|
{
|
||||||
|
@ -509,8 +642,13 @@ bool KeramikHandler::reset( unsigned long changed )
|
||||||
needHardReset = true;
|
needHardReset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( (settings_cache->smallCaptionBubbles != smallCaptionBubbles) ) {
|
||||||
|
needHardReset = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Update our config cache
|
// Update our config cache
|
||||||
settings_cache->largeGrabBars = largeGrabBars;
|
settings_cache->largeGrabBars = largeGrabBars;
|
||||||
|
settings_cache->smallCaptionBubbles = smallCaptionBubbles;
|
||||||
|
|
||||||
// Do we need to recreate the pixmaps?
|
// Do we need to recreate the pixmaps?
|
||||||
if ( pixmapsInvalid ) {
|
if ( pixmapsInvalid ) {
|
||||||
|
@ -537,6 +675,12 @@ KDecoration* KeramikHandler::createDecoration( KDecorationBridge* bridge )
|
||||||
return new KeramikClient( bridge, this );
|
return new KeramikClient( bridge, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QValueList< KeramikHandler::BorderSize > KeramikHandler::borderSizes() const
|
||||||
|
{ // the list must be sorted
|
||||||
|
return QValueList< BorderSize >() << BorderNormal << BorderLarge <<
|
||||||
|
BorderVeryLarge << BorderHuge << BorderVeryHuge << BorderOversized;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -549,7 +693,8 @@ KeramikButton::KeramikButton( KeramikClient* c, const char *name, Button btn, co
|
||||||
QToolTip::add( this, tip ); // FRAME
|
QToolTip::add( this, tip ); // FRAME
|
||||||
setBackgroundMode( NoBackground );
|
setBackgroundMode( NoBackground );
|
||||||
setCursor( arrowCursor );
|
setCursor( arrowCursor );
|
||||||
setFixedSize( 17, 17 );
|
int size = clientHandler->roundButton()->height();
|
||||||
|
setFixedSize( size, size );
|
||||||
|
|
||||||
setToggleButton( (button == OnAllDesktopsButton) );
|
setToggleButton( (button == OnAllDesktopsButton) );
|
||||||
}
|
}
|
||||||
|
@ -599,6 +744,7 @@ void KeramikButton::drawButton( QPainter *p )
|
||||||
{
|
{
|
||||||
const QPixmap *pix;
|
const QPixmap *pix;
|
||||||
const QBitmap *deco;
|
const QBitmap *deco;
|
||||||
|
int size = clientHandler->roundButton()->height();
|
||||||
|
|
||||||
// Get the bevel from the client handler
|
// Get the bevel from the client handler
|
||||||
if ( button == MenuButton || button == OnAllDesktopsButton || button == HelpButton )
|
if ( button == MenuButton || button == OnAllDesktopsButton || button == HelpButton )
|
||||||
|
@ -607,19 +753,20 @@ void KeramikButton::drawButton( QPainter *p )
|
||||||
pix = clientHandler->squareButton();
|
pix = clientHandler->squareButton();
|
||||||
|
|
||||||
// Draw the button background
|
// Draw the button background
|
||||||
p->drawPixmap( 0, 0, *clientHandler->tile( TitleCenter, client->isActive() ),
|
const QPixmap *background = clientHandler->tile( TitleCenter, client->isActive() );
|
||||||
0, 5, 17, 17 );
|
p->drawPixmap( 0, 0, *background,
|
||||||
|
0, (background->height()-size+1)/2, size, size );
|
||||||
|
|
||||||
if ( isDown() ) {
|
if ( isDown() ) {
|
||||||
// Pressed
|
// Pressed
|
||||||
p->drawPixmap( QPoint(), *pix, QStyle::visualRect( QRect(34, 0, 17, 17), pix->rect() ) );
|
p->drawPixmap( QPoint(), *pix, QStyle::visualRect( QRect(2*size, 0, size, size), pix->rect() ) );
|
||||||
p->translate( QApplication::reverseLayout() ? -1 : 1, 1 );
|
p->translate( QApplication::reverseLayout() ? -1 : 1, 1 );
|
||||||
} else if ( hover )
|
} else if ( hover )
|
||||||
// Mouse over
|
// Mouse over
|
||||||
p->drawPixmap( QPoint(), *pix, QStyle::visualRect( QRect(17, 0, 17, 17), pix->rect() ) );
|
p->drawPixmap( QPoint(), *pix, QStyle::visualRect( QRect(size, 0, size, size), pix->rect() ) );
|
||||||
else
|
else
|
||||||
// Normal
|
// Normal
|
||||||
p->drawPixmap( QPoint(), *pix, QStyle::visualRect( QRect(0, 0, 17, 17), pix->rect() ) );
|
p->drawPixmap( QPoint(), *pix, QStyle::visualRect( QRect(0, 0, size, size), pix->rect() ) );
|
||||||
|
|
||||||
|
|
||||||
// Draw the button deco on the bevel
|
// Draw the button deco on the bevel
|
||||||
|
@ -658,7 +805,7 @@ void KeramikButton::drawButton( QPainter *p )
|
||||||
}
|
}
|
||||||
|
|
||||||
p->setPen( Qt::black ); // ### hardcoded color
|
p->setPen( Qt::black ); // ### hardcoded color
|
||||||
p->drawPixmap( 0, 0, *deco );
|
p->drawPixmap( (size-17)/2, (size-17)/2, *deco );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -699,6 +846,8 @@ void KeramikClient::createLayout()
|
||||||
|
|
||||||
int grabBarHeight = clientHandler->grabBarHeight();
|
int grabBarHeight = clientHandler->grabBarHeight();
|
||||||
int topSpacing = ( largeTitlebar ? 4 : 1 );
|
int topSpacing = ( largeTitlebar ? 4 : 1 );
|
||||||
|
int leftBorderWidth = clientHandler->tile( BorderLeft, true )->width();
|
||||||
|
int rightBorderWidth = clientHandler->tile( BorderRight, true )->width();
|
||||||
topSpacer = new QSpacerItem( 10, topSpacing,
|
topSpacer = new QSpacerItem( 10, topSpacing,
|
||||||
QSizePolicy::Expanding, QSizePolicy::Minimum );
|
QSizePolicy::Expanding, QSizePolicy::Minimum );
|
||||||
|
|
||||||
|
@ -723,9 +872,9 @@ void KeramikClient::createLayout()
|
||||||
options()->titleButtonsRight() : QString(default_right) );
|
options()->titleButtonsRight() : QString(default_right) );
|
||||||
titleLayout->addSpacing( buttonMargin - 1 ); // Right button margin
|
titleLayout->addSpacing( buttonMargin - 1 ); // Right button margin
|
||||||
|
|
||||||
windowLayout->addSpacing( 3 ); // Left border
|
windowLayout->addSpacing( leftBorderWidth ); // Left border
|
||||||
windowLayout->addWidget( new QLabel( i18n( "<center><b>Keramik</b></center>" ), widget())); // Window wrapper FRAME
|
windowLayout->addWidget( new QLabel( i18n( "<center><b>Keramik</b></center>" ), widget())); // Window wrapper FRAME
|
||||||
windowLayout->addSpacing( 4 ); // Right border
|
windowLayout->addSpacing( rightBorderWidth ); // Right border
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ namespace Keramik {
|
||||||
struct SettingsCache
|
struct SettingsCache
|
||||||
{
|
{
|
||||||
bool largeGrabBars:1;
|
bool largeGrabBars:1;
|
||||||
|
bool smallCaptionBubbles:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KeramikHandler : public KDecorationFactory
|
class KeramikHandler : public KDecorationFactory
|
||||||
|
@ -58,6 +59,7 @@ namespace Keramik {
|
||||||
KeramikHandler();
|
KeramikHandler();
|
||||||
~KeramikHandler();
|
~KeramikHandler();
|
||||||
|
|
||||||
|
virtual QValueList< BorderSize > borderSizes() const;
|
||||||
virtual bool reset( unsigned long changed );
|
virtual bool reset( unsigned long changed );
|
||||||
virtual KDecoration* createDecoration( KDecorationBridge* );
|
virtual KDecoration* createDecoration( KDecorationBridge* );
|
||||||
|
|
||||||
|
@ -85,6 +87,8 @@ namespace Keramik {
|
||||||
void createPixmaps();
|
void createPixmaps();
|
||||||
void destroyPixmaps();
|
void destroyPixmaps();
|
||||||
|
|
||||||
|
void addWidth (int width, QPixmap *&pix, bool left, QPixmap *bottomPix);
|
||||||
|
void addHeight (int height, QPixmap *&pix);
|
||||||
void flip( QPixmap *&, QPixmap *& );
|
void flip( QPixmap *&, QPixmap *& );
|
||||||
void flip( QPixmap *& );
|
void flip( QPixmap *& );
|
||||||
void pretile( QPixmap *&, int, Qt::Orientation );
|
void pretile( QPixmap *&, int, Qt::Orientation );
|
||||||
|
|
BIN
clients/keramik/pics/titlebutton-round-huge.png
Normal file
BIN
clients/keramik/pics/titlebutton-round-huge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
BIN
clients/keramik/pics/titlebutton-round-large.png
Normal file
BIN
clients/keramik/pics/titlebutton-round-large.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
BIN
clients/keramik/pics/titlebutton-square-huge.png
Normal file
BIN
clients/keramik/pics/titlebutton-square-huge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
BIN
clients/keramik/pics/titlebutton-square-large.png
Normal file
BIN
clients/keramik/pics/titlebutton-square-large.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
Loading…
Reference in a new issue