aboutsummaryrefslogtreecommitdiffstats
path: root/draw.c
diff options
context:
space:
mode:
authorgotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2>2007-12-22 10:24:06 +0000
committergotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2>2007-12-22 10:24:06 +0000
commit8267971cf3e888709413ece5cfd1f73e360a7753 (patch)
treefe68d52c14918377708e381f6bcb32e39dbb009f /draw.c
parent709e2fada94d97c5d933eed57043cbb6b6ecfbc1 (diff)
downloaddzen-8267971cf3e888709413ece5cfd1f73e360a7753.tar.gz
dzen-8267971cf3e888709413ece5cfd1f73e360a7753.zip
fixed bug in recty calculation
git-svn-id: http://dzen.googlecode.com/svn/trunk@176 f2baff5b-bf2c-0410-a398-912abdc3d8b2
Diffstat (limited to 'draw.c')
-rw-r--r--draw.c54
1 files changed, 38 insertions, 16 deletions
diff --git a/draw.c b/draw.c
index 7dfd47f..14cf1d0 100644
--- a/draw.c
+++ b/draw.c
@@ -215,20 +215,20 @@ get_rect_vals(char *s, int *w, int *h, int *x, int *y) {
int i, j;
char buf[128];
- *w = 0; *h = 0; *x=~0; *y=~0;
+ *w = 0; *h = 0; *x=0; *y=0;
- for(i=0; (s[i] != 'x') && i<128; i++) {
+ for(i=0; s[i] && s[i] != 'x' && i<128; i++) {
buf[i] = s[i];
}
buf[i] = '\0';
*w = atoi(buf);
- for(j=0, i++; s[i] != '+' && s[i] != '-' && j<128; j++, i++)
+ for(j=0, ++i; s[i] && s[i] != '+' && s[i] != '-' && j<128; j++, i++)
buf[j] = s[i];
buf[j] = '\0';
*h = atoi(buf);
- for(j=0, i++; s[i] != '+' && s[i] != '-' && j<128; j++, i++)
+ for(j=0, ++i; s[i] && s[i] != '+' && s[i] != '-' && j<128; j++, i++)
buf[j] = s[i];
if(j<2) {
buf[j] = '\0';
@@ -366,10 +366,11 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
case rect:
get_rect_vals(tval, &rectw, &recth, &rectx, &recty);
- rectw = rectw+px > dzen.w ? dzen.w-px : rectw;
+ //rectw = rectw+px > dzen.w ? dzen.w-px : rectw;
recth = recth > dzen.line_height ? dzen.line_height : recth;
- recty = recty == ~0 ? (dzen.line_height - recth)/2 : recty;
- px = (rectx == ~0) ? px : rectx+px;
+ recty = (recty == 0) ? (dzen.line_height - recth)/2 : recty;
+ px = (rectx == 0) ? px : rectx+px;
+ printf("rect1: w=%d h=%d x=%d y=%d\n", rectw, recth, rectx, recty);
setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg);
XFillRectangle(dzen.dpy, pm, dzen.tgc, (int)px, (int)recty<0 ? dzen.line_height + recty : recty, rectw, recth);
@@ -380,10 +381,10 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
get_rect_vals(tval, &rectw, &recth, &rectx, &recty);
if (!rectw) break;
- rectw = rectw+px > dzen.w ? dzen.w-px : rectw;
+ //rectw = rectw+px > dzen.w ? dzen.w-px : rectw;
recth = recth > dzen.line_height ? dzen.line_height-2 : recth-1;
- recty = recty == ~0 ? (dzen.line_height - recth)/2 : recty;
- px = (rectx == ~0) ? px : rectx+px;
+ recty = recty == 0 ? (dzen.line_height - recth)/2 : recty;
+ px = (rectx == 0) ? px : rectx+px;
/* prevent from stairs effect when rounding recty */
if (!((dzen.line_height - recth) % 2)) recty--;
setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg);
@@ -510,10 +511,11 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
case rect:
get_rect_vals(tval, &rectw, &recth, &rectx, &recty);
- rectw = rectw+px > dzen.w ? dzen.w-px : rectw;
+ //rectw = rectw+px > dzen.w ? dzen.w-px : rectw;
recth = recth > dzen.line_height ? dzen.line_height : recth;
- recty = (recty == ~0) ? (dzen.line_height - recth)/2 : recty;
- px = (rectx == ~0) ? px : rectx+px;
+ recty = (recty == 0) ? (dzen.line_height - recth)/2 : recty;
+ px = (rectx == 0) ? px : rectx+px;
+ printf("rect2: w=%d h=%d x=%d y=%d\n", rectw, recth, rectx, recty);
setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg);
XFillRectangle(dzen.dpy, pm, dzen.tgc, (int)px, (int)recty<0 ? dzen.line_height + recty : recty, rectw, recth);
@@ -524,10 +526,10 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
get_rect_vals(tval, &rectw, &recth, &rectx, &recty);
if (!rectw) break;
- rectw = rectw+px > dzen.w ? dzen.w-px : rectw;
+ //rectw = rectw+px > dzen.w ? dzen.w-px : rectw;
recth = recth > dzen.line_height ? dzen.line_height-2 : recth-1;
- recty = recty == ~0 ? (dzen.line_height - recth)/2 : recty;
- px = (rectx == ~0) ? px : rectx+px;
+ recty = recty == 0 ? (dzen.line_height - recth)/2 : recty;
+ px = (rectx == 0) ? px : rectx+px;
/* prevent from stairs effect when rounding recty */
if (!((dzen.line_height - recth) % 2)) recty--;
setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg);
@@ -606,12 +608,31 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
XDrawString(dzen.dpy, pm, dzen.tgc, px, py, lbuf, strlen(lbuf));
px += tw;
+ /* expand/shrink dynamically */
+ /*
+ i = px;
+ if(lnr == -1)
+ XResizeWindow(dzen.dpy, dzen.title_win.win, px, dzen.line_height);
if(align == ALIGNLEFT)
xorig = 0;
if(align == ALIGNCENTER) {
xorig = (lnr != -1) ?
(dzen.slave_win.width - px)/2 :
+ (i - px)/2;
+ }
+ else if(align == ALIGNRIGHT) {
+ xorig = (lnr != -1) ?
+ (dzen.slave_win.width - px) :
+ (i - px)/2;
+ }
+ */
+
+ if(align == ALIGNLEFT)
+ xorig = 0;
+ if(align == ALIGNCENTER) {
+ xorig = (lnr != -1) ?
+ (dzen.slave_win.width - px)/2 :
(dzen.title_win.width - px)/2;
}
else if(align == ALIGNRIGHT) {
@@ -619,6 +640,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
(dzen.slave_win.width - px) :
(dzen.title_win.width - px);
}
+
if(lnr != -1) {
XCopyArea(dzen.dpy, pm, dzen.slave_win.drawable[lnr], dzen.gc,