]> Dogcows Code - chaz/openbox/blobdiff - render/render.c
add the left/right/top/bottom direction arrows and use them for resizing those ways
[chaz/openbox] / render / render.c
index e4cc97e7fcc79c123572382463e5dfd1ca9eb5bb..cd4607bbd465d696d1d897aadfff8e229be54033 100644 (file)
@@ -197,6 +197,7 @@ void x_paint(Window win, Appearance *l)
     int y = l->area.y;
     int w = l->area.width;
     int h = l->area.height;
+    Rect tarea; /* area in which to draw textures */
 
     if (w <= 0 || h <= 0 || x+w <= 0 || y+h <= 0) return;
 
@@ -231,6 +232,23 @@ void x_paint(Window win, Appearance *l)
     else gradient_render(&l->surface, w, h);
 
     for (i = 0; i < l->textures; i++) {
+        tarea = l->texture[i].position;
+        if (l->surface.data.planar.relief != Flat) {
+            switch (l->surface.data.planar.bevel) {
+            case Bevel1:
+                tarea.x += 1; tarea.y += 1;
+                tarea.width -= 2; tarea.height -= 2;
+                break;
+            case Bevel2:
+                tarea.x += 2; tarea.y += 2;
+                tarea.width -= 4; tarea.height -= 4;
+                break;
+            }
+        } else if (l->surface.data.planar.border) {
+            tarea.x += 1; tarea.y += 1;
+            tarea.width -= 2; tarea.height -= 2;
+        }
+
         switch (l->texture[i].type) {
         case Text:
             if (!transferred) {
@@ -244,7 +262,7 @@ void x_paint(Window win, Appearance *l)
                                         render_visual, render_colormap);
             }
             font_draw(l->xftdraw, &l->texture[i].data.text, 
-                      &l->texture[i].position);
+                      &tarea);
         break;
         case Bitmask:
             if (!transferred) {
@@ -256,12 +274,12 @@ void x_paint(Window win, Appearance *l)
             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,
-                      &l->texture[i].position);
+                      &tarea);
         break;
         case RGBA:
             image_draw(l->surface.data.planar.pixel_data, 
                        &l->texture[i].data.rgba,
-                       &l->texture[i].position);
+                       &tarea);
         break;
         }
     }
@@ -398,37 +416,43 @@ void pixel32_to_pixmap(pixel32 *in, Pixmap out, int x, int y, int w, int h)
     free(scratch);
 }
 
-void appearance_minsize(Appearance *l, Size *s)
+void appearance_minsize(Appearance *l, int *w, int *h)
 {
     int i;
-    SIZE_SET(*s, 0, 0);
+    *w = *h = 1;
 
     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);
+        if (l->surface.data.planar.relief != Flat) {
+            switch (l->surface.data.planar.bevel) {
+            case Bevel1:
+                *w = *h = 2;
+                break;
+            case Bevel2:
+                *w = *h = 4;
+                break;
+            }
+        } else if (l->surface.data.planar.border)
+            *w = *h = 2;
 
         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;
+                *w += l->texture[i].data.mask.mask->w;
+                *h += 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);
+                *w +=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);
+                *h +=  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;
+                *w += l->texture[i].data.rgba.width;
+                *h += l->texture[i].data.rgba.height;
                 break;
             case NoTexture:
                 break;
This page took 0.024067 seconds and 4 git commands to generate.