From 7ab6febbf9016da84ee65bb5d7437c2e966d5c06 Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 19 Dec 2019 01:00:01 -0500 Subject: [PATCH] viewdemo: add a legend. baller as fuck --- src/demo/view.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/demo/view.c b/src/demo/view.c index 869ae7ef5..de3f25cdd 100644 --- a/src/demo/view.c +++ b/src/demo/view.c @@ -34,6 +34,31 @@ view_video_demo(struct notcurses* nc){ return 0; } +static struct ncplane* +legend(struct notcurses* nc, int dimy, int dimx){ + struct ncplane* n = notcurses_newplane(nc, 3, dimx / 5 + 10, dimy / 8, dimx / 10, NULL); + ncplane_set_bg_alpha(n, CELL_ALPHA_TRANS); + uint64_t channels = 0; + channels_set_bg_alpha(&channels, CELL_ALPHA_TRANS); + cell c = CELL_INITIALIZER(' ', 0, channels); + ncplane_set_default(n, &c); + ncplane_set_fg_rgb(n, 0, 0, 0); + if(ncplane_putstr_aligned(n, 0, "target launch", NCALIGN_LEFT) <= 0){ + ncplane_destroy(n); + return NULL; + } + ncplane_set_fg_rgb(n, 0xff, 0xff, 0xff); + if(ncplane_putstr_aligned(n, 1, "2003-12-11 FM-6", NCALIGN_RIGHT) <= 0){ + ncplane_destroy(n); + return NULL; + } + if(ncplane_putstr_aligned(n, 2, "RIM-161 SM-3 v. Aries TTV", NCALIGN_RIGHT) <= 0){ + ncplane_destroy(n); + return NULL; + } + return n; +} + int view_demo(struct notcurses* nc){ struct ncplane* ncp = notcurses_stdplane(nc); int dimy, dimx; @@ -82,8 +107,13 @@ int view_demo(struct notcurses* nc){ return -1; } nanosleep(&demodelay, NULL); + struct ncplane* ncpl = legend(nc, dimy, dimx); + if(ncpl == NULL){ + return -1; + } if(view_video_demo(nc)){ return -1; } + ncplane_destroy(ncpl); return 0; }