From c1c1238e7e0b3d825af4f345eee578e6b829055e Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 31 Jul 2020 15:26:27 -0400 Subject: [PATCH] resize PoC: add some functionality #842 --- src/poc/resize.cpp | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/poc/resize.cpp b/src/poc/resize.cpp index 52586dd72..befe453af 100644 --- a/src/poc/resize.cpp +++ b/src/poc/resize.cpp @@ -21,26 +21,54 @@ int main(int argc, char** argv){ if((nc = notcurses_init(&opts, nullptr)) == nullptr){ return EXIT_FAILURE; } - int dimy, dimx; - struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx); struct ncvisual_options vopts{}; bool failed = false; nc_err_e ncerr; + int dimy, dimx; + int scaley, scalex; + int top = 0; + int bot; auto ncv = ncvisual_from_file(file, &ncerr); if(!ncv){ goto err; } - int scaley, scalex; ncvisual_geom(nc, ncv, &vopts, nullptr, nullptr, &scaley, &scalex); - //ncvisual_resize(ncv, dimy * scaley, dimx * scalex); - vopts.n = n; vopts.scaling = NCSCALE_STRETCH; - if(ncvisual_render(nc, ncv, &vopts) == nullptr){ + struct ncplane* ntarg; + if((ntarg = ncvisual_render(nc, ncv, &vopts)) == nullptr){ goto err; } if(notcurses_render(nc)){ goto err; } + ncplane_dim_yx(ntarg, &dimy, &dimx); + // start chopping off rows + bot = dimy - 1; + while(top <= bot){ + // one from top + sleep(1); + if(ncplane_resize(ntarg, 1, 0, bot - top, dimx, 0, 0, bot - top, dimx)){ + goto err; + } + ++top; + if(notcurses_render(nc)){ + goto err; + } + if(top > bot){ + break; + } + /* + // one from bottom + sleep(1); + if(ncplane_resize(ntarg, 0, 0, bot - top, dimx, 0, 0, bot - top, dimx)){ + goto err; + } + --bot; + if(notcurses_render(nc)){ + goto err; + } + */ + } return notcurses_stop(nc) || failed ? EXIT_FAILURE : EXIT_SUCCESS; err: