demo: add menu, but disable for now

pull/331/head
nick black 5 years ago committed by Nick Black
parent 3cdac5ce28
commit 5b20651836

@ -396,9 +396,10 @@ int main(int argc, char** argv){
sigemptyset(&sigmask);
sigaddset(&sigmask, SIGWINCH);
pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
notcurses_options nopts;
const bool use_menu = false;
const char* spec;
bool use_hud, ignore_failures;
notcurses_options nopts;
if((spec = handle_opts(argc, argv, &nopts, &use_hud, &ignore_failures)) == NULL){
if(argv[optind] != NULL){
usage(*argv, EXIT_FAILURE);
@ -426,6 +427,11 @@ int main(int argc, char** argv){
goto err;
}
}
if(use_menu){
if(menu_create(nc) == NULL){
goto err;
}
}
if(input_dispatcher(nc)){
goto err;
}

@ -120,6 +120,7 @@ timespec_mul(const struct timespec* ts, unsigned multiplier, struct timespec* pr
/*----------------------------------HUD----------------------------------*/
extern struct ncplane* hud;
struct ncplane* hud_create(struct notcurses* nc);
struct ncmenu* menu_create(struct notcurses* nc);
int hud_destroy(void);
// let the HUD know about an upcoming demo

@ -57,6 +57,32 @@ hud_grabbed_bg(struct ncplane* n){
return 0;
}
struct ncmenu* menu_create(struct notcurses* nc){
struct ncmenu_item demo_items[] = {
{ .desc = "Restart", .shortcut = { .id = 'r', .ctrl = true, }, },
};
const struct ncmenu_section sections[] = {
{ .name = "notcurses-demo", .items = demo_items,
.itemcount = sizeof(demo_items) / sizeof(*demo_items),
.shortcut = { .id = 'o', .alt = true, }, },
};
uint64_t headerchannels = 0;
uint64_t sectionchannels = 0;
channels_set_fg(&headerchannels, 0x00ff00);
channels_set_bg(&headerchannels, 0x440000);
channels_set_fg_alpha(&sectionchannels, CELL_ALPHA_TRANSPARENT);
channels_set_bg_alpha(&sectionchannels, CELL_ALPHA_TRANSPARENT);
const ncmenu_options mopts = {
.bottom = false,
.hiding = false,
.sections = sections,
.sectioncount = sizeof(sections) / sizeof(*sections),
.headerchannels = headerchannels,
.sectionchannels = sectionchannels,
};
return ncmenu_create(nc, &mopts);
}
struct ncplane* hud_create(struct notcurses* nc){
int dimx, dimy;
notcurses_term_dim_yx(nc, &dimy, &dimx);

@ -43,6 +43,7 @@ legend(struct notcurses* nc, int dimy, int dimx){
ncplane_set_base(n, channels, 0, " ");
ncplane_styles_set(n, NCSTYLE_BOLD);
ncplane_set_fg_rgb(n, 0xff, 0xff, 0xff);
ncplane_set_fg_alpha(n, CELL_ALPHA_HIGHCONTRAST);
if(ncplane_putstr_aligned(n, 0, NCALIGN_CENTER, "target launch") <= 0){
ncplane_destroy(n);
return NULL;

@ -221,7 +221,7 @@ highcontrast(uint32_t bchannel){
channel_set(&rchannel, 0x0);
}
*/
if(r + g + b < 384){
if(r + g + b < 512){
channel_set(&rchannel, 0xffffff);
}else{
channel_set(&rchannel, 0x0);

@ -85,11 +85,13 @@ int main(void){
{ .desc = "Quit", .shortcut = { .id = 'q', .ctrl = true, }, },
};
struct ncmenu_section sections[] = {
{ .name = "Schwarzgerät", .items = demo_items, .shortcut = { .id = 0x00e4, .alt = true, }, },
{ .name = "File", .items = file_items, .shortcut = { .id = 'f', .alt = true, }, },
{ .name = "Schwarzgerät", .items = demo_items,
.itemcount = sizeof(demo_items) / sizeof(*demo_items),
.shortcut = { .id = 0x00e4, .alt = true, }, },
{ .name = "File", .items = file_items,
.itemcount = sizeof(file_items) / sizeof(*file_items),
.shortcut = { .id = 'f', .alt = true, }, },
};
sections[0].itemcount = sizeof(demo_items) / sizeof(*demo_items);
sections[1].itemcount = sizeof(file_items) / sizeof(*file_items);
ncmenu_options mopts;
memset(&mopts, 0, sizeof(mopts));
mopts.sections = sections;

Loading…
Cancel
Save