From 2880e674eaa66b2d5639157e4506b404e2b183ad Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Wed, 26 Mar 2003 02:19:38 +0000 Subject: [PATCH] add a Rect to the textures for positioning them --- render/font.c | 9 ++++++++- render/font.h | 3 ++- render/mask.c | 10 +++++++--- render/mask.h | 3 ++- render/render.c | 6 ++++-- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/render/font.c b/render/font.c index d783d9d6..ee06caca 100644 --- a/render/font.c +++ b/render/font.c @@ -6,6 +6,7 @@ #include #include +#include "../kernel/geom.h" void font_startup(void) { @@ -91,10 +92,16 @@ int font_max_char_width(ObFont *f) return (signed) f->xftfont->max_advance_width; } -void font_draw(XftDraw *d, TextureText *t, int x, int y, int w, int h) +void font_draw(XftDraw *d, TextureText *t, Rect *position) { + int x,y,w,h; XftColor c; + x = position->x; + y = position->y; + w = position->width; + h = position->height; + /* accomidate for areas bigger/smaller than Xft thinks the font is tall */ y -= (2 * (t->font->xftfont->ascent + t->font->xftfont->descent) - (t->font->height + h) - 1) / 2; diff --git a/render/font.h b/render/font.h index b5806a4a..eaa89d56 100644 --- a/render/font.h +++ b/render/font.h @@ -2,6 +2,7 @@ #define __font_h #include #include "render.h" +#include "../kernel/geom.h" void font_startup(void); ObFont *font_open(char *fontstring); @@ -9,5 +10,5 @@ void font_close(ObFont *f); int font_measure_string(ObFont *f, char *str, int shadow, int offset); int font_height(ObFont *f, int shadow, int offset); int font_max_char_width(ObFont *f); -void font_draw(XftDraw *d, TextureText *t, int x, int y, int w, int h); +void font_draw(XftDraw *d, TextureText *t, Rect *position); #endif /* __font_h */ diff --git a/render/mask.c b/render/mask.c index 5f5aa263..e1a18933 100644 --- a/render/mask.c +++ b/render/mask.c @@ -16,14 +16,18 @@ void pixmap_mask_free(pixmap_mask *m) g_free(m); } -void mask_draw(Pixmap p, TextureMask *m, int width, int height) +void mask_draw(Pixmap p, TextureMask *m, Rect *position) { int x, y; if (m->mask == None) return; /* no mask given */ /* set the clip region */ - x = (width - m->mask->w) / 2; - y = (height - m->mask->h) / 2; + x = position->x + (position->width - m->mask->w) / 2; + y = position->y + (position->height - m->mask->h) / 2; + + if (x < 0) x = 0; + if (y < 0) y = 0; + XSetClipMask(ob_display, m->color->gc, m->mask->mask); XSetClipOrigin(ob_display, m->color->gc, x, y); diff --git a/render/mask.h b/render/mask.h index 4d2144e2..323e82e3 100644 --- a/render/mask.h +++ b/render/mask.h @@ -2,9 +2,10 @@ #define __mask_h #include "render.h" +#include "../kernel/geom.h" pixmap_mask *pixmap_mask_new(int w, int h, char *data); void pixmap_mask_free(pixmap_mask *m); -void mask_draw(Pixmap p, TextureMask *m, int width, int height); +void mask_draw(Pixmap p, TextureMask *m, Rect *position); #endif diff --git a/render/render.c b/render/render.c index 397cebfa..25a79020 100644 --- a/render/render.c +++ b/render/render.c @@ -136,12 +136,14 @@ void x_paint(Window win, Appearance *l, int x, int y, int w, int h) l->xftdraw = XftDrawCreate(ob_display, l->pixmap, render_visual, render_colormap); } - font_draw(l->xftdraw, &l->texture[i].data.text, x, y, w, h); + font_draw(l->xftdraw, &l->texture[i].data.text, + &l->texture[i].position); break; case Bitmask: if (l->texture[i].data.mask.color->gc == None) color_allocate_gc(l->texture[i].data.mask.color); - mask_draw(l->pixmap, &l->texture[i].data.mask, w, h); + mask_draw(l->pixmap, &l->texture[i].data.mask, + &l->texture[i].position); break; } } -- 2.39.2