Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul D'Pong2020-09-09 20:07:26 +0000
committerAlexander Kurtakov2020-09-14 14:06:28 +0000
commitbbfedc7fd1234f7f9a57a3b08d15c60e44221fb4 (patch)
tree9ac7700f360a4015176c4381308f66646ce7c709
parent1e36e8e63bde855e89628e468fcdb5aa0d32c33e (diff)
downloadeclipse.platform.swt-bbfedc7fd1234f7f9a57a3b08d15c60e44221fb4.tar.gz
eclipse.platform.swt-bbfedc7fd1234f7f9a57a3b08d15c60e44221fb4.tar.xz
eclipse.platform.swt-bbfedc7fd1234f7f9a57a3b08d15c60e44221fb4.zip
Bug 566730 - [GTK3] Tree.computeSizeInPixels returns wrong height if
children are expanded - Added ability for computeSizeInPixel to account for expanded children by iterating through the items of the tree checking if they are expanded and calling gtk_tree_model_iter_n_children on the item's handle. Change-Id: I04c15449c6df8b1395523d4f2de81c1c2d5fa8c3 Signed-off-by: Paul D'Pong <sdamrong@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index 63ca2a4d8b..22b097fc85 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -612,12 +612,18 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
* In GTK 3, computeNativeSize(..) sometimes just returns the header
* height as height. In that case, calculate the tree height based on
* the number of items at the root of the tree.
- * FIXME: This calculation neglects children of expanded tree items.
- * When fixing that, be careful not to use getItems (), since that
- * would realize too many VIRTUAL TreeItems (similar to bug 490203).
*/
if (hHint == SWT.DEFAULT && size.y == getHeaderHeight()) {
- size.y = getItemCount() * getItemHeightInPixels() + getHeaderHeight();
+ int itemHeight = getItemHeightInPixels();
+
+ // Initialize to height of root items & header
+ size.y = getItemCount() * itemHeight + getHeaderHeight();
+
+ for (TreeItem item : items) {
+ if (item != null && item.isExpanded) {
+ size.y += GTK.gtk_tree_model_iter_n_children (modelHandle, item.handle) * itemHeight;
+ }
+ }
}
Rectangle trim = computeTrimInPixels (0, 0, size.x, size.y);

Back to the top