diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-04-22 22:06:42 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-04-22 22:06:42 +0200 |
commit | 044b25bb359c4b3254b947ca34a1491f5eb9f901 (patch) | |
tree | 0fe851a5bfdaf6552c7ea0b07450be3446861944 /src | |
parent | 2c85156b2bc8b68502b47c250bd4902ff6449c95 (diff) |
Add SCBlock to image and callback paragraphs
Diffstat (limited to 'src')
-rw-r--r-- | src/frame.c | 9 | ||||
-rw-r--r-- | src/frame.h | 6 | ||||
-rw-r--r-- | src/sc_interp.c | 4 |
3 files changed, 13 insertions, 6 deletions
diff --git a/src/frame.c b/src/frame.c index f275baf..744f85d 100644 --- a/src/frame.c +++ b/src/frame.c @@ -64,6 +64,9 @@ struct _paragraph PangoLayout *layout; size_t offset_last; + /* For anything other than PARA_TYPE_TEXT */ + SCBlock *scblock; + /* For PARA_TYPE_IMAGE */ char *filename; double image_w; @@ -419,7 +422,7 @@ static Paragraph *insert_paragraph(struct frame *fr, int pos) } -void add_callback_para(struct frame *fr, double w, double h, +void add_callback_para(struct frame *fr, SCBlock *bl, double w, double h, SCCallbackDrawFunc draw_func, SCCallbackClickFunc click_func, void *bvp, void *vp) @@ -433,6 +436,7 @@ void add_callback_para(struct frame *fr, double w, double h, } pnew->type = PARA_TYPE_CALLBACK; + pnew->scblock = bl; pnew->cb_w = w; pnew->cb_h = h; pnew->draw_func = draw_func; @@ -444,7 +448,7 @@ void add_callback_para(struct frame *fr, double w, double h, } -void add_image_para(struct frame *fr, const char *filename, +void add_image_para(struct frame *fr, SCBlock *scblock, const char *filename, double w, double h, int editable) { Paragraph *pnew; @@ -456,6 +460,7 @@ void add_image_para(struct frame *fr, const char *filename, } pnew->type = PARA_TYPE_IMAGE; + pnew->scblock = scblock; pnew->filename = strdup(filename); pnew->image_w = w; pnew->image_h = h; diff --git a/src/frame.h b/src/frame.h index a480938..1edd440 100644 --- a/src/frame.h +++ b/src/frame.h @@ -115,12 +115,14 @@ extern void add_run(Paragraph *para, SCBlock *scblock, size_t offs_bytes, size_t len_bytes, PangoFontDescription *fdesc, double col[4]); -extern void add_callback_para(struct frame *fr, double w, double h, +extern void add_callback_para(struct frame *fr, SCBlock *scblock, + double w, double h, SCCallbackDrawFunc draw_func, SCCallbackClickFunc click_func, void *bvp, void *vp); -extern void add_image_para(struct frame *fr, const char *filename, +extern void add_image_para(struct frame *fr, SCBlock *scblock, + const char *filename, double w, double h, int editable); extern void wrap_paragraph(Paragraph *para, PangoContext *pc, double w); diff --git a/src/sc_interp.c b/src/sc_interp.c index 9899a95..cd1de86 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -216,7 +216,7 @@ static void do_callback(SCInterpreter *scin, SCBlock *bl, const char *name) if ( strcmp(cbl->names[i], name) != 0 ) continue; r = cbl->box_funcs[i](scin, bl, &w, &h, &bvp, cbl->vps[i]); if ( !r ) return; - add_callback_para(sc_interp_get_frame(scin), w, h, + add_callback_para(sc_interp_get_frame(scin), bl, w, h, cbl->draw_funcs[i], cbl->click_funcs[i], bvp, cbl->vps[i]); @@ -883,7 +883,7 @@ static int check_outputs(SCBlock *bl, SCInterpreter *scin) if ( parse_image_options(options, sc_interp_get_frame(scin), &w, &h, &filename) == 0 ) { - add_image_para(sc_interp_get_frame(scin), + add_image_para(sc_interp_get_frame(scin), bl, filename, w, h, 1); free(filename); } else { |