aewl
diff draw.c @ 353:8a06efe5b563
new color stuff/new rendering stuff
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Fri, 25 Aug 2006 12:59:45 +0200 |
parents | 5a8bdc3b37cb |
children | f9543a4af9e5 |
line diff
1.1 --- a/draw.c Fri Aug 25 07:54:49 2006 +0200 1.2 +++ b/draw.c Fri Aug 25 12:59:45 2006 +0200 1.3 @@ -22,29 +22,16 @@ 1.4 } 1.5 1.6 static void 1.7 -drawtext(const char *text, Bool invert, Bool highlight) 1.8 +drawtext(const char *text, unsigned long col[ColLast], Bool highlight) 1.9 { 1.10 int x, y, w, h; 1.11 static char buf[256]; 1.12 unsigned int len, olen; 1.13 XGCValues gcv; 1.14 - XPoint points[5]; 1.15 XRectangle r = { dc.x, dc.y, dc.w, dc.h }; 1.16 1.17 - XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg); 1.18 + XSetForeground(dpy, dc.gc, col[ColBG]); 1.19 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); 1.20 - points[0].x = dc.x; 1.21 - points[0].y = dc.y; 1.22 - points[1].x = dc.w - 1; 1.23 - points[1].y = 0; 1.24 - points[2].x = 0; 1.25 - points[2].y = dc.h - 1; 1.26 - points[3].x = -(dc.w - 1); 1.27 - points[3].y = 0; 1.28 - points[4].x = 0; 1.29 - points[4].y = -(dc.h - 1); 1.30 - XSetForeground(dpy, dc.gc, dc.border); 1.31 - XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); 1.32 1.33 if(!text) 1.34 return; 1.35 @@ -74,15 +61,14 @@ 1.36 1.37 if(w > dc.w) 1.38 return; /* too long */ 1.39 - gcv.foreground = invert ? dc.bg : dc.fg; 1.40 - gcv.background = invert ? dc.fg : dc.bg; 1.41 + gcv.foreground = col[ColFG]; 1.42 if(dc.font.set) { 1.43 - XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv); 1.44 + XChangeGC(dpy, dc.gc, GCForeground, &gcv); 1.45 XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); 1.46 } 1.47 else { 1.48 gcv.font = dc.font.xfont->fid; 1.49 - XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv); 1.50 + XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv); 1.51 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); 1.52 } 1.53 if(highlight) { 1.54 @@ -108,21 +94,25 @@ 1.55 void 1.56 drawstatus() 1.57 { 1.58 + static const char *mode[] = { "~", "=" }; 1.59 int i, x; 1.60 - Bool istile = arrange == dotile; 1.61 1.62 dc.x = dc.y = 0; 1.63 dc.w = bw; 1.64 - drawtext(NULL, !istile, False); 1.65 + 1.66 + if(!modew) 1.67 + modew = textw(mode[0]) > textw(mode[1]) ? textw(mode[0]) : textw(mode[1]); 1.68 + drawtext(mode[arrange == dotile ? 1 : 0], dc.status, False); 1.69 1.70 dc.w = 0; 1.71 + dc.x = modew; 1.72 for(i = 0; i < ntags; i++) { 1.73 dc.x += dc.w; 1.74 dc.w = textw(tags[i]); 1.75 - if(istile) 1.76 - drawtext(tags[i], seltag[i], sel && sel->tags[i]); 1.77 + if(seltag[i]) 1.78 + drawtext(tags[i], dc.sel, sel && sel->tags[i]); 1.79 else 1.80 - drawtext(tags[i], !seltag[i], sel && sel->tags[i]); 1.81 + drawtext(tags[i], dc.norm, sel && sel->tags[i]); 1.82 } 1.83 x = dc.x + dc.w; 1.84 dc.w = textw(stext); 1.85 @@ -131,11 +121,11 @@ 1.86 dc.x = x; 1.87 dc.w = bw - x; 1.88 } 1.89 - drawtext(stext, !istile, False); 1.90 + drawtext(stext, dc.status, False); 1.91 1.92 if(sel && ((dc.w = dc.x - x) > bh)) { 1.93 dc.x = x; 1.94 - drawtext(sel->name, istile, False); 1.95 + drawtext(sel->name, dc.sel, False); 1.96 } 1.97 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); 1.98 XSync(dpy, False); 1.99 @@ -145,20 +135,19 @@ 1.100 drawtitle(Client *c) 1.101 { 1.102 int i; 1.103 - Bool istile = arrange == dotile; 1.104 1.105 if(c == sel && issel) { 1.106 drawstatus(); 1.107 XUnmapWindow(dpy, c->twin); 1.108 - XSetWindowBorder(dpy, c->win, dc.fg); 1.109 + XSetWindowBorder(dpy, c->win, dc.sel[ColBG]); 1.110 return; 1.111 } 1.112 1.113 - XSetWindowBorder(dpy, c->win, dc.bg); 1.114 + XSetWindowBorder(dpy, c->win, dc.norm[ColBG]); 1.115 XMapWindow(dpy, c->twin); 1.116 dc.x = dc.y = 0; 1.117 dc.w = c->tw; 1.118 - drawtext(c->name, !istile, False); 1.119 + drawtext(c->name, dc.norm, False); 1.120 XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0); 1.121 XSync(dpy, False); 1.122 }