From d0a3543e727cd67325bcff51b171d684d54d5f0f Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 12 Apr 2004 21:46:08 +0000 Subject: [project @ 2004-04-12 21:46:08 by jmb] Add popup tooltip containing URL when mouse is over history window entry svn path=/import/netsurf/; revision=766 --- !NetSurf/Resources/en/Templates,fec | Bin 5940 -> 6093 bytes !NetSurf/Resources/fr/Templates,fec | Bin 6053 -> 6206 bytes riscos/dialog.c | 3 +- riscos/gui.c | 4 ++ riscos/gui.h | 4 +- riscos/history.c | 73 +++++++++++++++++++++++++++++++++++- riscos/options.h | 7 +++- riscos/window.c | 5 +++ 8 files changed, 91 insertions(+), 5 deletions(-) diff --git a/!NetSurf/Resources/en/Templates,fec b/!NetSurf/Resources/en/Templates,fec index 21e5baf53..851950380 100644 Binary files a/!NetSurf/Resources/en/Templates,fec and b/!NetSurf/Resources/en/Templates,fec differ diff --git a/!NetSurf/Resources/fr/Templates,fec b/!NetSurf/Resources/fr/Templates,fec index 2fea5b232..36e21be84 100644 Binary files a/!NetSurf/Resources/fr/Templates,fec and b/!NetSurf/Resources/fr/Templates,fec differ diff --git a/riscos/dialog.c b/riscos/dialog.c index 72d58decb..ced6def7f 100644 --- a/riscos/dialog.c +++ b/riscos/dialog.c @@ -29,7 +29,7 @@ wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br, #ifdef WITH_AUTH dialog_401li, #endif - dialog_zoom, dialog_pageinfo; + dialog_zoom, dialog_pageinfo, dialog_tooltip; ; wimp_menu* theme_menu = NULL; @@ -76,6 +76,7 @@ void ro_gui_dialog_init(void) dialog_config_th = ro_gui_dialog_create("config_th"); dialog_zoom = ro_gui_dialog_create("zoom"); dialog_pageinfo = ro_gui_dialog_create("pageinfo"); + dialog_tooltip = ro_gui_dialog_create("tooltip"); set_browser_choices(); set_proxy_choices(); diff --git a/riscos/gui.c b/riscos/gui.c index a53bebe29..4bd736f89 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -447,12 +447,16 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block) break; case wimp_POINTER_LEAVING_WINDOW: + if (over_window == history_window) + wimp_close_window(dialog_tooltip); over_window = 0; gui_window_set_pointer(GUI_POINTER_DEFAULT); break; case wimp_POINTER_ENTERING_WINDOW: over_window = ro_lookup_gui_from_w(block->entering.w); + if (over_window == 0 && block->entering.w == history_window) + over_window = history_window; break; case wimp_MOUSE_CLICK: diff --git a/riscos/gui.h b/riscos/gui.h index bbeb5fa17..bb69288d1 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -20,7 +20,8 @@ #define THEMES_DIR ".Themes" extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br, - dialog_config_prox, dialog_config_th, dialog_zoom, dialog_pageinfo; + dialog_config_prox, dialog_config_th, dialog_zoom, dialog_pageinfo, + dialog_tooltip; extern wimp_w history_window; extern wimp_menu *iconbar_menu, *browser_menu, *combo_menu, *theme_menu; extern int iconbar_menu_height; @@ -154,6 +155,7 @@ void ro_gui_history_open(struct browser_window *bw, struct history *history, int wx, int wy); void ro_gui_history_redraw(wimp_draw *redraw); void ro_gui_history_click(wimp_pointer *pointer); +void ro_gui_history_mouse_at(wimp_pointer *pointer); /* in save.c */ void ro_gui_save_click(wimp_pointer *pointer); diff --git a/riscos/history.c b/riscos/history.c index 07a709623..55d2ab476 100644 --- a/riscos/history.c +++ b/riscos/history.c @@ -56,6 +56,8 @@ struct history { static struct browser_window *history_bw; static struct history *history_current = 0; +/* Position of mouse in window */ +static int mouse_x = 0, mouse_y = 0; wimp_w history_window; font_f history_font; @@ -173,7 +175,7 @@ void history_add(struct history *history, struct content *content) } */ area = thumbnail_initialise(WIDTH / 2, HEIGHT / 2, (os_mode)0x301680b5); - if (!area) { + if (!area) { LOG(("Thumbnail initialisation failed.")); return; } @@ -465,6 +467,75 @@ void ro_gui_history_redraw_tree(struct history_entry *he, } } +/** + * Handle mouse movements over the history window. + */ +void ro_gui_history_mouse_at(wimp_pointer *pointer) +{ + int x, y; + long width; + struct history_entry *he; + wimp_window_state state; + wimp_icon_state ic; + os_box box = {0, 0, 0, 0}; + + /* If the mouse hasn't moved, or if we don't want tooltips, exit */ + if ((mouse_x == pointer->pos.x && mouse_y == pointer->pos.y) || + !option_history_tooltip) + return; + + /* Update mouse position */ + mouse_x = pointer->pos.x; + mouse_y = pointer->pos.y; + + /* Find history tree entry under mouse */ + state.w = history_window; + wimp_get_window_state(&state); + + x = (pointer->pos.x - (state.visible.x0 - state.xscroll)) / FULL_WIDTH; + y = -(pointer->pos.y - (state.visible.y1 - state.yscroll)) / FULL_HEIGHT; + he = ro_gui_history_click_find(history_current->start, x, y); + if (he) { + /* get width of string */ + xfont_scan_string(history_font, he->url, + font_GIVEN_FONT | font_KERN | font_GIVEN_LENGTH, + 0x7fffffff, 0x7fffffff, + 0, + 0, strlen(he->url) > 256 ? 256 : strlen(he->url), + 0, (int*)&width, 0, 0); + + ro_gui_set_icon_string(dialog_tooltip, 0, he->url); + + /* resize icon appropriately */ + ic.w = dialog_tooltip; + ic.i = 0; + wimp_get_icon_state(&ic); + wimp_resize_icon(dialog_tooltip, 0, + ic.icon.extent.x0, ic.icon.extent.y0, + width/200, ic.icon.extent.y1); + + state.w = dialog_tooltip; + wimp_get_window_state(&state); + + /* update window extent */ + box.x1 = width/200; + box.y0 = -36; + xwimp_set_extent(dialog_tooltip, &box); + + /* set visible area */ + state.visible.x0 = pointer->pos.x + 24; + state.visible.y0 = pointer->pos.y - 22 - 36; + state.visible.x1 = pointer->pos.x + width/200; + state.visible.y1 = pointer->pos.y - 22; + state.next = wimp_TOP; + /* open window */ + wimp_open_window((wimp_open *) &state); + } + else { + /* not over a tree entry => close tooltip window. */ + wimp_close_window(dialog_tooltip); + } +} /** * Handle mouse clicks in the history window. diff --git a/riscos/options.h b/riscos/options.h index 548e28f5b..9f9642175 100644 --- a/riscos/options.h +++ b/riscos/options.h @@ -24,6 +24,7 @@ extern bool option_dither_sprites; extern bool option_filter_sprites; extern bool option_thumbnail_32bpp; extern int option_thumbnail_oversampling; +extern bool option_history_tooltip; #define EXTRA_OPTION_DEFINE \ bool option_use_mouse_gestures = false;\ @@ -34,7 +35,8 @@ char *option_language = 0;\ bool option_dither_sprites = true;\ bool option_filter_sprites = false;\ bool option_thumbnail_32bpp = true;\ -int option_thumbnail_oversampling = 0; +int option_thumbnail_oversampling = 0;\ +bool option_history_tooltip = true; #define EXTRA_OPTION_TABLE \ { "use_mouse_gestures", OPTION_BOOL, &option_use_mouse_gestures },\ @@ -45,6 +47,7 @@ int option_thumbnail_oversampling = 0; { "dither_sprites", OPTION_BOOL, &option_dither_sprites },\ { "filter_sprites", OPTION_BOOL, &option_filter_sprites },\ { "thumbnail_32bpp", OPTION_BOOL, &option_thumbnail_32bpp },\ -{ "thumbnail_oversampling", OPTION_INTEGER, &option_thumbnail_oversampling } +{ "thumbnail_oversampling", OPTION_INTEGER, &option_thumbnail_oversampling },\ +{ "history_tooltip", OPTION_BOOL, &option_history_tooltip } #endif diff --git a/riscos/window.c b/riscos/window.c index 1abd994fe..9afe4f623 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -575,6 +575,11 @@ void ro_gui_window_mouse_at(wimp_pointer* pointer) wimp_window_state state; gui_window* g; + if (pointer->w == history_window) { + ro_gui_history_mouse_at(pointer); + return; + } + g = ro_lookup_gui_from_w(pointer->w); if (g == NULL) -- cgit v1.2.3