return 1; // account for wrap later
}
-int
-render_popupmenu(PopupMenu* popupmenu)
+/* save menu state to userdata */
+/* sorta duct tape rn */
+/* find a way to tie TodoItem and MenuItem together better in the future */
+void
+save_popupmenu_state(Menu* popupmenu_menu)
{
- render_menu(popupmenu->menu);
- wrefresh(popupmenu->win);
+ /* TodoItem* item_data; */
+
+ /* item_data = get_menu_userdata(popupmenu_menu); */
+ /* item_data->subtask_count = array_length(SubTask*, item_data->subtask_list); */
- return 0;
}
/* this is copy paste of other, prob abstract */
void popup_handleinput(BoardMenu* boardmenu, int ch);
void generic_handleinput(Menu* menu, int ch);
-void normal_renderstep(BoardMenu* boardmenu);
-void popup_renderstep(BoardMenu* boardmenu);
+void renderstep(BoardMenu* boardmenu);
void save_to_file(char* filepath, BoardMenu* boardmenu);
void exit_step(BoardMenu* boardmenu);
boardmenu = create_board_menu(board);
/* need to render before user presses anything */
- normal_renderstep(boardmenu);
+ renderstep(boardmenu);
int ch;
while (1) {
-
+
ch = getch();
if (boardmenu->popup_open == 0) {
normal_handleinput(boardmenu, ch);
- normal_renderstep(boardmenu);
} else {
popup_handleinput(boardmenu, ch);
- popup_renderstep(boardmenu);
}
+ renderstep(boardmenu);
+
}
/* save on exit - this causes weird stuff to happen, maybe it's not given enough time to write before program exits? */
insert_item(
to_menu,
- get_menu_item(
- from_menu,
- get_selected_item(from_menu)
- ),
+ get_selected_menuitem(from_menu),
min(
get_selected_item(from_menu),
get_menu_length(to_menu)
insert_item(
to_menu,
- get_menu_item(
- from_menu,
- get_selected_item(from_menu)
- ),
+ get_selected_menuitem(from_menu),
min(
get_selected_item(from_menu),
get_menu_length(to_menu)
/* set mode to popup */
boardmenu->popupmenu = make_popupmenu(sel_itemdata);
boardmenu->popup_open = 1;
+
}
break;
case BINDING_QUIT:
boardmenu->popup_open = 0;
+
+ /* reset screen */
clear();
+ renderstep(boardmenu);
break;
case BINDING_TOGGLE_DONE:
{
SubTask* curitem_data = (SubTask*)get_menuitem_userdata(get_menu_item(popupmenu_menu, get_selected_item(popupmenu_menu)));
curitem_data->done = (curitem_data->done == SubTaskState_todo) ? SubTaskState_done : SubTaskState_todo;
+ /* save_popupmenu_state(popupmenu_menu); */
}
break;
}
void
-normal_renderstep(BoardMenu* boardmenu)
+renderstep(BoardMenu* boardmenu)
{
- for (int i = 0; i < boardmenu->menu_count; i++) {
+ /* render main board menu */
+ if (boardmenu->popup_open == 0) {
+ for (int i = 0; i < boardmenu->menu_count; i++) {
- Menu* curmenu = boardmenu->menu_list[i];
+ Menu* curmenu = boardmenu->menu_list[i];
- /* update the descriptions - maybe not do this here */
- for (int j = 0; j < get_menu_length(curmenu); j++) {
- update_menuitem_descrip(get_menu_item(curmenu, j));
+ render_menu(curmenu);
}
- render_menu(curmenu);
- }
-}
+ /* render popup if it's open */
+ } else {
-void
-popup_renderstep(BoardMenu* boardmenu)
-{
- if (boardmenu->popupmenu == NULL) return;
+ // something weird happened, maybe raise error
+ /* if (boradmenu->popupmenu == NULL) return; */
- render_popupmenu(boardmenu->popupmenu);
+ render_menu(boardmenu->popupmenu->menu);
+ wrefresh(boardmenu->popupmenu->win);
+
+ }
+ refresh();
}
void