From b82939853866c9c61c572c218eea771641f960ce Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 3 Jul 2020 19:38:53 -0400 Subject: [PATCH] ncdirect_render_image: accept ncalign_e parameter #759 --- include/ncpp/Direct.hh | 4 ++-- include/notcurses/notcurses.h | 3 ++- python/src/notcurses/build_notcurses.py | 2 +- src/fetch/main.c | 3 ++- src/lib/direct.cpp | 3 ++- src/poc/vizdirect.c | 9 ++++++--- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/ncpp/Direct.hh b/include/ncpp/Direct.hh index a5392d9a6..68ae1b372 100644 --- a/include/ncpp/Direct.hh +++ b/include/ncpp/Direct.hh @@ -122,9 +122,9 @@ namespace ncpp return error_guard (ncdirect_cursor_disable (direct), -1); } - nc_err_e render_image (const char* file, ncblitter_e blitter, ncscale_e scale) const noexcept + nc_err_e render_image (const char* file, ncalign_e align, ncblitter_e blitter, ncscale_e scale) const noexcept { - return ncdirect_render_image (direct, file, blitter, scale); + return ncdirect_render_image (direct, file, align, blitter, scale); } private: diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 4dd8b3e3f..7de08bc34 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -154,7 +154,8 @@ API int ncdirect_printf_aligned(struct ncdirect* n, int y, ncalign_e align, // // be arbitrarily many rows -- the output will scroll -- but will only occupy // // the column of the cursor, and those to the right. API nc_err_e ncdirect_render_image(struct ncdirect* n, const char* filename, - ncblitter_e blitter, ncscale_e scale); + ncalign_e align, ncblitter_e blitter, + ncscale_e scale); // Clear the screen. API int ncdirect_clear(struct ncdirect* nc); diff --git a/python/src/notcurses/build_notcurses.py b/python/src/notcurses/build_notcurses.py index 974b2e421..792e6c2ef 100644 --- a/python/src/notcurses/build_notcurses.py +++ b/python/src/notcurses/build_notcurses.py @@ -506,7 +506,7 @@ int ncdirect_cursor_up(struct ncdirect* nc, int num); int ncdirect_cursor_left(struct ncdirect* nc, int num); int ncdirect_cursor_right(struct ncdirect* nc, int num); int ncdirect_cursor_down(struct ncdirect* nc, int num); -nc_err_e ncdirect_render_image(struct ncdirect* n, const char* filename, ncblitter_e blitter, ncscale_e scale); +nc_err_e ncdirect_render_image(struct ncdirect* n, const char* filename, ncalign_e align, ncblitter_e blitter, ncscale_e scale); """) if __name__ == "__main__": diff --git a/src/fetch/main.c b/src/fetch/main.c index 04e71f4d9..93fbd1a56 100644 --- a/src/fetch/main.c +++ b/src/fetch/main.c @@ -405,7 +405,8 @@ display_thread(void* vmarshal){ drawpalette(m->nc); if(m->dinfo){ if(m->dinfo->logofile){ - if(ncdirect_render_image(m->nc, m->dinfo->logofile, NCBLIT_2x2, + if(ncdirect_render_image(m->nc, m->dinfo->logofile, + NCALIGN_CENTER, NCBLIT_2x2, NCSCALE_SCALE) != NCERR_SUCCESS){ return NULL; } diff --git a/src/lib/direct.cpp b/src/lib/direct.cpp index 0f72259ca..af49db866 100644 --- a/src/lib/direct.cpp +++ b/src/lib/direct.cpp @@ -282,7 +282,8 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np){ return 0; } -nc_err_e ncdirect_render_image(ncdirect* n, const char* file, ncblitter_e blitter, ncscale_e scale){ +nc_err_e ncdirect_render_image(ncdirect* n, const char* file, ncalign_e align, + ncblitter_e blitter, ncscale_e scale){ nc_err_e ret; struct ncvisual* ncv = ncvisual_from_file(file, &ret); if(ncv == NULL){ diff --git a/src/poc/vizdirect.c b/src/poc/vizdirect.c index 58b5a67f6..435caf577 100644 --- a/src/poc/vizdirect.c +++ b/src/poc/vizdirect.c @@ -12,15 +12,18 @@ int main(void){ if((n = ncdirect_init(NULL, stdout)) == NULL){ return EXIT_FAILURE; } - if(ncdirect_render_image(n, "../data/normal.png", NCBLIT_DEFAULT, NCSCALE_STRETCH) != NCERR_SUCCESS){ + if(ncdirect_render_image(n, "../data/normal.png", NCALIGN_LEFT, + NCBLIT_DEFAULT, NCSCALE_STRETCH) != NCERR_SUCCESS){ return EXIT_FAILURE; } sleep(1); - if(ncdirect_render_image(n, "../data/changes.jpg", NCBLIT_DEFAULT, NCSCALE_SCALE) != NCERR_SUCCESS){ + if(ncdirect_render_image(n, "../data/changes.jpg", NCALIGN_CENTER, + NCBLIT_DEFAULT, NCSCALE_SCALE) != NCERR_SUCCESS){ return EXIT_FAILURE; } sleep(1); - if(ncdirect_render_image(n, "../data/warmech.bmp", NCBLIT_DEFAULT, NCSCALE_NONE) != NCERR_SUCCESS){ + if(ncdirect_render_image(n, "../data/warmech.bmp", NCALIGN_RIGHT, + NCBLIT_DEFAULT, NCSCALE_NONE) != NCERR_SUCCESS){ return EXIT_FAILURE; } if(ncdirect_stop(n)){