transparent planes #10

This commit is contained in:
nick black 2019-12-02 05:21:03 -05:00 committed by Nick Black
parent 2aadd096c0
commit 415e238b3d
6 changed files with 34 additions and 4 deletions

View File

@ -714,6 +714,9 @@ API struct panelreel* panelreel_create(struct ncplane* nc,
const panelreel_options* popts,
int efd);
// Returns the ncplane on which this panelreel lives.
API struct ncplane* panelreel_plane(struct panelreel* pr);
// Tablet draw callback, provided a ncplane the first column that may be used,
// the first row that may be used, the first column that may not be used, the
// first row that may not be used, and a bool indicating whether output ought

View File

@ -270,6 +270,12 @@ panelreel_demo_core(struct notcurses* nc, int efd, tabletctx** tctxs){
ncplane_cursor_move_yx(w, 1, 1);
ncplane_printf(w, "a, b, c create tablets, DEL deletes, q quits.");
// FIXME clrtoeol();
/*
struct timespec fadets = { .tv_sec = 1, .tv_nsec = 0, };
if(ncplane_fadein(panelreel_plane(pr), &fadets)){
return NULL;
}
*/
unsigned id = 0;
do{
ncplane_styles_set(w, 0);

View File

@ -942,8 +942,8 @@ term_setstyles(const notcurses* nc, FILE* out, uint32_t* curattr, const cell* c)
// find the topmost cell for this coordinate
static const cell*
visible_cell(const notcurses* nc, int y, int x, const ncplane** retp){
const ncplane* p = nc->top;
visible_cell(int y, int x, ncplane** retp){
ncplane* p = *retp;
while(p){
// where in the plane this coordinate would be, based off absy/absx. the
// true origin is 0,0, so abs=2,2 means coordinate 3,3 would be 1,1, while
@ -955,9 +955,22 @@ visible_cell(const notcurses* nc, int y, int x, const ncplane** retp){
if(poffx < p->lenx && poffx >= 0){
*retp = p;
const cell* vis = &p->fb[fbcellidx(p, poffy, poffx)];
// if we never actually loaded the cell, use the background, if one
// is defined.
if(vis->gcluster == 0){
vis = &p->background;
}
// if it's using the terminal default, chase further down
// FIXME should probably be based off alpha channel
if(cell_fg_default_p(vis) && cell_bg_default_p(vis) && vis->gcluster == 0){
*retp = p->z;
const cell* trans = visible_cell(y, x, retp);
if(trans){
vis = trans;
}else{
*retp = p;
}
}
return vis;
}
}
@ -1092,8 +1105,8 @@ int notcurses_render(notcurses* nc){
// surprise enlargenings, otherwise we just print forward
for(x = 0 ; x < nc->stdscr->lenx ; ++x){
unsigned r, g, b, br, bg, bb;
const ncplane* p;
const cell* c = visible_cell(nc, y, x, &p);
ncplane* p = nc->top;
const cell* c = visible_cell(y, x, &p);
// we allow these to be set distinctly, but terminfo only supports using
// them both via the 'op' capability. unless we want to generate the 'op'
// escapes ourselves, if either is set to default, we first send op, and

View File

@ -550,6 +550,10 @@ validate_panelreel_opts(ncplane* w, const panelreel_options* popts){
return true;
}
ncplane* panelreel_plane(panelreel* pr){
return pr->p;
}
panelreel* panelreel_create(ncplane* w, const panelreel_options* popts, int efd){
panelreel* pr;

View File

@ -79,6 +79,10 @@ int main(int argc, char** argv){
std::cerr << "Error decoding " << argv[i] << ": " << errbuf.data() << std::endl;
return EXIT_FAILURE;
}
ncspecial_key special;
cell c = CELL_TRIVIAL_INITIALIZER;
notcurses_getc_blocking(nc, &c, &special);
cell_release(ncp, &c);
ncvisual_destroy(ncv);
}
if(notcurses_stop(nc)){

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB