From 2054391345b9048d9160b06559fe4a15bf888407 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Fri, 6 Jan 2006 02:56:00 +0000 Subject: [project @ 2006-01-06 02:56:00 by rjw] Stop slight tree redraw errors from wrapping of 16-bit units. Pass the data to update URL tree nodes to where applicable. svn path=/import/netsurf/; revision=1988 --- desktop/tree.c | 10 +++++----- desktop/tree.h | 4 ++-- riscos/global_history.c | 5 +++-- riscos/hotlist.c | 2 +- riscos/treeview.c | 47 +++++++++++++++++++++++++++++------------------ 5 files changed, 40 insertions(+), 28 deletions(-) diff --git a/desktop/tree.c b/desktop/tree.c index 185e7e626..c65559638 100644 --- a/desktop/tree.c +++ b/desktop/tree.c @@ -714,17 +714,17 @@ void tree_draw_node(struct tree *tree, struct node *node, int clip_x, int clip_y for (; node; node = node->next) { if (node->box.y > y_max) return; if (node->next) - tree_draw_line(tree, node->box.x - (NODE_INSTEP / 2), + tree_draw_line(node->box.x - (NODE_INSTEP / 2), node->box.y + (40 / 2), 0, node->next->box.y - node->box.y); if ((node->box.x < x_max) && (node->box.y < y_max) && (node->box.x + node->box.width + NODE_INSTEP >= clip_x) && (node->box.y + node->box.height >= clip_y)) { if ((node->expanded) && (node->child)) - tree_draw_line(tree, node->box.x + (NODE_INSTEP / 2), + tree_draw_line(node->box.x + (NODE_INSTEP / 2), node->data.box.y + node->data.box.height, 0, (40 / 2)); - tree_draw_line(tree, node->box.x - (NODE_INSTEP / 2), + tree_draw_line(node->box.x - (NODE_INSTEP / 2), node->data.box.y + node->data.box.height - (40 / 2), (NODE_INSTEP / 2) - 4, 0); @@ -1017,7 +1017,7 @@ struct node *tree_create_URL_node(struct node *parent, struct url_content *data, if (element) element->text = strdup(data->url); - tree_update_URL_node(node); + tree_update_URL_node(node, data); tree_recalculate_node(node, false); return node; @@ -1061,7 +1061,7 @@ struct node *tree_create_URL_node_shared(struct node *parent, struct url_content if (element) element->text = data->url; - tree_update_URL_node(node); + tree_update_URL_node(node, data); tree_recalculate_node(node, false); return node; diff --git a/desktop/tree.h b/desktop/tree.h index b025195c2..3306c6583 100644 --- a/desktop/tree.h +++ b/desktop/tree.h @@ -138,11 +138,11 @@ struct node *tree_get_link_details(struct tree *tree, int x, int y, /* Platform specific code */ void tree_initialise_redraw(struct tree *tree); void tree_redraw_area(struct tree *tree, int x, int y, int width, int height); -void tree_draw_line(struct tree *tree, int x, int y, int width, int height); +void tree_draw_line(int x, int y, int width, int height); void tree_draw_node_element(struct tree *tree, struct node_element *element); void tree_draw_node_expansion(struct tree *tree, struct node *node); void tree_recalculate_node_element(struct node_element *element); -void tree_update_URL_node(struct node *node); +void tree_update_URL_node(struct node *node, struct url_content *data); void tree_resized(struct tree *tree); void tree_set_node_sprite_folder(struct node *node); diff --git a/riscos/global_history.c b/riscos/global_history.c index e308ae4d6..e87577ef9 100644 --- a/riscos/global_history.c +++ b/riscos/global_history.c @@ -50,7 +50,8 @@ static bool ro_gui_global_history_click(wimp_pointer *pointer); static void ro_gui_global_history_initialise_nodes(void); static void ro_gui_global_history_initialise_node(const char *title, time_t base, int days_back); -struct node *ro_gui_global_history_find(const char *url); +static struct node *ro_gui_global_history_find(const char *url); + /* A basic window for the history */ @@ -372,7 +373,7 @@ void global_history_add(struct url_content *data) { * only the relevant portion */ tree_redraw_area(global_history_tree, 0, 0, 16384, 16384); - tree_update_URL_node(node); + tree_update_URL_node(node, data); tree_delink_node(node); tree_link_node(parent, node, false); tree_handle_node_changed(global_history_tree, diff --git a/riscos/hotlist.c b/riscos/hotlist.c index 8c3bd50d9..bd9133957 100644 --- a/riscos/hotlist.c +++ b/riscos/hotlist.c @@ -225,7 +225,7 @@ void ro_gui_hotlist_visited(struct content *content, struct tree *tree, element = tree_find_element(node, TREE_ELEMENT_URL); if ((element) && (!strcmp(element->text, content->url))) { - tree_update_URL_node(node); + tree_update_URL_node(node, NULL); tree_handle_node_changed(tree, node, true, false); } diff --git a/riscos/treeview.c b/riscos/treeview.c index fdb7d229d..3680769bd 100644 --- a/riscos/treeview.c +++ b/riscos/treeview.c @@ -157,10 +157,21 @@ void tree_redraw_area(struct tree *tree, int x, int y, int width, int height) { * \param x the width of the line * \param x the height of the line */ -void tree_draw_line(struct tree *tree, int x, int y, int width, int height) { +void tree_draw_line(int x, int y, int width, int height) { os_error *error; + int y0, y1; - assert(tree); + /* stop the 16-bit co-ordinate system from causing redraw errors */ + y1 = ro_gui_tree_origin_y - y; + if (y1 < 0) + return; + y0 = y1 - height; + if (y0 > 16384) + return; + if (y0 < 0) + y0 = 0; + if (y1 > 16384) + y1 = 16384; error = xcolourtrans_set_gcol((os_colour)0x88888800, 0, os_ACTION_OVERWRITE, 0, 0); @@ -170,11 +181,9 @@ void tree_draw_line(struct tree *tree, int x, int y, int width, int height) { warn_user("MiscError", error->errmess); return; } - error = xos_plot(os_MOVE_TO, ro_gui_tree_origin_x + x, - ro_gui_tree_origin_y - y); + error = xos_plot(os_MOVE_TO, ro_gui_tree_origin_x + x, y0); if (!error) - xos_plot(os_PLOT_TO, ro_gui_tree_origin_x + x + width, - ro_gui_tree_origin_y - y - height); + xos_plot(os_PLOT_TO, ro_gui_tree_origin_x + x + width, y1); if (error) { LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess)); @@ -308,19 +317,19 @@ void tree_draw_node_element(struct tree *tree, struct node_element *element) { 0xffffff, false, false, false, IMAGE_PLOT_TINCT_OPAQUE); - tree_draw_line(tree, element->box.x, + tree_draw_line(element->box.x, element->box.y, element->box.width - 1, 0); - tree_draw_line(tree, element->box.x, + tree_draw_line(element->box.x, element->box.y, 0, element->box.height - 3); - tree_draw_line(tree, element->box.x, + tree_draw_line(element->box.x, element->box.y + element->box.height - 3, element->box.width - 1, 0); - tree_draw_line(tree, element->box.x + element->box.width - 1, + tree_draw_line(element->box.x + element->box.width - 1, element->box.y, 0, element->box.height - 3); @@ -514,9 +523,9 @@ void tree_set_node_sprite_folder(struct node *node) { * The internal node dimensions are not updated. * * \param node the node to update + * \param data the data the node is linked to, or NULL for unlinked data */ -void tree_update_URL_node(struct node *node) { - struct url_content *data; +void tree_update_URL_node(struct node *node, struct url_content *data) { struct node_element *element; char buffer[256]; @@ -525,17 +534,19 @@ void tree_update_URL_node(struct node *node) { element = tree_find_element(node, TREE_ELEMENT_URL); if (!element) return; - data = url_store_find(element->text); - if (!data) - return; - - /* data may have moved */ - if (!node->editable) { + if (data) { + /* node is linked, update */ if (data->title) node->data.text = data->title; else node->data.text = data->url; + } else { + /* node is not link, find data */ + data = url_store_find(element->text); + if (!data) + return; } + if (element) { sprintf(buffer, "small_%.3x", ro_content_filetype_from_type(data->type)); if (ro_gui_wimp_sprite_exists(buffer)) -- cgit v1.2.3