summaryrefslogtreecommitdiff
path: root/meme/gui.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2015-03-14 15:13:32 (GMT)
committerWerner Almesberger <werner@almesberger.net>2015-03-14 15:13:32 (GMT)
commit1b6ddad3bc38ee43bbed59d695acf538b7284feb (patch)
tree22aa08bad0f2ed6804e29a3a232cd0b47160ea2a /meme/gui.c
parent1f9086e6b4da68a49d00ab4a25624119b8a36d56 (diff)
downloadmisc-1b6ddad3bc38ee43bbed59d695acf538b7284feb.zip
misc-1b6ddad3bc38ee43bbed59d695acf538b7284feb.tar.gz
misc-1b6ddad3bc38ee43bbed59d695acf538b7284feb.tar.bz2
meme/: support multiple overlays
Diffstat (limited to 'meme/gui.c')
-rw-r--r--meme/gui.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/meme/gui.c b/meme/gui.c
index 0cd6836..847fb4b 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -62,6 +62,7 @@ static bool show_profiles = 0;
static bool show_overlay = 0;
static bool show_mesh = 1;
static const struct vertex *cursor;
+static const struct overlay *overlay;
/* ----- Coordinate transform ---------------------------------------------- */
@@ -923,9 +924,9 @@ static void lineto(void *user, int x, int y)
}
-static void draw_overlay(SDL_Surface *s, const struct overlay *overlay)
+static void draw_overlay(SDL_Surface *s, const struct overlay *over)
{
- overlay_draw(overlay, moveto, lineto, s);
+ overlay_draw(over, moveto, lineto, s);
}
@@ -1196,7 +1197,8 @@ static void delayed_motion(void *user)
}
-static bool event_loop(SDL_Surface **surf, const char *logfile)
+static bool event_loop(SDL_Surface **surf, const char *logfile,
+ const struct overlay *const *overlays, unsigned n_overlays)
{
SDL_Surface *s = *surf;
SDL_Event event;
@@ -1249,6 +1251,18 @@ static bool event_loop(SDL_Surface **surf, const char *logfile)
return 0;
case SDLK_q:
return 1;
+ case SDLK_1:
+ if (n_overlays)
+ overlay = overlays[0];
+ return 0;
+ case SDLK_2:
+ if (n_overlays > 1)
+ overlay = overlays[1];
+ return 0;
+ case SDLK_3:
+ if (n_overlays > 2)
+ overlay = overlays[2];
+ return 0;
default:
break;
}
@@ -1286,7 +1300,8 @@ static bool event_loop(SDL_Surface **surf, const char *logfile)
}
-void gui(const char *logfile, const struct overlay *overlay)
+void gui(const char *logfile,
+ const struct overlay *const *overlays, unsigned n_overlays)
{
SDL_Surface *surf;
@@ -1312,6 +1327,9 @@ void gui(const char *logfile, const struct overlay *overlay)
init_z_grad();
auto_scale();
+ if (n_overlays)
+ overlay = overlays[0];
+
while (1) {
struct time t;
discard_changes();
@@ -1336,7 +1354,7 @@ fprintf(stderr, "%.3f s @ zoom %d\n", time_ms(&t)/1000.0, zoom);
}
apply_changes(surf);
- if (event_loop(&surf, logfile))
+ if (event_loop(&surf, logfile, overlays, n_overlays))
break;
}
}