]> Dogcows Code - chaz/openbox/commitdiff
add a Rect to the textures for positioning them
authorDerek Foreman <manmower@gmail.com>
Wed, 26 Mar 2003 02:19:38 +0000 (02:19 +0000)
committerDerek Foreman <manmower@gmail.com>
Wed, 26 Mar 2003 02:19:38 +0000 (02:19 +0000)
render/font.c
render/font.h
render/mask.c
render/mask.h
render/render.c

index d783d9d6000efafb9abc95f0b3f5db559e98cd0c..ee06caca861f9f6dee63917c31992787af5407e9 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <X11/Xft/Xft.h>
 #include <glib.h>
+#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;
index b5806a4ab559fa5c45594f076866370782c274bf..eaa89d56e04bf155203c161c788e7d7509e4cad0 100644 (file)
@@ -2,6 +2,7 @@
 #define __font_h
 #include <X11/Xft/Xft.h>
 #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 */
index 5f5aa263057dc30b0c2e6bf4b9b3778b4a1e7bc8..e1a18933143993a33a10676a93597830e58755f2 100644 (file)
@@ -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);
 
index 4d2144e2117b446b3ca3d87a640ca55fb2b629a6..323e82e32a7779fd9c2067d21a7db6370a20f34e 100644 (file)
@@ -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
index 397cebfaadc7dde9b7d490d2ac832847a4328223..25a79020bc68d7a34ef850d36ef978abc3240176 100644 (file)
@@ -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;
         }
     }
This page took 0.028315 seconds and 4 git commands to generate.