From 1efefba2657678809bc2e718f71ea7776495fd5e Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Sun, 28 Feb 2021 23:44:41 -0500 Subject: [PATCH] changed rendering --- headers/render.h | 1 + render.c | 32 ++++++++++++++++++++------------ taskasaur.c | 22 ++++++++++++++++++++++ 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/headers/render.h b/headers/render.h index 8c60a57..a14301c 100644 --- a/headers/render.h +++ b/headers/render.h @@ -48,6 +48,7 @@ extern int update_menuitem_descrip(MenuItem* menuitem); /* 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 */ diff --git a/render.c b/render.c index 33cd48b..7db2db3 100644 --- a/render.c +++ b/render.c @@ -298,20 +298,13 @@ make_popup_menu(TodoItem* itemdata) { 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, @@ -320,11 +313,26 @@ create_popup_win(TodoItem* item_info) 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 */ diff --git a/taskasaur.c b/taskasaur.c index 582d496..b00d29a 100644 --- a/taskasaur.c +++ b/taskasaur.c @@ -8,6 +8,7 @@ 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); @@ -39,6 +40,7 @@ main(int argc, char** argv) normal_handleinput(boardmenu, ch); normal_renderstep(boardmenu); } else { + popup_handleinput(boardmenu, ch); popup_renderstep(boardmenu); } @@ -207,6 +209,24 @@ normal_handleinput(BoardMenu* boardmenu, int ch) } } +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) { @@ -228,6 +248,8 @@ popup_renderstep(BoardMenu* boardmenu) { if (boardmenu->popup_menu == NULL) return; + render_popup_menu(boardmenu->popup_menu); + } void -- 2.20.1