/* popup menu for menu item */
extern Menu* make_popup_menu(TodoItem* itemdata);
extern WINDOW* create_popup_win(TodoItem* item_info);
+extern int render_popup_menu(Menu* popup_menu);
extern MenuItem** subtasklist_to_menuitem(SubTask** subtask_list, int list_length);
/* some helpers */
{
MenuItem** subtask_menuitems;
Menu* new_popup_menu;
+ WINDOW* popup_win;
- /* subtask list */
subtask_menuitems = subtasklist_to_menuitem(itemdata->subtask_list, itemdata->subtask_count);
new_popup_menu = create_menu(strdup(""), subtask_menuitems);
- return new_popup_menu;
-}
-
-WINDOW*
-create_popup_win(TodoItem* item_info)
-{
+ /* popup win */
int maxheight, maxwidth;
- WINDOW* popup_win;
-
getmaxyx(stdscr, maxheight, maxwidth);
popup_win = newwin(
maxheight-2*POPUP_BORDER,
POPUP_BORDER*2
);
box(popup_win, 0, 0);
-
- refresh();
+
+ set_menu_win(new_popup_menu, popup_win);
+
+ return new_popup_menu;
+}
+
+int
+render_popup_menu(Menu* popup_menu)
+{
+ WINDOW* popup_win;
+
+ popup_win = get_menu_win(popup_menu);
+ wclear(popup_win);
+
+ /* box(popup_win, 0, 0); */
+ render_menu(popup_menu);
+
wrefresh(popup_win);
- return popup_win;
+ return 0;
}
/* this is copy paste of other, prob abstract */
char* boardfile_name = "test_board.md";
void normal_handleinput(BoardMenu* boardmenu, int ch);
+void popup_handleinput(BoardMenu* boardmenu, int ch);
void normal_renderstep(BoardMenu* boardmenu);
void popup_renderstep(BoardMenu* boardmenu);
normal_handleinput(boardmenu, ch);
normal_renderstep(boardmenu);
} else {
+ popup_handleinput(boardmenu, ch);
popup_renderstep(boardmenu);
}
}
}
+void
+popup_handleinput(BoardMenu* boardmenu, int ch)
+{
+ Menu* popup_menu;
+
+ popup_menu = boardmenu->popup_menu;
+
+ switch (ch) {
+
+ case BINDING_SCROLL_UP:
+ menu_driver(popup_menu, MENU_UP);
+ break;
+ case BINDING_SCROLL_DOWN:
+ menu_driver(popup_menu, MENU_DOWN);
+ break;
+ }
+}
+
void
normal_renderstep(BoardMenu* boardmenu)
{
{
if (boardmenu->popup_menu == NULL) return;
+ render_popup_menu(boardmenu->popup_menu);
+
}
void