Commit 05062529 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

Clean up height code a bit. I don't think it's completely correct yet, but

Fri Nov  2 16:45:17 2001  Jonathan Blandford  <jrb@redhat.com>

	* gtk/gtkrbtree.c (_gtk_rbtree_remove_node): Clean up height code
	a bit.  I don't think it's completely correct yet, but it's
	getting there.
parent 44934dca
Fri Nov 2 16:45:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbtree_remove_node): Clean up height code
a bit. I don't think it's completely correct yet, but it's
getting there.
Fri Nov 2 16:14:15 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkviewport.c (gtk_viewport_size_request): Remove
......
Fri Nov 2 16:45:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbtree_remove_node): Clean up height code
a bit. I don't think it's completely correct yet, but it's
getting there.
Fri Nov 2 16:14:15 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkviewport.c (gtk_viewport_size_request): Remove
......
Fri Nov 2 16:45:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbtree_remove_node): Clean up height code
a bit. I don't think it's completely correct yet, but it's
getting there.
Fri Nov 2 16:14:15 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkviewport.c (gtk_viewport_size_request): Remove
......
Fri Nov 2 16:45:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbtree_remove_node): Clean up height code
a bit. I don't think it's completely correct yet, but it's
getting there.
Fri Nov 2 16:14:15 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkviewport.c (gtk_viewport_size_request): Remove
......
Fri Nov 2 16:45:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbtree_remove_node): Clean up height code
a bit. I don't think it's completely correct yet, but it's
getting there.
Fri Nov 2 16:14:15 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkviewport.c (gtk_viewport_size_request): Remove
......
Fri Nov 2 16:45:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbtree_remove_node): Clean up height code
a bit. I don't think it's completely correct yet, but it's
getting there.
Fri Nov 2 16:14:15 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkviewport.c (gtk_viewport_size_request): Remove
......
Fri Nov 2 16:45:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbtree_remove_node): Clean up height code
a bit. I don't think it's completely correct yet, but it's
getting there.
Fri Nov 2 16:14:15 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkviewport.c (gtk_viewport_size_request): Remove
......
......@@ -1055,6 +1055,8 @@ _gtk_rbtree_remove_node (GtkRBTree *tree,
GtkRBNode *x, *y;
GtkRBTree *tmp_tree;
GtkRBNode *tmp_node;
gint node_height;
gint y_height;
g_return_if_fail (tree != NULL);
g_return_if_fail (node != NULL);
......@@ -1066,7 +1068,8 @@ _gtk_rbtree_remove_node (GtkRBTree *tree,
if (gtk_debug_flags & GTK_DEBUG_TREE)
_gtk_rbtree_test (G_STRLOC, tree);
if (node->left == tree->nil || node->right == tree->nil)
{
y = node;
......@@ -1086,15 +1089,17 @@ _gtk_rbtree_remove_node (GtkRBTree *tree,
/* y->count = node->count; */
/* offsets and parity adjust all the way up through parent trees */
y_height = GTK_RBNODE_GET_HEIGHT (y);
node_height = GTK_RBNODE_GET_HEIGHT (node) + (node->children?node->children->root->offset:0);
/* Do this twice for code clarities sake. */
tmp_tree = tree;
tmp_node = y;
while (tmp_tree && tmp_node && tmp_node != tmp_tree->nil)
{
/* tmp_node->offset -= y->offset; */
tmp_node->parity -= (guint) 1; /* parity of y is always 1 */
tmp_node->offset -= (y_height + (y->children?y->children->root->offset:0));
tmp_node->parity -= (1 + (y->children?y->children->root->parity:0));
tmp_node = tmp_node->parent;
if (tmp_node == tmp_tree->nil)
{
......@@ -1102,7 +1107,7 @@ _gtk_rbtree_remove_node (GtkRBTree *tree,
tmp_tree = tmp_tree->parent_tree;
}
}
/* x is y's only child */
if (y->left != tree->nil)
x = y->left;
......@@ -1121,12 +1126,35 @@ _gtk_rbtree_remove_node (GtkRBTree *tree,
if (y != node)
{
gint diff;
/* Copy the node over */
if (GTK_RBNODE_GET_COLOR (node) == GTK_RBNODE_BLACK)
node->flags = ((y->flags & (GTK_RBNODE_NON_COLORS)) | GTK_RBNODE_BLACK);
else
node->flags = ((y->flags & (GTK_RBNODE_NON_COLORS)) | GTK_RBNODE_RED);
node->children = y->children;
/* We want to see how different our height is from the previous node.
* To do this, we compare our current height with our supposed height.
*/
diff = y_height - GTK_RBNODE_GET_HEIGHT (node);
if (diff != 0)
{
tmp_tree = tree;
tmp_node = node;
while (tmp_tree && tmp_node && tmp_node != tmp_tree->nil)
{
tmp_node->offset += diff;
tmp_node = tmp_node->parent;
if (tmp_node == tmp_tree->nil)
{
tmp_node = tmp_tree->parent_node;
tmp_tree = tmp_tree->parent_tree;
}
}
}
}
if (GTK_RBNODE_GET_COLOR (y) == GTK_RBNODE_BLACK)
......
......@@ -3012,7 +3012,7 @@ gtk_tree_view_focus_out (GtkWidget *widget,
}
/* Incremental Reflow */
#if 0
static void
validate_visible_area (GtkTreeView *tree_view)
{
......@@ -3045,7 +3045,7 @@ install_presize_handler (GtkTreeView *tree_view)
{
}
#endif
/* Drag-and-drop */
static void
......
......@@ -312,8 +312,6 @@ void gtk_tree_view_set_destroy_count_func (GtkTreeView *tree_view,
GtkDestroyNotify destroy);
#ifdef __cplusplus
}
#endif /* __cplusplus */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment