]> Dogcows Code - chaz/openbox/commitdiff
add function to give the minimum size of an appearance to fully render it's data
authorDana Jansens <danakj@orodu.net>
Sun, 6 Apr 2003 06:19:36 +0000 (06:19 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 6 Apr 2003 06:19:36 +0000 (06:19 +0000)
render/render.c
render/render.h

index 71bf7fa3323369e25a4558de34f11feca4b2ee35..0e4d244e9d86bc3e0333f038ce6ae8a6f34db8b4 100644 (file)
@@ -7,7 +7,7 @@
 #include "mask.h"
 #include "color.h"
 #include "image.h"
-#include "../kernel/openbox.h"
+#include "kernel/openbox.h"
 
 int render_depth;
 Visual *render_visual;
@@ -385,3 +385,43 @@ void pixel32_to_pixmap(pixel32 *in, Pixmap out, int x, int y, int w, int h)
     im->data = NULL;
     XDestroyImage(im);
 }
+
+void appearance_minsize(Appearance *l, Size *s)
+{
+    int i;
+    SIZE_SET(*s, 0, 0);
+
+    switch (l->surface.type) {
+    case Surface_Planar:
+        if (l->surface.data.planar.border ||
+            l->surface.data.planar.bevel == Bevel1)
+            SIZE_SET(*s, 2, 2);
+        else if (l->surface.data.planar.bevel == Bevel2)
+            SIZE_SET(*s, 4, 4);
+
+        for (i = 0; i < l->textures; ++i)
+            switch (l->texture[i].type) {
+            case Bitmask:
+                s->width += l->texture[i].data.mask.mask->w;
+                s->height += l->texture[i].data.mask.mask->h;
+                break;
+            case Text:
+                s->width +=font_measure_string(l->texture[i].data.text.font,
+                                               l->texture[i].data.text.string,
+                                               l->texture[i].data.text.shadow,
+                                               l->texture[i].data.text.offset);
+                s->height +=  font_height(l->texture[i].data.text.font,
+                                          l->texture[i].data.text.shadow,
+                                          l->texture[i].data.text.offset);
+                break;
+            case RGBA:
+                s->width += l->texture[i].data.rgba.width;
+                s->height += l->texture[i].data.rgba.height;
+                break;
+            case NoTexture:
+                break;
+            }            
+        break;
+    }
+    return s;
+}
index e282740ef44e06c1d89f6ed1a920c3b4b284b82b..1a41b219bcb77333a50c652221976b61f05e1bd5 100644 (file)
@@ -156,4 +156,6 @@ void truecolor_startup(void);
 void pseudocolor_startup(void);
 void pixel32_to_pixmap(pixel32 *in, Pixmap out, int x, int y, int w, int h);
 
+void appearance_minsize(Appearance *l, Size *s);
+
 #endif /*__render_h*/
This page took 0.025144 seconds and 4 git commands to generate.