1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 00:33:02 +01:00

simplify popup drawing

This commit is contained in:
Jfreegman 2014-03-09 01:02:54 -05:00
parent fe0641e981
commit d08feb2cc5
3 changed files with 10 additions and 16 deletions

View File

@ -262,10 +262,6 @@ static void del_friend_activate(ToxWindow *self, Tox *m, int f_num)
getmaxyx(self->window, y2, x2);
self->popup = newwin(3, 22 + TOXIC_MAX_NAME_LENGTH, 8, 8);
wattron(self->popup, A_BOLD);
box(self->popup, ACS_VLINE, ACS_HLINE);
wattroff(self->popup, A_BOLD);
pendingdelete.active = true;
pendingdelete.num = f_num;
}
@ -283,17 +279,22 @@ static void del_friend_deactivate(ToxWindow *self, Tox *m, wint_t key)
refresh();
}
static void friendlist_onPopup(ToxWindow *self, Tox *m)
static void draw_popup(ToxWindow *self, Tox *m)
{
if (self->popup == NULL)
return;
wattron(self->popup, A_BOLD);
box(self->popup, ACS_VLINE, ACS_HLINE);
wattroff(self->popup, A_BOLD);
wmove(self->popup, 1, 1);
wprintw(self->popup, "Delete contact ");
wattron(self->popup, A_BOLD);
wprintw(self->popup, "%s", friends[pendingdelete.num].name);
wattroff(self->popup, A_BOLD);
wprintw(self->popup, "? y/n");
wrefresh(self->popup);
}
@ -453,6 +454,7 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
self->x = x2;
wrefresh(self->window);
draw_popup(self, m);
}
void disable_chatwin(int f_num)
@ -473,7 +475,6 @@ ToxWindow new_friendlist(void)
ret.active = true;
ret.onKey = &friendlist_onKey;
ret.onPopup = &friendlist_onPopup;
ret.onDraw = &friendlist_onDraw;
ret.onInit = &friendlist_onInit;
ret.onFriendAdded = &friendlist_onFriendAdded;

View File

@ -88,7 +88,6 @@ typedef struct ChatContext ChatContext;
struct ToxWindow {
void(*onKey)(ToxWindow *, Tox *, wint_t);
void(*onDraw)(ToxWindow *, Tox *);
void(*onPopup)(ToxWindow *, Tox*);
void(*onInit)(ToxWindow *, Tox *);
void(*onFriendRequest)(ToxWindow *, uint8_t *, uint8_t *, uint16_t);
void(*onFriendAdded)(ToxWindow *, Tox *, int, bool);

View File

@ -387,14 +387,8 @@ void draw_active_window(Tox *m)
wresize(a->window, LINES - 2, COLS);
#endif
/* ignore main window if popup is active */
if (a->popup) {
a->onPopup(a, m);
wrefresh(a->popup);
} else {
a->onDraw(a, m);
wrefresh(a->window);
}
a->onDraw(a, m);
wrefresh(a->window);
/* Handle input */
#ifdef HAVE_WIDECHAR
@ -403,7 +397,7 @@ void draw_active_window(Tox *m)
ch = getch();
#endif
if ((ch == T_KEY_NEXT || ch == T_KEY_PREV) && !a->popup) /* lock window if active popup */
if (ch == T_KEY_NEXT || ch == T_KEY_PREV)
set_next_window((int) ch);
else if (ch != ERR)
a->onKey(a, m, ch);