From 402e229e76dfd8b4cda8b7cf1fccaec5acf7570c Mon Sep 17 00:00:00 2001 From: Scott Moynes Date: Wed, 16 Oct 2002 22:33:34 +0000 Subject: [PATCH] Allow for customizing of the dropShadows. If xft.flags: shadow then you can specify the tint with xft.shadow.tint: which should be a number 0 to 255. xft.shadow.offset: will specify how many pixels to add in positioning. Also, try to fix the inheritence in the pressed button borders. Need a style to test this --- src/Font.cc | 12 ++++++++---- src/Font.hh | 5 ++++- src/Screen.cc | 16 +++++++++++++++- src/Window.cc | 26 +++++++++++--------------- 4 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/Font.cc b/src/Font.cc index fd7a0fbe..e2649f10 100644 --- a/src/Font.cc +++ b/src/Font.cc @@ -48,7 +48,8 @@ string BFont::_fallback_font = "fixed"; #ifdef XFT BFont::BFont(Display *d, BScreen *screen, const string &family, int size, - bool bold, bool italic, bool shadow, bool antialias) : + bool bold, bool italic, bool shadow, unsigned char offset, + unsigned char tint, bool antialias) : _display(d), _screen(screen), _family(family), @@ -58,6 +59,8 @@ BFont::BFont(Display *d, BScreen *screen, const string &family, int size, _italic(italic), _antialias(antialias), _shadow(shadow), + _offset(offset), + _tint(tint), _xftfont(0), _font(0), _fontset(0), @@ -267,7 +270,7 @@ void BFont::drawString(Drawable d, int x, int y, const BColor &color, c.color.red = 0; c.color.green = 0; c.color.blue = 0; - c.color.alpha = 0x40 | 0x40 << 8; // transparent shadow + c.color.alpha = _tint | _tint << 8; // transparent shadow c.pixel = BlackPixel(_display, _screen->getScreenNumber()); #ifdef XFT_UTF8 @@ -275,8 +278,9 @@ void BFont::drawString(Drawable d, int x, int y, const BColor &color, #else XftDrawString8( #endif - draw, &c, _xftfont, x + 1, _xftfont->ascent + y + 1, - (XftChar8 *) string.c_str(), string.size()); + draw, &c, _xftfont, x + _offset, + _xftfont->ascent + y + _offset, (XftChar8 *) string.c_str(), + string.size()); } XftColor c; diff --git a/src/Font.hh b/src/Font.hh index e29f41b1..8f3856b6 100644 --- a/src/Font.hh +++ b/src/Font.hh @@ -72,6 +72,8 @@ private: #ifdef XFT bool _antialias; bool _shadow; + unsigned char _offset; + unsigned char _tint; XftFont *_xftfont; @@ -96,7 +98,8 @@ public: #ifdef XFT // loads an Xft font BFont(Display *d, BScreen *screen, const std::string &family, int size, - bool bold, bool italic, bool shadow, bool antialias = True); + bool bold, bool italic, bool shadow, unsigned char offset, + unsigned char tint, bool antialias = True); #endif // loads a standard X font BFont(Display *d, BScreen *screen, const std::string &xlfd); diff --git a/src/Screen.cc b/src/Screen.cc index 4d15e28b..f691cf6e 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -2733,6 +2733,7 @@ BFont *BScreen::readDatabaseFont(const string &rbasename, bool bold = False; bool italic = False; bool dropShadow = False; + if (style.getValue(rbasename + "xft.flags", s)) { if (s.find("bold") != string::npos) bold = True; @@ -2742,8 +2743,21 @@ BFont *BScreen::readDatabaseFont(const string &rbasename, dropShadow = True; } + unsigned char offset = 1; + if (style.getValue(rbasename + "xft.shadow.offset", s)) { + offset = atoi(s.c_str()); //doesn't detect errors + if (offset > CHAR_MAX) + offset = 1; + } + + unsigned char tint = 0x40; + if (style.getValue(rbasename + "xft.shadow.tint", s)) { + tint = atoi(s.c_str()); + } + + BFont *b = new BFont(blackbox->getXDisplay(), this, family, i, bold, - italic, dropShadow, resource.aa_fonts); + italic, dropShadow, offset, tint, resource.aa_fonts); if (b->valid()) return b; else diff --git a/src/Window.cc b/src/Window.cc index 8a1bbda2..f3103165 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -600,21 +600,17 @@ void BlackboxWindow::decorate(void) { if (needsPressed) { texture = &(screen->getWindowStyle()->b_pressed); - Pixmap pbutton = texture->render(frame.button_w, frame.button_w, - pbutton); - unsigned long pixel; - - if (!pbutton) { - pixel = texture->color().pixel(); - if (needsPressed & 0x1) - frame.pfbutton_pixel = pixel; - if (needsPressed & 0x2) - frame.pubutton_pixel = pixel; - } else { - if (needsPressed & 0x1) - frame.pfbutton = pbutton; - if (needsPressed & 0x2) - frame.pubutton = pbutton; + if (needsPressed & 0x1) { + frame.pfbutton = texture->render(frame.button_w, frame.button_w, + frame.pfbutton); + if (! frame.pfbutton) + frame.pfbutton_pixel = texture->color().pixel(); + } + if (needsPressed & 0x2) { + frame.pubutton = texture->render(frame.button_w, frame.button_w, + frame.pubutton); + if (! frame.pubutton) + frame.pubutton = texture->color().pixel(); } } -- 2.39.2