From 55c566558b168b434e955dbefca4745c3a4932a2 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 21 Nov 2017 22:32:42 +0100 Subject: Calculate image sizes to fill frames horizontally --- src/sc_interp.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/sc_interp.c') diff --git a/src/sc_interp.c b/src/sc_interp.c index b4ec7cd..b530941 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -723,20 +723,29 @@ static int parse_dims(const char *opt, struct frame *parent, if ( check == w ) goto invalid; w_units = get_units(w); if ( w_units == UNITS_FRAC ) { - double pw = parent->w; - pw -= parent->pad_l; - pw -= parent->pad_r; - *wp = pw * *wp; + if ( parent != NULL ) { + double pw = parent->w; + pw -= parent->pad_l; + pw -= parent->pad_r; + *wp = pw * *wp; + } else { + *wp = -1.0; + } + } *hp = strtod(h, &check); if ( check == h ) goto invalid; h_units = get_units(h); if ( h_units == UNITS_FRAC ) { - double ph = parent->h; - ph -= parent->pad_t; - ph -= parent->pad_b; - *hp = ph * *hp; + if ( parent != NULL ) { + double ph = parent->h; + ph -= parent->pad_t; + ph -= parent->pad_b; + *hp = ph * *hp; + } else { + *hp = -1.0; + } } *xp= strtod(x, &check); @@ -810,7 +819,7 @@ static int parse_image_option(const char *opt, struct frame *parent, if ( (index(opt, 'x') != NULL) && (index(opt, '+') != NULL) && (index(opt, '+') != rindex(opt, '+')) ) { double dum; - return parse_dims(opt, parent, wp, hp, &dum, &dum); + return parse_dims(opt, NULL, wp, hp, &dum, &dum); } if ( strncmp(opt, "filename=\"", 10) == 0 ) { -- cgit v1.2.3