mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
selector: transparent where we aren't
This commit is contained in:
parent
5980c9ae66
commit
bdd0917ea4
@ -1035,7 +1035,7 @@ channel_set_alpha(unsigned* channel, int alpha){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*channel = (alpha << CELL_ALPHA_SHIFT) | (*channel & ~CELL_ALPHA_MASK);
|
*channel = (alpha << CELL_ALPHA_SHIFT) | (*channel & ~CELL_ALPHA_MASK);
|
||||||
if(alpha == CELL_ALPHA_HIGHCONTRAST){
|
if(alpha != CELL_ALPHA_HIGHCONTRAST){
|
||||||
*channel |= CELL_BGDEFAULT_MASK;
|
*channel |= CELL_BGDEFAULT_MASK;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -217,6 +217,10 @@ ncselector* ncselector_create(ncplane* n, int y, int x, const selector_options*
|
|||||||
goto freeitems;
|
goto freeitems;
|
||||||
}
|
}
|
||||||
cell_init(&ns->background);
|
cell_init(&ns->background);
|
||||||
|
uint64_t transchan = 0;
|
||||||
|
channels_set_fg_alpha(&transchan, CELL_ALPHA_TRANSPARENT);
|
||||||
|
channels_set_bg_alpha(&transchan, CELL_ALPHA_TRANSPARENT);
|
||||||
|
ncplane_set_base(ns->ncp, transchan, 0, "");
|
||||||
if(cell_prime(ns->ncp, &ns->background, " ", 0, opts->bgchannels) < 0){
|
if(cell_prime(ns->ncp, &ns->background, " ", 0, opts->bgchannels) < 0){
|
||||||
ncplane_destroy(ns->ncp);
|
ncplane_destroy(ns->ncp);
|
||||||
goto freeitems;
|
goto freeitems;
|
||||||
|
@ -70,40 +70,61 @@ int main(void){
|
|||||||
channels_set_fg(&sopts.boxchannels, 0x20e040);
|
channels_set_fg(&sopts.boxchannels, 0x20e040);
|
||||||
channels_set_fg(&sopts.opchannels, 0xe08040);
|
channels_set_fg(&sopts.opchannels, 0xe08040);
|
||||||
channels_set_fg(&sopts.descchannels, 0x80e040);
|
channels_set_fg(&sopts.descchannels, 0x80e040);
|
||||||
|
channels_set_bg(&sopts.opchannels, 0);
|
||||||
|
channels_set_bg(&sopts.descchannels, 0);
|
||||||
channels_set_fg(&sopts.footchannels, 0xe00040);
|
channels_set_fg(&sopts.footchannels, 0xe00040);
|
||||||
channels_set_fg(&sopts.titlechannels, 0xffff80);
|
channels_set_fg(&sopts.titlechannels, 0xffff80);
|
||||||
channels_set_fg(&sopts.bgchannels, 0x002000);
|
channels_set_fg(&sopts.bgchannels, 0x002000);
|
||||||
channels_set_bg(&sopts.bgchannels, 0x002000);
|
channels_set_bg(&sopts.bgchannels, 0x002000);
|
||||||
channels_set_fg_alpha(&sopts.bgchannels, CELL_ALPHA_BLEND);
|
channels_set_fg_alpha(&sopts.bgchannels, CELL_ALPHA_BLEND);
|
||||||
channels_set_bg_alpha(&sopts.bgchannels, CELL_ALPHA_BLEND);
|
channels_set_bg_alpha(&sopts.bgchannels, CELL_ALPHA_BLEND);
|
||||||
ncplane_set_fg(notcurses_stdplane(nc), 0x40f040);
|
struct ncplane* n = notcurses_stdplane(nc);
|
||||||
ncplane_putstr_aligned(notcurses_stdplane(nc), 0, NCALIGN_RIGHT, "selector widget demo");
|
|
||||||
struct ncselector* ns = ncselector_create(notcurses_stdplane(nc), 3, 0, &sopts);
|
int averr;
|
||||||
|
struct ncvisual* ncv = ncplane_visual_open(n, "../data/changes.jpg", &averr);
|
||||||
|
if(!ncv){
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if(!ncvisual_decode(ncv, &averr)){
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if(ncvisual_render(ncv, 0, 0, 0, 0)){
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ncplane_set_fg(n, 0x40f040);
|
||||||
|
ncplane_putstr_aligned(n, 0, NCALIGN_RIGHT, "selector widget demo");
|
||||||
|
struct ncselector* ns = ncselector_create(n, 3, 0, &sopts);
|
||||||
run_selector(nc, ns);
|
run_selector(nc, ns);
|
||||||
|
|
||||||
sopts.title = "short round title";
|
sopts.title = "short round title";
|
||||||
ns = ncselector_create(notcurses_stdplane(nc), 3, 0, &sopts);
|
ns = ncselector_create(n, 3, 0, &sopts);
|
||||||
run_selector(nc, ns);
|
run_selector(nc, ns);
|
||||||
|
|
||||||
sopts.title = "short round title";
|
sopts.title = "short round title";
|
||||||
sopts.secondary = "now this secondary is also very, very, very outlandishly long, you see";
|
sopts.secondary = "now this secondary is also very, very, very outlandishly long, you see";
|
||||||
ns = ncselector_create(notcurses_stdplane(nc), 3, 0, &sopts);
|
ns = ncselector_create(n, 3, 0, &sopts);
|
||||||
run_selector(nc, ns);
|
run_selector(nc, ns);
|
||||||
|
|
||||||
sopts.title = "the whole world is watching";
|
sopts.title = "the whole world is watching";
|
||||||
sopts.secondary = NULL;
|
sopts.secondary = NULL;
|
||||||
sopts.footer = "now this FOOTERFOOTER is also very, very, very outlandishly long, you see";
|
sopts.footer = "now this FOOTERFOOTER is also very, very, very outlandishly long, you see";
|
||||||
ns = ncselector_create(notcurses_stdplane(nc), 3, 0, &sopts);
|
ns = ncselector_create(n, 3, 0, &sopts);
|
||||||
run_selector(nc, ns);
|
run_selector(nc, ns);
|
||||||
|
|
||||||
sopts.title = "chomps";
|
sopts.title = "chomps";
|
||||||
sopts.secondary = NULL;
|
sopts.secondary = NULL;
|
||||||
sopts.footer = NULL;
|
sopts.footer = NULL;
|
||||||
ns = ncselector_create(notcurses_stdplane(nc), 3, 0, &sopts);
|
ns = ncselector_create(n, 3, 0, &sopts);
|
||||||
run_selector(nc, ns);
|
run_selector(nc, ns);
|
||||||
|
|
||||||
if(notcurses_stop(nc)){
|
if(notcurses_stop(nc)){
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
|
err:
|
||||||
|
notcurses_stop(nc);
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user