[visual] NCVISUAL_OPTIONS_HORALIGNED for bitmaps #1443

pull/1466/head
nick black 3 years ago committed by Nick Black
parent 1c3e10f926
commit 42e1e4f5d0

@ -472,6 +472,7 @@ ncplane* ncvisual_render_cells(notcurses* nc, ncvisual* ncv, const struct blitse
} // else stretch
}
if(flags & NCVISUAL_OPTION_HORALIGNED){
// FIXME this only centers
placex = (ncplane_dim_x(n) - dispcols / encoding_x_scale(&nc->tcache, bset)) / 2;
}
}
@ -493,7 +494,7 @@ ncplane* ncvisual_render_cells(notcurses* nc, ncvisual* ncv, const struct blitse
ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blitset* bset,
int placey, int placex, int begy, int begx,
ncplane* n, ncscale_e scaling){
ncplane* n, ncscale_e scaling, uint64_t flags){
ncplane* stdn = notcurses_stdplane(nc);
if(stdn == n){
logerror(nc, "Won't render bitmaps to the standard plane\n");
@ -522,6 +523,9 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
.resizecb = NULL,
.flags = 0,
};
if(flags & NCVISUAL_OPTION_HORALIGNED){
nopts.flags |= NCPLANE_OPTION_HORALIGNED;
}
if((n = ncplane_create(stdn, &nopts)) == NULL){
return NULL;
}
@ -533,12 +537,21 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
dispcols *= nc->tcache.cellpixx;
disprows *= nc->tcache.cellpixy;
dispcols -= (placex * nc->tcache.cellpixx + 1);
disprows -= (placey * nc->tcache.cellpixy + 1);
if(!(flags & NCVISUAL_OPTION_HORALIGNED)){
disprows -= (placey * nc->tcache.cellpixy + 1);
}
}
}
if(scaling == NCSCALE_SCALE || scaling == NCSCALE_SCALE_HIRES){
scale_visual(ncv, &disprows, &dispcols);
}
if(flags & NCVISUAL_OPTION_HORALIGNED){
if(placex == NCALIGN_CENTER){
placex = (ncplane_dim_x(n) - dispcols / nc->tcache.cellpixx) / 2;
}else if(placex == NCALIGN_RIGHT){
placex = ncplane_dim_x(n) - dispcols / nc->tcache.cellpixx;
}
}
//fprintf(stderr, "pblit: %dx%d <- %dx%d of %d/%d stride %u @%dx%d %p %u\n", disprows, dispcols, begy, begx, ncv->rows, ncv->cols, ncv->rowstride, placey, placex, ncv->data, nc->tcache.cellpixx);
blitterargs bargs;
bargs.begy = begy;
@ -614,8 +627,8 @@ ncplane* ncvisual_render(notcurses* nc, ncvisual* ncv, const struct ncvisual_opt
n = ncvisual_render_cells(nc, ncv, bset, placey, placex, begy, begx, leny, lenx,
n, scaling, vopts ? vopts->flags : 0);
}else{
// FIXME pass flags
n = ncvisual_render_pixels(nc, ncv, bset, placey, placex, begy, begx, n, scaling);
n = ncvisual_render_pixels(nc, ncv, bset, placey, placex, begy, begx, n, scaling,
vopts ? vopts->flags : 0);
}
return n;
}

Loading…
Cancel
Save