aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2018-10-17 15:28:59 +0200
committerThomas White <taw@bitwiz.me.uk>2018-10-17 15:28:59 +0200
commitd7cf85134ea2559de04fbb094b1308b80e51f336 (patch)
tree0f9c6cb8969f6d9b467e4076d328a1a211c71b33
parent51e1d39d8eaaf02f23ed0b83695e0294a23496bb (diff)
Initial style lookup
-rw-r--r--src/sc_interp.c26
-rw-r--r--stylesheet.json56
-rw-r--r--tests/meson.build7
3 files changed, 82 insertions, 7 deletions
diff --git a/src/sc_interp.c b/src/sc_interp.c
index ed49597..b603c61 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -1085,6 +1085,27 @@ static int check_outputs(SCBlock *bl, SCInterpreter *scin, Stylesheet *ss)
}
+static void apply_style(SCInterpreter *scin, Stylesheet *ss, const char *path)
+{
+ char fullpath[256];
+ size_t len;
+ char *bgcol1;
+
+ len = strlen(path);
+ if ( len > 160 ) {
+ fprintf(stderr, "Can't apply style: path too long.\n");
+ return;
+ }
+
+ strcpy(fullpath, path);
+ strcat(fullpath, ".bggradv");
+ bgcol1 = stylesheet_lookup(ss, fullpath);
+ set_bggrad(scin, bgcol1, GRAD_VERT);
+
+ update_bg(scin);
+}
+
+
int sc_interp_add_block(SCInterpreter *scin, SCBlock *bl, Stylesheet *ss)
{
const char *name = sc_block_name(bl);
@@ -1107,10 +1128,7 @@ int sc_interp_add_block(SCInterpreter *scin, SCBlock *bl, Stylesheet *ss)
} else if ( strcmp(name, "presentation") == 0 ) {
maybe_recurse_before(scin, child);
- set_bgcol(scin, "#ff00ff");
- update_bg(scin);
- printf("pres\n");
- /* FIXME: Apply narrative style */
+ apply_style(scin, ss, "$.narrative");
maybe_recurse_after(scin, child, ss);
} else if ( strcmp(name, "slide") == 0 ) {
diff --git a/stylesheet.json b/stylesheet.json
new file mode 100644
index 0000000..518c21b
--- /dev/null
+++ b/stylesheet.json
@@ -0,0 +1,56 @@
+{
+ "narrative": {
+ "font": "Comfortaa 20",
+ "fgcol": "#000000",
+ "bggradv": "#729fcf,#d3d7cf"
+ },
+
+ "slide": {
+ "width": 1280,
+ "height": 720,
+ "bggrad": "vertical",
+ "bgcol1": "#729fcf",
+ "bgcol2": "#d3d7cf",
+ "frame": {
+ "font": "Comfortaa 20"
+ },
+ "slidetitle": {
+ "width": "1f",
+ "height": "90u",
+ "posx": 0,
+ "posy": 0,
+ "padl": 30,
+ "padr": 30,
+ "padt": 30,
+ "padb": 30,
+ "fgcol": "#000000",
+ "font": "Comfortaa Bold 40"
+ },
+ "prestitle": {
+ "width": "1f",
+ "height": "240u",
+ "posx": 0,
+ "posy": 160,
+ "padl": 50,
+ "padr": 50,
+ "padt": 50,
+ "padb": 50,
+ "fgcol": "#000000",
+ "font": "Comfortaa Bold 45",
+ "alignment": "center"
+ },
+ "author": {
+ "width": "1f",
+ "height": "240u",
+ "posx": 0,
+ "posy": 360,
+ "padl": 80,
+ "padr": 80,
+ "padt": 80,
+ "padb": 80,
+ "fgcol": "#000000",
+ "font": "Comfortaa 20",
+ "alignment": "center"
+ }
+ }
+}
diff --git a/tests/meson.build b/tests/meson.build
index c919e35..dee9a47 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,17 +1,18 @@
basic_rendering = ['../src/render.c', '../src/frame.c',
'../src/sc_parse.c', '../src/imagestore.c',
- '../src/sc_interp.c', '../src/utils.c']
+ '../src/sc_interp.c', '../src/utils.c',
+ '../src/stylesheet.c']
e = executable('storycode_test', 'storycode_test.c', '../src/sc_parse.c',
dependencies : [gtkdep])
test('Simple StoryCode parsing', e)
e = executable('render_test', 'render_test.c', basic_rendering,
- dependencies : [gtkdep, mdep])
+ dependencies : [gtkdep, mdep, jsondep])
test('Simple rendering', e)
e = executable('render_test_sc1', 'render_test_sc1.c', basic_rendering,
- dependencies : [gtkdep, mdep])
+ dependencies : [gtkdep, mdep, jsondep])
test('Simple StoryCode rendering', e)
e = executable('json_test', 'json_test.c', '../src/sc_parse.c',