diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-03-29 17:57:42 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-03-29 17:57:42 +0200 |
commit | b14d1503e73100f6973c813845632dfa05c583b9 (patch) | |
tree | cef1c7900d956ca57b8e6d9de4a2d780483a4b79 /src/frame.c | |
parent | 0973dc26a6c384a09d898bc0bcfa41ee6f962129 (diff) |
Highlight the current paragraph
Has the nice effect of showing which slide is selected.
Diffstat (limited to 'src/frame.c')
-rw-r--r-- | src/frame.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/frame.c b/src/frame.c index f71e764..b021b42 100644 --- a/src/frame.c +++ b/src/frame.c @@ -576,6 +576,31 @@ int find_cursor(struct frame *fr, double x, double y, } +int get_para_highlight(struct frame *fr, int cursor_para, + double *cx, double *cy, double *cw, double *ch) +{ + Paragraph *para; + int i; + double py = 0.0; + + if ( cursor_para > fr->n_paras ) { + fprintf(stderr, "Cursor paragraph number is too high!\n"); + return 1; + } + + para = fr->paras[cursor_para]; + for ( i=0; i<cursor_para; i++ ) { + py += fr->paras[i]->height; + } + + *cx = fr->pad_l; + *cy = fr->pad_t + py; + *cw = fr->w - fr->pad_l - fr->pad_r; + *ch = para->height; + return 0; +} + + int get_cursor_pos(struct frame *fr, int cursor_para, int cursor_pos, double *cx, double *cy, double *ch) { @@ -590,14 +615,16 @@ int get_cursor_pos(struct frame *fr, int cursor_para, int cursor_pos, } para = fr->paras[cursor_para]; + for ( i=0; i<cursor_para; i++ ) { + py += fr->paras[i]->height; + } - if ( para->type != PARA_TYPE_TEXT ) return 1; + if ( para->type != PARA_TYPE_TEXT ) { + return 1; + } pango_layout_get_cursor_pos(para->layout, cursor_pos, &rect, NULL); - for ( i=0; i<cursor_para; i++ ) { - py += fr->paras[i]->height; - } *cx = pango_units_to_double(rect.x) + fr->pad_l; *cy = pango_units_to_double(rect.y) + fr->pad_t + py; *ch = pango_units_to_double(rect.height); |