pinosaur
/
taskasaur.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
removed subwin
[taskasaur.git]
/
menu.c
diff --git
a/menu.c
b/menu.c
index
4f9ee5e
..
abb2fdf
100644
(file)
--- a/
menu.c
+++ b/
menu.c
@@
-30,7
+30,6
@@
typedef struct Menu {
int scroll_offset;
bool focused;
WINDOW* menu_win;
int scroll_offset;
bool focused;
WINDOW* menu_win;
- WINDOW* sub_win;
int max_height;
int max_width;
void* userdata;
int max_height;
int max_width;
void* userdata;
@@
-102,12
+101,6
@@
get_menu_win(Menu* menu)
return menu->menu_win;
}
return menu->menu_win;
}
-WINDOW*
-get_menu_subwin(Menu* menu)
-{
- return menu->sub_win;
-}
-
MenuItem*
get_menu_item(Menu* menu, int index)
{
MenuItem*
get_menu_item(Menu* menu, int index)
{
@@
-171,13
+164,6
@@
set_menu_win(Menu* menu, WINDOW* win)
/* 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;
/* 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;
}
return 0;
}
@@
-286,7
+272,7
@@
menu_insert_mode(Menu* menu, int insert_index)
/* move cursor to right spot */
ungetstr(menu->menu_items[insert_index]->title);
/* move cursor to right spot */
ungetstr(menu->menu_items[insert_index]->title);
- mvwgetnstr(menu->
sub
_win,
+ mvwgetnstr(menu->
menu
_win,
insert_pos,
0,
temp,
insert_pos,
0,
temp,
@@
-375,16
+361,7
@@
menu_driver(Menu* menu, MenuAction action)
int
render_menu(Menu* menu)
{
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;
/* calculate scroll */
int visible;
@@
-406,19
+383,13
@@
render_menu(Menu* menu)
);
}
);
}
- /* 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);
}
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;
wrefresh(menu->menu_win);
return 0;
@@
-433,13
+404,15
@@
render_item(Menu* menu, int item_index, int start_y)
/* color selected item */
hlcolor = COLOR_PAIR((item_index == menu->selected_item && menu->focused == true) ? TS_SELECTED : TS_NONSELECTED);
/* 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) {
/* 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);
}
return item_height(curitem);
@@
-464,7
+437,7
@@
items_visible(Menu* menu, int offset)
int maxheight;
int maxwidth; // unused
int maxheight;
int maxwidth; // unused
- getmaxyx(menu->
sub
_win, maxheight, maxwidth);
+ getmaxyx(menu->
menu
_win, maxheight, maxwidth);
int vis = 0;
int lines = 0;
int vis = 0;
int lines = 0;
@@
-485,7
+458,7
@@
items_visible_rev(Menu* menu, int offset)
int maxheight;
int maxwidth; // unused
int maxheight;
int maxwidth; // unused
- getmaxyx(menu->
sub
_win, maxheight, maxwidth);
+ getmaxyx(menu->
menu
_win, maxheight, maxwidth);
int vis = 0;
int lines = 0;
int vis = 0;
int lines = 0;