int scroll_offset;
bool focused;
WINDOW* menu_win;
- WINDOW* sub_win;
int max_height;
int max_width;
void* userdata;
return menu->menu_win;
}
-WINDOW*
-get_menu_subwin(Menu* menu)
-{
- return menu->sub_win;
-}
-
MenuItem*
get_menu_item(Menu* menu, int index)
{
/* create a subwin (also prob free old subwin?) */
menu->max_height = height-MENU_PAD_TOP-MENU_PAD_BOTTOM;
menu->max_width = width-MENU_PAD_LEFT-MENU_PAD_RIGHT;
- menu->sub_win = derwin(
- menu->menu_win,
- menu->max_height,
- menu->max_width,
- MENU_PAD_TOP,
- MENU_PAD_LEFT
- );
return 0;
}
/* move cursor to right spot */
ungetstr(menu->menu_items[insert_index]->title);
- mvwgetnstr(menu->sub_win,
+ mvwgetnstr(menu->menu_win,
insert_pos,
0,
temp,
int
render_menu(Menu* menu)
{
- /* draw outer menu (prob dont need this every render) */
- /* wclear(menu->menu_win); */
- int titlecolor;
- titlecolor = COLOR_PAIR((menu->focused == true) ? TS_MENU_SELECTED: TS_MENU_NONSELECTED);
- wattron(menu->menu_win, titlecolor);
- mvwprintw(menu->menu_win, 0, MENU_PAD_LEFT, menu->menu_name);
- wattroff(menu->menu_win, titlecolor);
-
- /* draw inner menu */
- wclear(menu->sub_win);
+ wclear(menu->menu_win);
/* calculate scroll */
int visible;
);
}
- /* char abuf[20]; */
- /* int y; */
- /* int x; */
- /* getmaxyx(menu->sub_win, y, x); */
- /* sprintf(abuf, "%d,%d,%d max:%d,%d", menu->selected_item, visible, menu->scroll_offset,y,x); */
- /* mvprintw(19, 27, abuf); */
-
+ /* render menu items */
int curline = 0;
for (int i = menu->scroll_offset; i < menu->menu_length; i++) {
curline += render_item(menu, i, curline);
}
- wrefresh(menu->sub_win);
+ wrefresh(menu->menu_win);
wrefresh(menu->menu_win);
return 0;
/* color selected item */
hlcolor = COLOR_PAIR((item_index == menu->selected_item && menu->focused == true) ? TS_SELECTED : TS_NONSELECTED);
- wattron(menu->sub_win, hlcolor);
- mvwprintw(menu->sub_win, start_y, 0, curitem->title);
- wattroff(menu->sub_win, hlcolor);
+ wattron(menu->menu_win, hlcolor);
+ mvwprintw(menu->menu_win, start_y, 0, curitem->title);
+ wattroff(menu->menu_win, hlcolor);
/* display number of items */
if (strlen(curitem->description) > 0) {
- mvwprintw(menu->sub_win, start_y+1, 0, curitem->description);
+ wattron(menu->menu_win, COLOR_PAIR(TS_ITEMCOUNT));
+ mvwprintw(menu->menu_win, start_y+1, 0, curitem->description);
+ wattroff(menu->menu_win, COLOR_PAIR(TS_ITEMCOUNT));
}
return item_height(curitem);
int maxheight;
int maxwidth; // unused
- getmaxyx(menu->sub_win, maxheight, maxwidth);
+ getmaxyx(menu->menu_win, maxheight, maxwidth);
int vis = 0;
int lines = 0;
int maxheight;
int maxwidth; // unused
- getmaxyx(menu->sub_win, maxheight, maxwidth);
+ getmaxyx(menu->menu_win, maxheight, maxwidth);
int vis = 0;
int lines = 0;