summaryrefslogtreecommitdiff
path: root/gui/over.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-19 03:32:41 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-19 03:32:41 -0300
commit6315c2dc1bfb9124aac44b5a2c058eef454b2d27 (patch)
treed65cef8f6a4336e82a27f2056e537cc631555fbe /gui/over.c
parent7dba2d97f3964f29e0d89b213b37e1a1b6bac3a9 (diff)
downloadeeshow-6315c2dc1bfb9124aac44b5a2c058eef454b2d27.tar.gz
eeshow-6315c2dc1bfb9124aac44b5a2c058eef454b2d27.tar.bz2
eeshow-6315c2dc1bfb9124aac44b5a2c058eef454b2d27.zip
eeshow/gui/over.c (overlay_set_related, _all): support related AoIs
Diffstat (limited to 'gui/over.c')
-rw-r--r--gui/over.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/gui/over.c b/gui/over.c
index 253ba7c..1a1f511 100644
--- a/gui/over.c
+++ b/gui/over.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
+#include <assert.h>
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
@@ -47,6 +48,7 @@ struct overlay {
void *user;
struct aoi *aoi;
+ const struct overlay *related;
struct overlay *next, *prev;
};
@@ -167,8 +169,13 @@ fprintf(stderr, "%u(%d) %u %.60s\n", ty, ink_rect.y / PANGO_SCALE, ink_h, over->
if (over->aoi)
aoi_update(over->aoi, &aoi_cfg);
- else
+ else {
over->aoi = aoi_add(over->aois, &aoi_cfg);
+ if (over->related) {
+ assert(over->related->aoi);
+ aoi_set_related(over->aoi, over->related->aoi);
+ }
+ }
}
return h;
@@ -318,6 +325,7 @@ struct overlay *overlay_add(struct overlay **overlays, struct aoi **aois,
over->click = click;
over->user = user;
over->aoi = NULL;
+ over->related = NULL;
prev = NULL;
for (anchor = overlays; *anchor; anchor = &(*anchor)->next)
@@ -356,6 +364,31 @@ void overlay_text(struct overlay *over, const char *fmt, ...)
}
+/* ----- Nesting ----------------------------------------------------------- */
+
+
+void overlay_set_related(struct overlay *over, struct overlay *related)
+{
+ /*
+ * Relatedness is a property that only matters to AoIs, but we have to
+ * defer propagating it because we only know our AoI after drawing the
+ * overlay.
+ */
+
+ assert(!over->related);
+ over->related = related;
+}
+
+
+void overlay_set_related_all(struct overlay *overlays, struct overlay *related)
+{
+ struct overlay *over;
+
+ for (over = overlays; over; over = over->next)
+ overlay_set_related(over, related);
+}
+
+
/* ----- Removal ----------------------------------------------------------- */