From 5c804fe3b209ecf416a9525f570f6a52f20bfe08 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Fri, 9 Jul 2004 21:03:26 +0000 Subject: [PATCH] [project @ 2004-07-09 21:03:26 by rjw] Various minor GUI fixes svn path=/import/netsurf/; revision=1064 --- !NetSurf/Resources/en/Templates,fec | Bin 7140 -> 7140 bytes !NetSurf/Resources/fr/Templates,fec | Bin 7219 -> 7219 bytes riscos/gui.h | 1 + riscos/hotlist.c | 105 +++++++++++++++------------- riscos/menus.c | 2 + riscos/save.c | 4 ++ riscos/theme.c | 2 +- riscos/toolbar.c | 2 +- 8 files changed, 67 insertions(+), 49 deletions(-) diff --git a/!NetSurf/Resources/en/Templates,fec b/!NetSurf/Resources/en/Templates,fec index 6573fd60b30d63717b8fc6f4e88827c138fee135..52463f749d2006edb87c9c955ac293846c1574cb 100644 GIT binary patch delta 48 zcmaE2{=|I4V@Af7%}*FF^8%?I{4Oj&>aXx>R>qdeDB6 delta 51 zcmaE2{=|I4V@Afd%}*FF^8%?I{4Oj&>aXx>R>ro;D delta 51 zcmdmNvDsq7V@Afd%}*E^`GC|j{xBvWWh=Ccow0554@n=kkj#>tRNl#6Qon!#uF~%S D`ox0, \ + full ? -16384 : entry->y0, full ? 16384 : entry->x0 + entry->expanded_width, entry->y0 + entry->height); +#define hotlist_redraw_entry_title(entry) xwimp_force_redraw(hotlist_window, entry->x0, \ + entry->y0 + entry->height - HOTLIST_LINE_HEIGHT, entry->x0 + entry->width, entry->y0 + entry->height); + void ro_gui_hotlist_init(void) { - char *title; + const char *title; + char *new_title; os_box extent = {0, 0, 0, 0};; os_error *error; @@ -274,7 +281,9 @@ void ro_gui_hotlist_init(void) { /* Create our window */ title = messages_get("Hotlist"); - hotlist_window_definition.title_data.indirected_text.text = title; + new_title = malloc(strlen(title + 1)); + strcpy(new_title, title); + hotlist_window_definition.title_data.indirected_text.text = new_title; hotlist_window_definition.title_data.indirected_text.validation = null_text_string; hotlist_window_definition.title_data.indirected_text.size = strlen(title); error = xwimp_create_window(&hotlist_window_definition, &hotlist_window); @@ -455,7 +464,7 @@ bool ro_gui_hotlist_load(void) { /* Add some content */ - entry = ro_gui_hotlist_create_entry("NetSurf homepage", "http://netsurf.sf.net/", + entry = ro_gui_hotlist_create_entry("NetSurf homepage", "http://netsurf.sourceforge.net/", 0xfaf, netsurf); entry->add_date = (time_t)-1; entry = ro_gui_hotlist_create_entry("NetSurf test builds", "http://netsurf.strcprstskrzkrk.co.uk/", @@ -507,7 +516,7 @@ void ro_gui_hotlist_save_as(const char *file) { /* HTML header */ - fprintf(fp, "\n\nHotlist\n\n"); + fprintf(fp, "\n\nHotlist\n\n\n"); /* Start our recursive save */ @@ -676,7 +685,7 @@ void ro_gui_hotlist_add(char *title, struct content *content) { */ void hotlist_visited(struct content *content) { if ((!content) || (!content->url)) return; - ro_gui_hotlist_visited_update(content->url, root.child_entry); + ro_gui_hotlist_visited_update(content, root.child_entry); } @@ -686,11 +695,13 @@ void hotlist_visited(struct content *content) { * \param content the content visited * \param entry the entry to check siblings and children of */ -void ro_gui_hotlist_visited_update(const char *url, struct hotlist_entry *entry) { +void ro_gui_hotlist_visited_update(struct content *content, struct hotlist_entry *entry) { + char *url; bool full = false; /* Update the hotlist */ + url = content->url; while (entry) { if ((entry->url) && (strcmp(url, entry->url) == 0)) { /* Check if we're going to need a full redraw downwards @@ -699,21 +710,16 @@ void ro_gui_hotlist_visited_update(const char *url, struct hotlist_entry *entry) /* Update our values */ + if (entry->children == 0) entry->filetype = ro_content_filetype(content); entry->visits++; entry->last_date = time(NULL); ro_gui_hotlist_update_entry_size(entry); /* Redraw the least we can get away with */ - if (entry->expanded) { - xwimp_force_redraw(hotlist_window, - full ? 0 : entry->x0, - full ? -16384 : entry->y0, - full ? 16384 : entry->x0 + entry->width, - entry->y0 + entry->height); - } + if (entry->expanded) hotlist_redraw_entry(entry, full); } - if (entry->child_entry) ro_gui_hotlist_visited_update(url, entry->child_entry); + if (entry->child_entry) ro_gui_hotlist_visited_update(content, entry->child_entry); entry = entry->next_entry; } } @@ -1040,7 +1046,6 @@ void ro_gui_hotlist_redraw(wimp_draw *redraw) { if (hotlist_toolbar) { extent.y1 += hotlist_toolbar->height; } - LOG(("Toolbar height: %i", hotlist_toolbar->height)); xwimp_set_extent(hotlist_window, &extent); state.w = hotlist_window; wimp_get_window_state(&state); @@ -1387,7 +1392,8 @@ void ro_gui_hotlist_click(wimp_pointer *pointer) { x_offset = x - entry->x0; y_offset = y - (entry->y0 + entry->height); if (((x_offset < HOTLIST_LEAF_INSET) && (y_offset > -HOTLIST_LINE_HEIGHT) && - ((buttons == wimp_CLICK_SELECT << 8) || (buttons == wimp_CLICK_ADJUST << 8))) || + ((buttons == wimp_CLICK_SELECT << 8) || (buttons == wimp_CLICK_ADJUST << 8) || + (buttons == wimp_DOUBLE_SELECT) || (buttons == wimp_DOUBLE_ADJUST))) || ((entry->children != -1) && ((buttons == wimp_DOUBLE_SELECT) || (buttons == wimp_DOUBLE_ADJUST)))) { if (entry->children != 0) { @@ -1397,9 +1403,7 @@ void ro_gui_hotlist_click(wimp_pointer *pointer) { entry->expanded = !entry->expanded; if (x_offset >= HOTLIST_LEAF_INSET) entry->selected = false; reformat_pending = true; - xwimp_force_redraw(hotlist_window, - 0, -16384, 16384, - entry->y0 + entry->height); + hotlist_redraw_entry(entry, true); } } else if (x_offset >= HOTLIST_LEAF_INSET) { @@ -1419,18 +1423,12 @@ void ro_gui_hotlist_click(wimp_pointer *pointer) { ro_gui_hotlist_selection_state(root.child_entry, false, true); entry->selected = true; - xwimp_force_redraw(hotlist_window, - entry->x0, entry->y0 + entry->height - HOTLIST_LINE_HEIGHT, - entry->x0 + entry->width, - entry->y0 + entry->height); + hotlist_redraw_entry_title(entry); + } } else if (buttons == (wimp_CLICK_ADJUST << 8)) { entry->selected = !entry->selected; - xwimp_force_redraw(hotlist_window, - entry->x0, entry->y0 + entry->height - HOTLIST_LINE_HEIGHT, - entry->x0 + entry->width, - entry->y0 + entry->height); - + hotlist_redraw_entry_title(entry); } /* Check if we should open the URL @@ -1443,6 +1441,7 @@ void ro_gui_hotlist_click(wimp_pointer *pointer) { false, true); } else { entry->selected = false; + ro_gui_dialog_close_persistant(hotlist_window); xwimp_close_window(hotlist_window); } } @@ -1624,12 +1623,7 @@ int ro_gui_hotlist_selection_state(struct hotlist_entry *entry, bool selected, b /* Redraw the entrys first line */ - if (redraw) { - xwimp_force_redraw(hotlist_window, - entry->x0, entry->y0 + entry->height - HOTLIST_LINE_HEIGHT, - entry->x0 + entry->width, - entry->y0 + entry->height); - } + if (redraw) hotlist_redraw_entry_title(entry); } /* Continue onwards @@ -1703,6 +1697,25 @@ void ro_gui_hotlist_launch_selection(struct hotlist_entry *entry) { } +/** + * Invalidate the statistics for any selected items (internal interface) + * + * \param entry the entry to update siblings and children of + */ +void ro_gui_hotlist_invalidate_statistics(struct hotlist_entry *entry) { + if (!entry) return; + while (entry) { + if ((entry->selected) && (entry->children == -1)) { + entry->visits = 0; + entry->last_date = (time_t)-1; + if (entry->expanded) hotlist_redraw_entry(entry, true); + } + if (entry->child_entry) ro_gui_hotlist_invalidate_statistics(entry->child_entry); + entry = entry->next_entry; + } +} + + /** * Set the process flag for the current selection (internal interface) * @@ -1772,11 +1785,7 @@ void ro_gui_hotlist_update_expansion(struct hotlist_entry *entry, bool only_sele /* Redraw the entrys first line */ - if (current != entry->expanded) { - xwimp_force_redraw(hotlist_window, - 0, -16384, 16384, - entry->y0 + entry->height); - } + if (current != entry->expanded) hotlist_redraw_entry(entry, true); } /* Continue onwards (child entries cannot be selected if the parent is @@ -1861,13 +1870,7 @@ void ro_gui_hotlist_selection_drag(struct hotlist_entry *entry, } else { entry->selected = true; } - if (redraw) { - xwimp_force_redraw(hotlist_window, - entry->x0, - entry->y0 + entry->height - HOTLIST_LINE_HEIGHT, - entry->x0 + entry->width, - entry->y0 + entry->height); - } + if (redraw) hotlist_redraw_entry_title(entry); } } @@ -2199,6 +2202,14 @@ void ro_gui_hotlist_set_selected(bool selected) { } +/** + * Reset the statistics for selected entries + */ +void ro_gui_hotlist_reset_statistics(void) { + ro_gui_hotlist_invalidate_statistics(root.child_entry); +} + + /** * Return the current number of selected items * diff --git a/riscos/menus.c b/riscos/menus.c index 668e09182..41fb46e42 100644 --- a/riscos/menus.c +++ b/riscos/menus.c @@ -474,6 +474,7 @@ void ro_gui_create_menu(wimp_menu *menu, int x, int y, gui_window *g) current_menu_y = y; current_gui = g; if (menu == browser_menu) { + if (!hotlist_window) browser_utilities_menu->entries[0].icon_flags |= wimp_ICON_SHADED; if (ro_gui_menu_find_object_box()) menu->entries[1].icon_flags &= ~wimp_ICON_SHADED; else @@ -576,6 +577,7 @@ void ro_gui_menu_selection(wimp_selection *selection) ro_gui_hotlist_delete_selected(); break; case 4: /* Reset usage */ + ro_gui_hotlist_reset_statistics(); break; } break; diff --git a/riscos/save.c b/riscos/save.c index e085d36e4..74b3edc5b 100644 --- a/riscos/save.c +++ b/riscos/save.c @@ -226,6 +226,10 @@ void ro_gui_save_datasave_ack(wimp_message *message) ro_gui_hotlist_save_as(path); break; } + + /* Close the save window + */ + xwimp_close_window(dialog_saveas); /* Ack successful save with message_DATA_LOAD */ message->action = message_DATA_LOAD; diff --git a/riscos/theme.c b/riscos/theme.c index b63488017..a706ac87c 100644 --- a/riscos/theme.c +++ b/riscos/theme.c @@ -225,7 +225,7 @@ int ro_theme_update_toolbar(struct toolbar *toolbar, wimp_w window) { xwimp_get_window_state(&state); state.w = toolbar->toolbar_handle; state.visible.x1 = outline.outline.x1 - 2; - state.visible.y0 = state.visible.y1 - toolbar->height; + state.visible.y0 = state.visible.y1 - toolbar->height + 2; state.xscroll = 0; state.yscroll = 0; state.next = wimp_TOP; diff --git a/riscos/toolbar.c b/riscos/toolbar.c index a7f0ea8c3..ba922e453 100644 --- a/riscos/toolbar.c +++ b/riscos/toolbar.c @@ -681,7 +681,7 @@ int ro_toolbar_update(struct toolbar *toolbar) { /* Set our return status */ - if (toolbar_height != 0) toolbar_height += 8; + if (toolbar_height != 0) toolbar_height += 8 + 2; return_status = (toolbar_height == toolbar->height); toolbar->height = toolbar_height;