Allow for customizing of the dropShadows.
authorScott Moynes <smoynes@nexus.carleton.ca>
Wed, 16 Oct 2002 22:33:34 +0000 (22:33 +0000)
committerScott Moynes <smoynes@nexus.carleton.ca>
Wed, 16 Oct 2002 22:33:34 +0000 (22:33 +0000)
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
src/Font.hh
src/Screen.cc
src/Window.cc

index fd7a0fb..e2649f1 100644 (file)
@@ -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;
index e29f41b..8f3856b 100644 (file)
@@ -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);
index 4d15e28..f691cf6 100644 (file)
@@ -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
index 8a1bbda..f310316 100644 (file)
@@ -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();
     }
     
   }