summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-10-22 12:06:31 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-10-22 12:06:31 (GMT)
commita78129fa93b0b8699a6eee526ea5be561a75cc3f (patch)
tree06947d8f85451095a54fd6804bb3a7f271c0cb72
parent278f35823b8f927483a251737dc907975c99675c (diff)
downloadeeshow-a78129fa93b0b8699a6eee526ea5be561a75cc3f.zip
eeshow-a78129fa93b0b8699a6eee526ea5be561a75cc3f.tar.gz
eeshow-a78129fa93b0b8699a6eee526ea5be561a75cc3f.tar.bz2
gfx/record.c (record_find_text_bbox), record.h: find text, return bounding box
-rw-r--r--gfx/record.c20
-rw-r--r--gfx/record.h2
2 files changed, 16 insertions, 6 deletions
diff --git a/gfx/record.c b/gfx/record.c
index 5a17b6b..851d913 100644
--- a/gfx/record.c
+++ b/gfx/record.c
@@ -362,12 +362,11 @@ void record_replay(const struct record *rec, enum gfx_extra extra)
/* ----- Find text by position --------------------------------------------- */
-const char *record_find_text(const struct record *rec, enum gfx_extra extra,
- int x, int y)
+const char *record_find_text_bbox(const struct record *rec,
+ enum gfx_extra extra, int x, int y, struct record_bbox *bbox)
{
const struct record_layer *layer;
const struct record_obj *obj;
- struct record_bbox bbox;
for (layer = rec->layers; layer; layer = layer->next)
for (obj = layer->objs; obj; obj = obj->next) {
@@ -375,15 +374,24 @@ const char *record_find_text(const struct record *rec, enum gfx_extra extra,
continue;
if (obj->type != ro_text)
continue;
- bbox = obj->u.text.bbox;
- if (x >= bbox.xmin && x <= bbox.xmax &&
- y >= bbox.ymin && y <= bbox.ymax)
+ *bbox = obj->u.text.bbox;
+ if (x >= bbox->xmin && x <= bbox->xmax &&
+ y >= bbox->ymin && y <= bbox->ymax)
return obj->u.text.s;
}
return NULL;
}
+const char *record_find_text(const struct record *rec, enum gfx_extra extra,
+ int x, int y)
+{
+ struct record_bbox bbox;
+
+ return record_find_text_bbox(rec, extra, x, y, &bbox);
+}
+
+
/* ----- Bounding box ------------------------------------------------------ */
diff --git a/gfx/record.h b/gfx/record.h
index f35dc9d..5768f42 100644
--- a/gfx/record.h
+++ b/gfx/record.h
@@ -61,6 +61,8 @@ void record_set_extra(void *ctx, enum gfx_extra extra);
void record_init(struct record *rec, const struct gfx_ops *ops, void *user);
void record_wipe(struct record *rec);
void record_replay(const struct record *rec, enum gfx_extra extra);
+const char *record_find_text_bbox(const struct record *rec,
+ enum gfx_extra extra, int x, int y, struct record_bbox *bbox);
const char *record_find_text(const struct record *rec, enum gfx_extra extra,
int x, int y);
void record_bbox(const struct record *rec, int *x, int *y, int *w, int *h);