1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

big dialogs: redraw the dialog when scrolling

Merge functions:
redraw_from_window(win) => redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, win)
redraw_below_window(win) => redraw_windows(REDRAW_BEHIND_WINDOW, win)
Add REDRAW_WINDOW_AND_FRONT as a third possibility.
Then use that in update_hierbox_browser(), which previously used
window.next for this purpose, and in dialog-scrolling code,
which previously did not redraw the dialog box itself.
This commit is contained in:
Kalle Olavi Niemitalo 2008-10-12 14:01:05 +03:00 committed by Kalle Olavi Niemitalo
parent 2db33a0c53
commit 8010b3371b
9 changed files with 50 additions and 36 deletions

View File

@ -126,7 +126,7 @@ redraw_dialog(struct dialog_data *dlg_data, int layout)
update_all_widgets(dlg_data);
redraw_from_window(dlg_data->win);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, dlg_data->win);
}
static void
@ -206,7 +206,7 @@ select_widget(struct dialog_data *dlg_data, struct widget_data *widget_data)
dlg_data->selected_widget_id = widget_data - dlg_data->widgets_data;
if (check_range(dlg_data, widget_data)) {
redraw_from_window(dlg_data->win);
redraw_windows(REDRAW_WINDOW_AND_FRONT, dlg_data->win);
return;
}
@ -249,13 +249,13 @@ cycle_widget_focus(struct dialog_data *dlg_data, int direction)
&& dlg_data->selected_widget_id != prev_selected);
if (check_range(dlg_data, selected_widget(dlg_data))) {
redraw_from_window(dlg_data->win);
redraw_windows(REDRAW_WINDOW_AND_FRONT, dlg_data->win);
return;
}
display_widget(dlg_data, previously_selected_widget);
display_widget(dlg_data, selected_widget(dlg_data));
redraw_from_window(dlg_data->win);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, dlg_data->win);
}
static void

View File

@ -30,7 +30,7 @@ update_hierbox_browser(struct hierbox_browser *browser)
struct hierbox_dialog_list_item *item;
foreach (item, browser->dialogs) {
redraw_from_window(item->dlg_data->win->next);
redraw_windows(REDRAW_WINDOW_AND_FRONT, item->dlg_data->win);
}
}

View File

@ -719,7 +719,7 @@ kbd_field(struct dialog_data *dlg_data, struct widget_data *widget_data)
display_field:
display_widget(dlg_data, widget_data);
redraw_from_window(dlg_data->win);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, dlg_data->win);
return EVENT_PROCESSED;
}

View File

@ -672,7 +672,7 @@ display_menu(struct terminal *term, struct menu *menu)
}
}
redraw_from_window(menu->win);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, menu->win);
}
@ -1185,7 +1185,7 @@ display_mainmenu(struct terminal *term, struct menu *menu)
draw_box(term, &box, '>', 0, normal_color);
}
redraw_from_window(menu->win);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, menu->win);
}

View File

@ -432,7 +432,7 @@ format_and_display_text(struct widget_data *widget_data,
height, 0);
display_text(dlg_data, widget_data);
redraw_from_window(dlg_data->win);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, dlg_data->win);
}
static widget_handler_status_T

View File

@ -135,7 +135,7 @@ download_dialog_layouter(struct dialog_data *dlg_data)
&& (show_meter || is_in_state(download->state, S_RESUME)));
#endif
redraw_below_window(dlg_data->win);
redraw_windows(REDRAW_BEHIND_WINDOW, dlg_data->win);
file_download->dlg_data = dlg_data;
if (!msg) return;

View File

@ -567,5 +567,5 @@ print_screen_status(struct session *ses)
display_tab_bar(ses, term, tabs_count);
}
redraw_from_window(ses->tab);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, ses->tab);
}

View File

@ -18,36 +18,35 @@
void
redraw_from_window(struct window *win)
redraw_windows(enum windows_to_redraw which, struct window *win)
{
struct terminal *term = win->term;
struct term_event ev;
struct window *end = (struct window *) &term->windows;
if (term->redrawing != TREDRAW_READY) return;
set_redraw_term_event(&ev, term->width, term->height);
term->redrawing = TREDRAW_BUSY;
for (win = win->prev; win != end; win = win->prev) {
if (!inactive_tab(win))
win->handler(win, &ev);
}
term->redrawing = TREDRAW_READY;
}
void
redraw_below_window(struct window *win)
{
struct terminal *term = win->term;
struct term_event ev;
struct window *end = win;
struct window *end;
enum term_redrawing_state saved_redraw_state = term->redrawing;
if (term->redrawing == TREDRAW_DELAYED) return;
switch (which) {
case REDRAW_IN_FRONT_OF_WINDOW:
win = win->prev;
/* fall through */
case REDRAW_WINDOW_AND_FRONT:
end = (struct window *) &term->windows;
if (term->redrawing != TREDRAW_READY) return;
term->redrawing = TREDRAW_BUSY;
break;
case REDRAW_BEHIND_WINDOW:
end = win;
win = (struct window *) term->windows.prev;
if (term->redrawing == TREDRAW_DELAYED) return;
term->redrawing = TREDRAW_DELAYED;
break;
default:
ERROR("invalid enum windows_to_redraw: which==%d", (int) which);
return;
}
set_redraw_term_event(&ev, term->width, term->height);
term->redrawing = TREDRAW_DELAYED;
for (win = term->windows.prev; win != end; win = win->prev) {
for (; win != end; win = win->prev) {
if (!inactive_tab(win))
win->handler(win, &ev);
}

View File

@ -68,8 +68,23 @@ struct window {
unsigned int resize:1;
};
void redraw_from_window(struct window *);
void redraw_below_window(struct window *);
/** Which windows redraw_windows() should redraw. */
enum windows_to_redraw {
/** Redraw the windows in front of the specified window,
* but not the specified window itself. */
REDRAW_IN_FRONT_OF_WINDOW,
/** Redraw the specified window, and the windows in front of
* it. */
REDRAW_WINDOW_AND_FRONT,
/** Redraw the windows behind the specified window,
* but not the specified window itself.
* Do that even if terminal.redrawing is TREDRAW_BUSY. */
REDRAW_BEHIND_WINDOW,
};
void redraw_windows(enum windows_to_redraw, struct window *);
void add_window(struct terminal *, window_handler_T, void *);
void delete_window(struct window *);
void delete_window_ev(struct window *, struct term_event *ev);