#include <unistd.h>
#include "frame.h"
#include "misc.h"
+#include "render.h"
#include "obtheme.h"
#include "obtheme.tab.h"
return -1;
}
+struct gradient_table_item {
+ char *name;
+ RrSurfaceColorType val;
+};
+
+struct gradient_table_item gradients[RR_SURFACE_NUM_TYPES] = {
+ {"none", RR_SURFACE_NONE},
+ {"parentrel", RR_SURFACE_PARENTREL},
+ {"solid", RR_SURFACE_SOLID},
+ {"split", RR_SURFACE_SPLIT_VERTICAL},
+ {"horizontal", RR_SURFACE_HORIZONTAL},
+ {"vertical", RR_SURFACE_VERTICAL},
+ {"diagonal", RR_SURFACE_DIAGONAL},
+ {"cross_diagonal", RR_SURFACE_CROSS_DIAGONAL},
+ {"pyramid", RR_SURFACE_PYRAMID},
+ {"mirror_horizontal", RR_SURFACE_MIRROR_HORIZONTAL},
+};
+
+static RrSurfaceColorType gradient_from_string(char *str)
+{
+ int i;
+
+ for (i = 0; i < RR_SURFACE_NUM_TYPES; i++)
+ if (strcmp(gradients[i].name, str) == 1)
+ return gradients[i].val;
+
+ return -1;
+}
+
struct parser_control *parser_init(struct obthemedata *otd)
{
struct parser_control *out;
struct vector vector;
ObCursor dir;
ObFrameContext context;
+ RrSurfaceColorType gradient;
}
%token NORTH NORTHEAST EAST SOUTHEAST SOUTH SOUTHWEST
%type <vector> up anchor
%type <dir> cursor
%type <context> context
+%type <gradient> gradient
%%
theme_object : material_decl
;
material_props : /* empty */ { memset(&$$, 0, sizeof($$)); }
- | material_props opacity {
- $$ = $1;
- $$.opacity = $2;
- }
+ | material_props opacity { $$ = $1; $$.opacity = $2;}
+ | material_props gradient
;
material_decl : MATERIAL ID LCB material_props RCB {
| decoritems geometry
| decoritems texture
| decoritems context { $1.context = $2; }
- | decoritems gradient
| decoritems cursor { $1.cursor = $2; }
;
// | CURSOR LB NONE RB { $$ = OB_CURSOR_NORTHEAST; }
| CURSOR LB UNCHANGED RB { $$ = OB_CURSOR_NONE; }
;
-gradient : GRADIENT LB ID RB
+gradient : GRADIENT LB ID RB {
+ $$ = gradient_from_string($3);
+ if ($$ == -1) {
+ snprintf(pc->error_buf, 4000, "No gradient named '%s'\n", $3);
+ obthemeerror(pc, pc->error_buf);
+ return 1;
+ }
+ }
;
%%