diff options
author | fvogel <fvogelnew1@free.fr> | 2024-09-14 09:12:29 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2024-09-14 09:12:29 (GMT) |
commit | a850e99ee0b543eda99379868bf747b8f1614762 (patch) | |
tree | 3a4bcf4bd3905503dfd3ba807277bab06a7543ad | |
parent | 5c7e60e24ab666695b0c9ee22ab3f2dd1807d48d (diff) | |
download | tk-a850e99ee0b543eda99379868bf747b8f1614762.zip tk-a850e99ee0b543eda99379868bf747b8f1614762.tar.gz tk-a850e99ee0b543eda99379868bf747b8f1614762.tar.bz2 |
Fix [8e9d65d2d4]: Unexpected behavior of ttk::treeview with detached items - Part 2 ([bbox] command).
-rw-r--r-- | generic/ttk/ttkTreeview.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index 582baa4..356c27b 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1741,6 +1741,13 @@ static int DisplayRow(int row, Treeview *tv) return row - tv->tree.yscroll.first + tv->tree.titleRows; } +/* Is an item detached? The root is never detached. */ +static int IsDetached(Treeview* tv, TreeItem* item) +{ + return item->next == NULL && item->prev == NULL && + item->parent == NULL && item != tv->tree.root; +} + /* + BoundingBox -- * Compute the parcel of the specified column of the specified item, * (or the entire item if column is NULL) @@ -1754,6 +1761,7 @@ static int BoundingBox( { int dispRow; Ttk_Box bbox = tv->tree.treeArea; + TreeItem *parent; /* Make sure the scroll information is current before use */ TtkUpdateScrollInfo(tv->tree.xscrollHandle); @@ -1767,6 +1775,12 @@ static int BoundingBox( /* not viewable, or off-screen */ return 0; } + for (parent = item; parent; parent = parent->parent) { + if (IsDetached(tv, parent)) { + /* detached, or ancestor detached */ + return 0; + } + } bbox.y += dispRow * tv->tree.rowHeight; bbox.height = tv->tree.rowHeight * item->height; @@ -3347,13 +3361,6 @@ static int TreeviewDetachCommand( return TCL_OK; } -/* Is an item detached? The root is never detached. */ -static int IsDetached(Treeview *tv, TreeItem *item) -{ - return item->next == NULL && item->prev == NULL && - item->parent == NULL && item != tv->tree.root; -} - /* + $tv detached ?$item? -- * List detached items (in arbitrary order) or query the detached state of * $item. |