zoo demo: multiselector use CHANNELS_RGB_INIT

This commit is contained in:
nick black 2020-07-29 03:56:33 -04:00
parent 17b6706d3e
commit 47800e57f1
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 12 additions and 16 deletions

View File

@ -43,16 +43,13 @@ multiselector_demo(struct notcurses* nc, struct ncplane* n, int dimx, int y){
.maxdisplay = 8,
.title = "multi-item selector",
.items = mselect_items,
.boxchannels = CHANNELS_RGB_INITIALIZER(0x20, 0xe0, 0xe0, 0x20, 0, 0),
.opchannels = CHANNELS_RGB_INITIALIZER(0xe0, 0x80, 0x40, 0, 0, 0),
.descchannels = CHANNELS_RGB_INITIALIZER(0x80, 0xe0, 0x40, 0, 0, 0),
.footchannels = CHANNELS_RGB_INITIALIZER(0xe0, 0, 0x40, 0x20, 0x20, 0),
.titlechannels = CHANNELS_RGB_INITIALIZER(0x20, 0xff, 0xff, 0, 0, 0x20),
.bgchannels = CHANNELS_RGB_INITIALIZER(0, 0x20, 0, 0, 0x20, 0),
};
channels_set_fg(&mopts.boxchannels, 0x20e040);
channels_set_fg(&mopts.opchannels, 0xe08040);
channels_set_fg(&mopts.descchannels, 0x80e040);
channels_set_bg(&mopts.opchannels, 0);
channels_set_bg(&mopts.descchannels, 0);
channels_set_fg(&mopts.footchannels, 0xe00040);
channels_set_fg(&mopts.titlechannels, 0xffff80);
channels_set_fg(&mopts.bgchannels, 0x002000);
channels_set_bg(&mopts.bgchannels, 0x002000);
channels_set_fg_alpha(&mopts.bgchannels, CELL_ALPHA_BLEND);
channels_set_bg_alpha(&mopts.bgchannels, CELL_ALPHA_BLEND);
struct ncmultiselector* mselector = ncmultiselector_create(n, y, 0, &mopts);

View File

@ -374,15 +374,14 @@ ncreel_draw_tablet(const ncreel* nr, nctablet* t, int frontiery,
// NULL). it can occupy the entire ncreel.
static int
draw_focused_tablet(const ncreel* nr){
int pbegy, plenx, pleny; // ncreel window coordinates
int plenx, pleny; // ncreel window coordinates
ncplane_dim_yx(nr->p, &pleny, &plenx);
pbegy = 0;
int fulcrum;
if(nr->tablets->p == NULL){
if(nr->last_traveled_direction >= 0){
fulcrum = pleny + pbegy - !(nr->ropts.bordermask & NCBOXMASK_BOTTOM);
fulcrum = pleny + !(nr->ropts.bordermask & NCBOXMASK_BOTTOM);
}else{
fulcrum = pbegy + !(nr->ropts.bordermask & NCBOXMASK_TOP);
fulcrum = !(nr->ropts.bordermask & NCBOXMASK_TOP);
}
//fprintf(stderr, "LTD: %d placing new at %d\n", nr->last_traveled_direction, fulcrum);
}else{ // focused was already present. want to stay where we are, if possible
@ -393,7 +392,7 @@ draw_focused_tablet(const ncreel* nr){
int prevfulcrum;
ncplane_yx(nr->tablets->prev->p, &prevfulcrum, NULL);
if(fulcrum < prevfulcrum){
fulcrum = pleny + pbegy - !(nr->ropts.bordermask & NCBOXMASK_BOTTOM);
fulcrum = pleny + !(nr->ropts.bordermask & NCBOXMASK_BOTTOM);
}
}
}else if(nr->last_traveled_direction < 0){
@ -401,13 +400,13 @@ draw_focused_tablet(const ncreel* nr){
int nextfulcrum;
ncplane_yx(nr->tablets->next->p, &nextfulcrum, NULL);
if(fulcrum > nextfulcrum){
fulcrum = pbegy + !(nr->ropts.bordermask & NCBOXMASK_TOP);
fulcrum = !(nr->ropts.bordermask & NCBOXMASK_TOP);
}
}
}
//fprintf(stderr, "existing: %p %d placing at %d\n", nr->tablets, nr->last_traveled_direction, fulcrum);
}
//fprintf(stderr, "PR dims: %d + %d/%d fulcrum: %d\n", pbegy, pleny, plenx, fulcrum);
//fprintf(stderr, "PR dims: %d/%d fulcrum: %d\n", pleny, plenx, fulcrum);
ncreel_draw_tablet(nr, nr->tablets, fulcrum, 0 /* nr->last_traveled_direction*/);
return 0;
}