summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-10-19 01:50:44 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-10-19 01:50:44 (GMT)
commit2f031f568dae875c5d9fa0e20b478b9a8046c9e9 (patch)
tree5e1a346349e414456bb6f3ce4b9b4dd2c49fc6de /gfx
parent36e141f4452fde1499f1054fd8e853f5f0d0563c (diff)
downloadeeshow-2f031f568dae875c5d9fa0e20b478b9a8046c9e9.zip
eeshow-2f031f568dae875c5d9fa0e20b478b9a8046c9e9.tar.gz
eeshow-2f031f568dae875c5d9fa0e20b478b9a8046c9e9.tar.bz2
gfx/record.c: record bounding box of text (for future use)
Diffstat (limited to 'gfx')
-rw-r--r--gfx/record.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/gfx/record.c b/gfx/record.c
index ce31c71..9ef184c 100644
--- a/gfx/record.c
+++ b/gfx/record.c
@@ -61,6 +61,7 @@ struct record_obj {
enum text_align align;
int rot;
enum text_style style;
+ struct record_bbox bbox;
} text;
} u;
struct record_obj *next;
@@ -235,25 +236,31 @@ void record_text(void *ctx, int x, int y, const char *s, unsigned size,
struct record *rec = ctx;
struct record_obj *obj =
new_obj(ctx, ro_text, color, COLOR_NONE, layer);
+ struct record_bbox bbox;
int width = rec->ops->text_width(rec->user, s, size, style);
+ bb_init(&bbox);
switch (align) {
case text_min:
- bb_rot(&rec->bbox, x, y, 0, -size, rot);
- bb_rot(&rec->bbox, x, y, width, 0, rot);
+ bb_rot(&bbox, x, y, 0, -size, rot);
+ bb_rot(&bbox, x, y, width, 0, rot);
break;
case text_mid:
- bb_rot(&rec->bbox, x, y, -(width + 1) / 2, -size, rot);
- bb_rot(&rec->bbox, x, y, (width + 1) / 2, 0, rot);
+ bb_rot(&bbox, x, y, -(width + 1) / 2, -size, rot);
+ bb_rot(&bbox, x, y, (width + 1) / 2, 0, rot);
break;
case text_max:
- bb_rot(&rec->bbox, x, y, -width, -size, rot);
- bb_rot(&rec->bbox, x, y, 0, 0, rot);
+ bb_rot(&bbox, x, y, -width, -size, rot);
+ bb_rot(&bbox, x, y, 0, 0, rot);
break;
default:
BUG("invalid alignment %d", align);
}
+ obj->u.text.bbox = bbox;
+ bb(&rec->bbox, bbox.xmin, bbox.ymin);
+ bb(&rec->bbox, bbox.xmax, bbox.ymax);
+
obj->x = x;
obj->y = y;
obj->u.text.s = stralloc(s);