add enough stuff to maybe start work on rendering code
authorDerek Foreman <foremande@gmail.com>
Wed, 19 May 2010 18:07:26 +0000 (14:07 -0400)
committerDerek Foreman <foremande@gmail.com>
Wed, 19 May 2010 18:07:26 +0000 (14:07 -0400)
main.c
obtheme.h
obtheme.l
obtheme.y
theme.obtheme

diff --git a/main.c b/main.c
index 9f19e52..8e7cbb9 100644 (file)
--- a/main.c
+++ b/main.c
@@ -41,6 +41,12 @@ static void decor_print(gpointer data, gpointer user_data)
        struct decor *decor = data;
        printf("    decor id %s\n", decor->name);
 printf("   anchor.x = %f\n", expression_eval(&decor->space.anchor.x));
+       if (decor->texture.present) {
+               if (decor->texture.internal)
+                       printf("    texture internal: %s\n", decor->texture.name);
+               else
+                       printf("    texture file: %s\n", decor->texture.name);
+       }
 //     printf("      anchor (%d %d %d)\n", decor->space.anchor.x, decor->space.anchor.y, decor->space.anchor.z);
 //     printf("      up     (%d %d %d)\n", decor->space.up.x, decor->space.up.y, decor->space.up.z);
        if (decor->children)
index 9a4faf7..1c15dd1 100644 (file)
--- a/obtheme.h
+++ b/obtheme.h
@@ -67,12 +67,30 @@ struct space {
        struct vector up;
 };
 
+struct texture {
+       gboolean present;
+       gboolean internal;
+       char *name;
+};
+
+struct box {
+       struct vector start;
+       struct vector end;
+};
+
+struct geometry {
+       struct box box;
+};
+
 struct decor {
        char *name;
        GSList *children;
        struct space space;
        ObDirection cursor;
        ObFrameContext context;
+       struct texture texture;
+       struct material *material;
+       struct geometry geometry;
 };
 
 struct parser_control {
index 364fb3f..0806e10 100644 (file)
--- a/obtheme.l
+++ b/obtheme.l
@@ -124,6 +124,9 @@ anchor                      return ANCHOR;
 opacity                        return OPACITY;
 shapeof                        return SHAPEOF;
 texture                        return TEXTURE;
+image                  return IMAGE;
+to                     return TO;
+box                    return BOX;
 NORTH                  return NORTH;
 NORTHEAST              return NORTHEAST;
 EAST                   return EAST;
index ffcf862..80331e7 100644 (file)
--- a/obtheme.y
+++ b/obtheme.y
@@ -128,19 +128,23 @@ struct expression *exdup(struct expression in)
        RrSurfaceColorType gradient;
        struct expression expr;
        struct variable var;
+       struct texture tex;
+       struct material *matptr;
+       struct box box;
+       struct geometry geometry;
 }
 
 %token NORTH NORTHEAST EAST SOUTHEAST SOUTH SOUTHWEST
 %token WEST NORTHWEST NONE UNCHANGED
-%token LCB RCB LB RB
+%token LCB RCB LB RB TO
 %token LEFT_ARROW RIGHT_ARROW DOUBLE_ARROW
 %token SEMICOLON AT COLON DEFAULT NOT
-%token PLUS MINUS STAR SLASH COMMA
+%token PLUS MINUS STAR SLASH COMMA BOX
 %token <string> STRING ID
 %token <integer> NUMBER SUBST BULK BIG LITTLE
 %token THEME FRAME SPACE GEOMETRY MATERIAL GRADIENT
 %token CONTEXT CURSOR UP ANCHOR STYLE TEXTURE OPACITY
-%token SHAPEOF DECOR DOT
+%token SHAPEOF DECOR DOT IMAGE
 %type <decor> decor
 %type <decor> decoritems styleitem
 %type <space> space
@@ -155,7 +159,10 @@ struct expression *exdup(struct expression in)
 %type <gradient> gradient
 %type <expr> expression
 %type <var> variable
-
+%type <tex> texture image texitems
+%type <matptr> material_use
+%type <box> box
+%type <geometry> geometry geometry_item
 %left PLUS MINUS
 %left STAR SLASH
 %left LB
