diff options
author | Thomas White <taw@bitwiz.org.uk> | 2014-01-16 22:33:48 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2014-01-16 22:33:48 +0100 |
commit | bc49b9f3fd00ebc3bd62a51bb2321822618e838d (patch) | |
tree | d69e0054c78641b78172b420c51f026b7e1c0e65 /src | |
parent | feff707efd0e5ca7225b8119319a9b8ab81064ec (diff) |
Frame geometry
Diffstat (limited to 'src')
-rw-r--r-- | src/frame.h | 3 | ||||
-rw-r--r-- | src/render.c | 15 | ||||
-rw-r--r-- | src/sc_interp.c | 35 |
3 files changed, 42 insertions, 11 deletions
diff --git a/src/frame.h b/src/frame.h index 8431836..f71794b 100644 --- a/src/frame.h +++ b/src/frame.h @@ -65,6 +65,9 @@ struct frame double pad_l; double pad_r; + /* Background properties for this frame */ + double bgcol[4]; + /* True if this frame should be deleted on the next mouse click */ int empty; diff --git a/src/render.c b/src/render.c index 65d1601..4509152 100644 --- a/src/render.c +++ b/src/render.c @@ -255,19 +255,16 @@ static void render_lines(struct frame *fr, cairo_t *cr, ImageStore *is, } } -#if 0 - GdkRGBA col; - - if ( b->contents == NULL ) continue; - gdk_rgba_parse(&col, b->contents); - cairo_rectangle(cr, 0, 0, fr->w, fr->h); - gdk_cairo_set_source_rgba(cr, &col); - cairo_fill(cr); -#endif static int draw_frame(cairo_t *cr, struct frame *fr, ImageStore *is, enum is_size isz) { + cairo_new_path(cr); + cairo_rectangle(cr, 0.0, 0.0, fr->w, fr->h); + cairo_set_source_rgba(cr, fr->bgcol[0], fr->bgcol[1], fr->bgcol[2], + fr->bgcol[3]); + cairo_fill(cr); + if ( fr->trouble ) { cairo_new_path(cr); cairo_rectangle(cr, 0.0, 0.0, fr->w, fr->h); diff --git a/src/sc_interp.c b/src/sc_interp.c index 84d4ce4..9fd6b24 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -149,6 +149,28 @@ static void set_colour(SCInterpreter *scin, const char *colour) } +static void set_frame_bgcolour(struct frame *fr, const char *colour) +{ + GdkRGBA col; + + if ( colour == NULL ) { + printf("Invalid colour\n"); + fr->bgcol[0] = 0.0; + fr->bgcol[1] = 0.0; + fr->bgcol[2] = 0.0; + fr->bgcol[3] = 1.0; + return; + } + + gdk_rgba_parse(&col, colour); + + fr->bgcol[0] = col.red; + fr->bgcol[1] = col.green; + fr->bgcol[2] = col.blue; + fr->bgcol[3] = col.alpha; +} + + void sc_interp_save(SCInterpreter *scin) { if ( scin->j+1 == scin->max_state ) { @@ -307,7 +329,10 @@ static void parse_frame_option(struct frame *fr, struct frame *parent, } w_units = get_units(w); if ( w_units == UNITS_FRAC ) { - fr->w = parent->w * fr->w; + double pw = parent->w; + pw -= parent->pad_l; + pw -= parent->pad_r; + fr->w = pw * fr->w; } fr->h = strtod(h, &check); @@ -317,7 +342,10 @@ static void parse_frame_option(struct frame *fr, struct frame *parent, } h_units = get_units(h); if ( h_units == UNITS_FRAC ) { - fr->h = parent->h * fr->h; + double ph = parent->h; + ph -= parent->pad_t; + ph -= parent->pad_b; + fr->h = ph * fr->h; } fr->x = strtod(x, &check); @@ -392,6 +420,9 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) } else if ( strcmp(name, "fgcol") == 0 ) { set_colour(scin, options); + } else if ( strcmp(name, "bgcol") == 0 ) { + set_frame_bgcolour(sc_interp_get_frame(scin), options); + #if 0 } else if ( strcmp(name, "image")==0 ) { int w, h; |