Polish node deletion.

This commit is contained in:
Michael Drake 2013-08-30 13:29:19 +01:00
parent 09f5b0e95f
commit 9a59103c6a
2 changed files with 21 additions and 9 deletions

View File

@ -1066,6 +1066,7 @@ static nserror treeview_delete_node_internal(treeview *tree, treeview_node *n,
/* Inform front end of change in dimensions */
if (tree->root != NULL && p != NULL && p->flags & TREE_NODE_EXPANDED &&
nd.h_reduction > 0 &&
!(flags & TREE_OPTION_SUPPRESS_RESIZE)) {
tree->cw_t->update_size(tree->cw_h, -1,
tree->root->height);
@ -1183,7 +1184,6 @@ nserror treeview_delete_node(treeview *tree, treeview_node *n,
nserror err;
struct rect r;
treeview_node *p;
int h;
assert(tree != NULL);
assert(n != NULL);
@ -1197,16 +1197,21 @@ nserror treeview_delete_node(treeview *tree, treeview_node *n,
if (err != NSERROR_OK)
return err;
h = tree->root->height;
if (tree->flags & TREEVIEW_DEL_EMPTY_DIRS) {
int h = tree->root->height;
/* Delete any empty nodes */
err = treeview_delete_empty_nodes(tree, false);
if (err != NSERROR_OK)
return err;
}
/* Inform front end of change in dimensions */
if (tree->root->height != h && !(flags & TREE_OPTION_SUPPRESS_RESIZE)) {
tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
if (tree->root->height != h) {
r.y0 = 0;
if (!(flags & TREE_OPTION_SUPPRESS_RESIZE)) {
tree->cw_t->update_size(tree->cw_h, -1,
tree->root->height);
}
}
}
/* Redraw */
@ -2461,9 +2466,16 @@ bool treeview_keypress(treeview *tree, uint32_t key)
redraw = treeview_delete_selection(tree, &r);
if (tree->flags & TREEVIEW_DEL_EMPTY_DIRS) {
int h = tree->root->height;
/* Delete any empty nodes */
err = treeview_delete_empty_nodes(tree, true);
err = treeview_delete_empty_nodes(tree, false);
/* Inform front end of change in dimensions */
if (tree->root->height != h) {
r.y0 = 0;
tree->cw_t->update_size(tree->cw_h, -1,
tree->root->height);
}
}
break;
case KEY_CR:

View File

@ -48,7 +48,7 @@ typedef enum {
TREE_OPTION_NONE = (0), /* No flags set */
TREE_OPTION_SUPPRESS_RESIZE = (1 << 0), /* Suppress callback */
TREE_OPTION_SUPPRESS_REDRAW = (1 << 1) /* Suppress callback */
} treeview_node_options_flags; /**< Node creation settings */
} treeview_node_options_flags; /**< Node change handling options */
typedef enum {
TREEVIEW_NO_FLAGS = (0), /**< No flags set */