@@ -234,15 +241,25 @@ space             : SPACE LCB spaceconstraints RCB {
 shape          : SHAPEOF LB ID RB
                ;
 
+box            : BOX LB expression COMMA expression COMMA expression RB TO
+                  LB expression COMMA expression COMMA expression RB {
+                       
+               }
+               ;
+
 geometry_item  : /* empty */
                | shape
+               | box { $$.box = $1; }
                ;
 
-geometry       : GEOMETRY LCB geometry_item RCB
+geometry       : GEOMETRY LCB geometry_item RCB {
+                       $$ = $3;
+               }
                ;
 
 material_use   : MATERIAL LB ID RB {
-                       if (g_hash_table_lookup(pc->target->materials, $3) == NULL) {
+                       $$ = g_hash_table_lookup(pc->target->materials, $3);
+                       if ($$ == NULL) {
                                snprintf(pc->error_buf, 4000, "No definition for material '%s'\n", $3);
                                obthemeerror(pc, pc->error_buf);
                                return 1;
@@ -293,6 +310,8 @@ decoritems  : /* empty */ {
                        $$.space.up.y.v.number = 1;
                        $$.space.up.z.op = OB_THEME_EQL;
                        $$.space.up.z.v.number = 1;
+                       $$.texture.present = 0;
+                       $$.material = NULL;
                }
                | decoritems decor {
                        struct decor *out = malloc(sizeof(struct decor));
@@ -301,11 +320,11 @@ decoritems        : /* empty */ {
                        $$.children = g_slist_append($1.children, out);
                }
                | decoritems space { $1.space = $2; $$ = $1; }
-               | decoritems material_use
-               | decoritems geometry
-               | decoritems texture
-               | decoritems context { $1.context = $2; }
-               | decoritems cursor { $1.cursor = $2; }
+               | decoritems material_use { $1.material = $2; $$ = $1; }
+               | decoritems geometry { $1.geometry = $2; $$ = $1;}
+               | decoritems texture { $1.texture = $2; $$ = $1; } //XXX multitexture?
+               | decoritems context { $1.context = $2; $$ = $1; }
+               | decoritems cursor { $1.cursor = $2; $$ = $1; }
                ;
 
                ;
@@ -316,7 +335,22 @@ decor              : DECOR ID LCB decoritems RCB {
                }
                ;
 
-texture                : TEXTURE LCB RCB
+image          : IMAGE LB STRING RB {
+                       $$.present = 1;
+                       $$.internal = 0;
+                       $$.name = $3;
+               }
+               | IMAGE LB ID RB {
+                       $$.present = 1;
+                       $$.internal = 1;
+                       $$.name = $3;
+               }
+               ;
+
+texitems       : image { $$ = $1; }
+               ;
+
+texture                : TEXTURE LCB texitems RCB { $$ = $3; }
                ;
 
 context                : CONTEXT LB ID RB {
index ced4738..3bc8496 100644 (file)
@@ -18,30 +18,35 @@ theme awesome {
        style regular_window {
                decor clientwindow {
                        space {
-                               anchor(1 + client.width + 1/3* 9/2, 0, 0)
+                               anchor(0, 0, 0)
                                up(0, 0, 0)
                        }
                        geometry {
                                shapeof(client)
                        }
                        material(flat)
-                       texture { //$CLIENT.contents
+                       texture {
+                               image(client)
                        }
 
                        decor titlebar {
                                context(titlebar)
                                geometry {
-                               //      box (0, 0, 0) to (.1 * client.width / (4/client.width), 100%, 0)
+                                       box (0, 0, 0) to (client.width, font.height + 5, 0)
                                }
                                material(flat)
-//texture {
+
                                decor title {
                                        geometry {
+                                               box (client.width / 4, font.height + 5, 0) to (3*client.width / 4, font.height + 5, 0)
 //                                             text(client.title)
 //                                             justify(center)
                                        }
                                }
                                decor minbutton {
+                                       geometry {
+                                               box (0, 0, 0) to (10, 10, 0)
+                                       }
                                        material(none)
                                        context(minimize)
                                }