From 9ee3bd246ec4b59e75a147cc3357f1a51e54817f Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Wed, 19 May 2010 14:07:26 -0400 Subject: [PATCH] add enough stuff to maybe start work on rendering code --- main.c | 6 ++++++ obtheme.h | 18 ++++++++++++++++ obtheme.l | 3 +++ obtheme.y | 58 ++++++++++++++++++++++++++++++++++++++++----------- theme.obtheme | 13 ++++++++---- 5 files changed, 82 insertions(+), 16 deletions(-) diff --git a/main.c b/main.c index 9f19e52..8e7cbb9 100644 --- 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) diff --git a/obtheme.h b/obtheme.h index 9a4faf7..1c15dd1 100644 --- 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 { diff --git a/obtheme.l b/obtheme.l index 364fb3f..0806e10 100644 --- 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; diff --git a/obtheme.y b/obtheme.y index ffcf862..80331e7 100644 --- 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 ID %token 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 %type decoritems styleitem %type space @@ -155,7 +159,10 @@ struct expression *exdup(struct expression in) %type gradient %type expression %type variable - +%type texture image texitems +%type material_use +%type box +%type 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 { diff --git a/theme.obtheme b/theme.obtheme index ced4738..3bc8496 100644 --- a/theme.obtheme +++ b/theme.obtheme @@ -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) } -- 2.34.1