Adding support for the IceWM keys ColorActiveTitleBarShadow and
ColorNormalTitleBarShadow as requested by users. svn path=/trunk/kdebase/kwin/; revision=93566
This commit is contained in:
parent
45dea027b3
commit
7bbb0cfa0f
1 changed files with 69 additions and 14 deletions
|
@ -86,14 +86,19 @@ QColor* colorActiveTitleBarText;
|
||||||
QColor* colorInActiveTitleBarText;
|
QColor* colorInActiveTitleBarText;
|
||||||
QColor* colorActiveTitleBar;
|
QColor* colorActiveTitleBar;
|
||||||
QColor* colorInActiveTitleBar;
|
QColor* colorInActiveTitleBar;
|
||||||
|
QColor* colorActiveTitleTextShadow;
|
||||||
|
QColor* colorInActiveTitleTextShadow;
|
||||||
|
|
||||||
int cornerSizeX;
|
int cornerSizeX;
|
||||||
int cornerSizeY;
|
int cornerSizeY;
|
||||||
int titleBarHeight;
|
int titleBarHeight;
|
||||||
int borderSizeX;
|
int borderSizeX;
|
||||||
int borderSizeY;
|
int borderSizeY;
|
||||||
|
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
bool validframe = false;
|
bool validframe = false;
|
||||||
|
bool useActiveShadow = false;
|
||||||
|
bool useInActiveShadow = false;
|
||||||
|
|
||||||
// KControl Settings - Read from kwinrc config file or icewm theme
|
// KControl Settings - Read from kwinrc config file or icewm theme
|
||||||
bool themeTitleTextColors = true; // Allow theme to set colors. kcontrol will have no effect
|
bool themeTitleTextColors = true; // Allow theme to set colors. kcontrol will have no effect
|
||||||
|
@ -138,6 +143,8 @@ ThemeHandler::ThemeHandler(): QObject( 0L )
|
||||||
colorInActiveTitleBarText = new QColor();
|
colorInActiveTitleBarText = new QColor();
|
||||||
colorActiveTitleBar = new QColor();
|
colorActiveTitleBar = new QColor();
|
||||||
colorInActiveTitleBar = new QColor();
|
colorInActiveTitleBar = new QColor();
|
||||||
|
colorActiveTitleTextShadow = new QColor();
|
||||||
|
colorInActiveTitleTextShadow = new QColor();
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
readConfig();
|
readConfig();
|
||||||
|
@ -153,6 +160,8 @@ ThemeHandler::~ThemeHandler()
|
||||||
if (initialized)
|
if (initialized)
|
||||||
freePixmaps();
|
freePixmaps();
|
||||||
|
|
||||||
|
delete colorInActiveTitleTextShadow;
|
||||||
|
delete colorActiveTitleTextShadow;
|
||||||
delete colorInActiveBorder;
|
delete colorInActiveBorder;
|
||||||
delete colorActiveTitleBarText;
|
delete colorActiveTitleBarText;
|
||||||
delete colorInActiveTitleBarText;
|
delete colorInActiveTitleBarText;
|
||||||
|
@ -281,6 +290,30 @@ void ThemeHandler::initTheme()
|
||||||
s = config.readEntry("ColorNormalTitleBarText", "#000000");
|
s = config.readEntry("ColorNormalTitleBarText", "#000000");
|
||||||
*colorInActiveTitleBarText = decodeColor( s );
|
*colorInActiveTitleBarText = decodeColor( s );
|
||||||
|
|
||||||
|
// Use title text shadows only with theme title text colors
|
||||||
|
if ( themeTitleTextColors )
|
||||||
|
{
|
||||||
|
s = config.readEntry("ColorActiveTitleBarShadow", "");
|
||||||
|
if (s.length() > 0)
|
||||||
|
{
|
||||||
|
*colorActiveTitleTextShadow = decodeColor( s );
|
||||||
|
useActiveShadow = true;
|
||||||
|
} else
|
||||||
|
useActiveShadow = false;
|
||||||
|
|
||||||
|
s = config.readEntry("ColorNormalTitleBarShadow", "");
|
||||||
|
if (s.length() > 0)
|
||||||
|
{
|
||||||
|
*colorInActiveTitleTextShadow = decodeColor( s );
|
||||||
|
useInActiveShadow = true;
|
||||||
|
} else
|
||||||
|
useInActiveShadow = false;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
useActiveShadow = false;
|
||||||
|
useInActiveShadow = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Stretch pixmaps for speed, where required
|
// Stretch pixmaps for speed, where required
|
||||||
setPixmap( titleJ, "title", "J.xpm" );
|
setPixmap( titleJ, "title", "J.xpm" );
|
||||||
setPixmap( titleL, "title", "L.xpm" );
|
setPixmap( titleL, "title", "L.xpm" );
|
||||||
|
@ -875,6 +908,20 @@ void IceWMClient::paintEvent( QPaintEvent* )
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
int act = isActive() ? Active: InActive;
|
int act = isActive() ? Active: InActive;
|
||||||
|
|
||||||
|
// Added titlebar shadows - pre-compute values to improve drawing speed
|
||||||
|
QColor colorTitle;
|
||||||
|
QColor colorTitleShadow;
|
||||||
|
|
||||||
|
bool useShadow = isActive() ? useActiveShadow : useInActiveShadow;
|
||||||
|
|
||||||
|
if ( themeTitleTextColors )
|
||||||
|
colorTitle = isActive()? *colorActiveTitleBarText : *colorInActiveTitleBarText;
|
||||||
|
else
|
||||||
|
colorTitle = options->color(Options::Font, isActive());
|
||||||
|
|
||||||
|
if ( useShadow )
|
||||||
|
colorTitleShadow = isActive() ? *colorActiveTitleTextShadow : *colorInActiveTitleTextShadow;
|
||||||
|
|
||||||
// Obtain widget bounds.
|
// Obtain widget bounds.
|
||||||
QRect r;
|
QRect r;
|
||||||
r = rect();
|
r = rect();
|
||||||
|
@ -985,12 +1032,6 @@ void IceWMClient::paintEvent( QPaintEvent* )
|
||||||
|
|
||||||
p.setFont( options->font(true) );
|
p.setFont( options->font(true) );
|
||||||
|
|
||||||
// Select appropriate title text color
|
|
||||||
if (themeTitleTextColors)
|
|
||||||
p.setPen( isActive() ? *colorActiveTitleBarText : *colorInActiveTitleBarText );
|
|
||||||
else
|
|
||||||
p.setPen( options->color(Options::Font, isActive() ));
|
|
||||||
|
|
||||||
// Draw the titlebar pixmap
|
// Draw the titlebar pixmap
|
||||||
if (tmpPix)
|
if (tmpPix)
|
||||||
{
|
{
|
||||||
|
@ -1006,9 +1047,23 @@ void IceWMClient::paintEvent( QPaintEvent* )
|
||||||
tts = caption();
|
tts = caption();
|
||||||
talign = titleBarCentered ? AlignCenter|AlignVCenter : AlignLeft|AlignVCenter;
|
talign = titleBarCentered ? AlignCenter|AlignVCenter : AlignLeft|AlignVCenter;
|
||||||
|
|
||||||
|
// Pre-set the color to reduce flicker
|
||||||
|
if ( useShadow )
|
||||||
|
p.setPen( colorTitleShadow );
|
||||||
|
else
|
||||||
|
p.setPen( colorTitle );
|
||||||
|
|
||||||
p.drawTiledPixmap( r, *tmpPix);
|
p.drawTiledPixmap( r, *tmpPix);
|
||||||
// Draw the text immediately after the pixmap, to reduce flicker
|
|
||||||
|
if ( useShadow )
|
||||||
|
{
|
||||||
|
// Draw the text immediately after the rect to reduce flicker
|
||||||
|
p.drawText(rx+1, ry+1, rw-1, rh, talign, tts);
|
||||||
|
// Select appropriate title text color
|
||||||
|
p.setPen( colorTitle );
|
||||||
|
}
|
||||||
p.drawText(rx, ry, rw, rh, talign, tts);
|
p.drawText(rx, ry, rw, rh, talign, tts);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue