support menus on any plane #1645

This commit is contained in:
nick black 2021-07-07 08:33:36 -04:00
parent e631cac954
commit f0aec109b7
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 9 additions and 12 deletions

View File

@ -64,13 +64,12 @@ typedef struct ncmenu_options {
# DESCRIPTION
A notcurses instance supports menu bars on the top or bottom row of the true
screen. A menu is composed of sections, which are in turn composed of items.
Either no sections are visible, and the menu is *rolled up*, or exactly one
section is *unrolled*. **ncmenu_rollup** places an ncmenu in the rolled up
state. **ncmenu_unroll** rolls up any unrolled section, and unrolls the
specified one. **ncmenu_destroy** removes a menu bar, and frees all associated
resources.
A notcurses instance supports menu bars on the top or bottom row of a plane.
A menu is composed of sections, which are in turn composed of items. Either no
sections are visible, and the menu is *rolled up*, or exactly one section is
*unrolled*. **ncmenu_rollup** places an ncmenu in the rolled up state.
**ncmenu_unroll** rolls up any unrolled section, and unrolls the specified one.
**ncmenu_destroy** removes a menu bar, and frees all associated resources.
**ncmenu_selected** return the selected item description, or NULL if no section
is unrolled, or no valid item is selected. **ncmenu_mouse_selected** returns

View File

@ -3281,7 +3281,7 @@ API void nctree_destroy(struct nctree* n);
// Menus. Horizontal menu bars are supported, on the top and/or bottom rows.
// If the menu bar is longer than the screen, it will be only partially
// visible. Menus may be either visible or invisible by default. In the event of
// a screen resize, menus will be automatically moved/resized. Elements can be
// a plane resize, menus will be automatically moved/resized. Elements can be
// dynamically enabled or disabled at all levels (menu, section, and item),
struct ncmenu_item {
char* desc; // utf-8 menu item, NULL for horizontal separator
@ -3306,9 +3306,7 @@ typedef struct ncmenu_options {
uint64_t flags; // flag word of NCMENU_OPTION_*
} ncmenu_options;
// Create a menu with the specified options. Menus are currently bound to an
// overall Notcurses object (as opposed to a particular plane), and are
// implemented as ncplanes kept atop other ncplanes.
// Create a menu with the specified options, bound to the specified plane.
API ALLOC struct ncmenu* ncmenu_create(struct ncplane* n, const ncmenu_options* opts)
__attribute__ ((nonnull (1)));

View File

@ -356,7 +356,7 @@ ncmenu* ncmenu_create(ncplane* n, const ncmenu_options* opts){
ret->sectioncount = opts->sectioncount;
ret->sections = NULL;
int dimy, dimx;
ncplane_dim_yx(notcurses_stdplane(ncplane_notcurses(n)), &dimy, &dimx);
ncplane_dim_yx(n, &dimy, &dimx);
if(ret){
ret->bottom = !!(opts->flags & NCMENU_OPTION_BOTTOM);
if(dup_menu_sections(ret, opts, &totalwidth, &totalheight) == 0){