summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-10-19 02:26:53 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-10-19 02:26:53 (GMT)
commit31ebe5256442870459a35dce362d84d629aa9043 (patch)
tree00ff24045752763b084efbb188a30e841d07de05 /gfx
parent2f031f568dae875c5d9fa0e20b478b9a8046c9e9 (diff)
downloadeeshow-31ebe5256442870459a35dce362d84d629aa9043.zip
eeshow-31ebe5256442870459a35dce362d84d629aa9043.tar.gz
eeshow-31ebe5256442870459a35dce362d84d629aa9043.tar.bz2
gfx/record.c (record_find_text): lookup text by position
Diffstat (limited to 'gfx')
-rw-r--r--gfx/record.c25
-rw-r--r--gfx/record.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/gfx/record.c b/gfx/record.c
index 9ef184c..5a17b6b 100644
--- a/gfx/record.c
+++ b/gfx/record.c
@@ -359,6 +359,31 @@ 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 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) {
+ if (obj->extra && !(obj->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)
+ return obj->u.text.s;
+ }
+ return NULL;
+}
+
+
/* ----- Bounding box ------------------------------------------------------ */
diff --git a/gfx/record.h b/gfx/record.h
index a8dbec4..f35dc9d 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(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);
void record_destroy(struct record *rec);