diff options
author | Thomas White <taw@bitwiz.org.uk> | 2014-01-16 21:42:48 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2014-01-16 21:42:48 +0100 |
commit | feff707efd0e5ca7225b8119319a9b8ab81064ec (patch) | |
tree | 3b48bc0462ddbca736b192a34101f0505687234a | |
parent | 52d339b66d1739635047c34206bb9fea71567e2b (diff) |
Handle frame size specified as fraction
-rw-r--r-- | src/sc_interp.c | 20 | ||||
-rw-r--r-- | tests/render_test_sc1.c | 2 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/sc_interp.c b/src/sc_interp.c index dcafd36..84d4ce4 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -268,7 +268,8 @@ static LengthUnits get_units(const char *t) } -static void parse_frame_option(struct frame *fr, const char *opt) +static void parse_frame_option(struct frame *fr, struct frame *parent, + const char *opt) { if ( (index(opt, 'x') != NULL) && (index(opt, '+') != NULL) && (index(opt, '+') != rindex(opt, '+')) ) @@ -305,6 +306,9 @@ static void parse_frame_option(struct frame *fr, const char *opt) return; } w_units = get_units(w); + if ( w_units == UNITS_FRAC ) { + fr->w = parent->w * fr->w; + } fr->h = strtod(h, &check); if ( check == h ) { @@ -312,7 +316,9 @@ static void parse_frame_option(struct frame *fr, const char *opt) return; } h_units = get_units(h); - /* FIXME: Handle units */ + if ( h_units == UNITS_FRAC ) { + fr->h = parent->h * fr->h; + } fr->x = strtod(x, &check); if ( check == x ) { @@ -329,7 +335,8 @@ static void parse_frame_option(struct frame *fr, const char *opt) } -static void parse_frame_options(struct frame *fr, const char *opth) +static void parse_frame_options(struct frame *fr, struct frame *parent, + const char *opth) { int i; size_t len; @@ -348,14 +355,14 @@ static void parse_frame_options(struct frame *fr, const char *opth) /* FIXME: comma might be escaped or quoted */ if ( opt[i] == ',' ) { opt[i] = '\0'; - parse_frame_option(fr, opt+start); + parse_frame_option(fr, parent, opt+start); start = i+1; } } if ( start != len ) { - parse_frame_option(fr, opt+start); + parse_frame_option(fr, parent, opt+start); } free(opt); @@ -416,7 +423,8 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) fprintf(stderr, "Failed to add frame.\n"); goto next; } - parse_frame_options(fr, options); + parse_frame_options(fr, sc_interp_get_frame(scin), + options); set_frame(scin, fr); } else { diff --git a/tests/render_test_sc1.c b/tests/render_test_sc1.c index 2382455..65efd7b 100644 --- a/tests/render_test_sc1.c +++ b/tests/render_test_sc1.c @@ -36,7 +36,7 @@ #include "../src/frame.h" -const char *sc = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. \\f[100ux100u+0+0]{\\bgcol[#ff00ff]Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros.} Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est."; +const char *sc = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. \\f[0.5fx1u+30+0]{\\bgcol[#ff00ff]Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros.} Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est."; static gint mw_destroy(GtkWidget *w, void *p) |