diff options
author | Simeon Andreev | 2019-06-06 11:18:09 +0000 |
---|---|---|
committer | Eric Williams | 2019-06-18 14:42:54 +0000 |
commit | 31781bf0c9e88b424f33f8fb5e566302cc6f2e79 (patch) | |
tree | c31ea3eebce39157de983356318595da4da86037 | |
parent | 9270e7077c6a9288b57223989a2308a5885cd5a7 (diff) | |
download | eclipse.platform.swt-31781bf0c9e88b424f33f8fb5e566302cc6f2e79.tar.gz eclipse.platform.swt-31781bf0c9e88b424f33f8fb5e566302cc6f2e79.tar.xz eclipse.platform.swt-31781bf0c9e88b424f33f8fb5e566302cc6f2e79.zip |
Bug 547986 - [GTK3] Table editor at first row not painted
The fix for bug 535978 introduces a regression, namely first row editor
table/tree editors are not drawn if the table/tree has a header.
This is the case, since Composite.propagateDraw will lower the GTK+
window of children widgets, if their placement is "underneath" the
table/tree header height. This is done to prevent widgets from being
drawn on top of the table/tree header when the table/tree is scrolled
down.
The check whether the widget is placed "underneath" the header is done
with the assumption that widgets in the table/tree client area have y
values (of their GTK+ allocation) starting below the header (e.g.
starting from 20+ pixels). However, those y values start with 0. As a
result, widgets of the first row are always considered to be
"underneath" the table/tree header and are so not painted.
With this change, only widgets with negative y values are considered to
be "underneath" the table/tree header. A negative y value (of the GTK+
allocation) results from scrolling down, since the widget (e.g. a
table/tree editor) starts "before" the table/tree client area.
As a result, the first row shows children widgets (such as editors) of
tables/trees. When scrolling down, widgets become not visible as soon as
part of them is covered by the table/tree header. This is not optimal
(ideally they should be partially visible), but should be enough. The
SWT mechanism to paint children (such as editors) in tables/trees does
not use native GTK mechanism but builds on top. So drawing such children
widgets partially is likely not possible or is very difficult.
Change-Id: I06e125a874895c00c40d2ccfd147c9f6ed3bf210
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
3 files changed, 14 insertions, 20 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java index 36c42bcdd0..33c10508c8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java @@ -90,13 +90,13 @@ public class Composite extends Scrollable { static final String NO_INPUT_METHOD = "org.eclipse.swt.internal.gtk.noInputMethod"; //$NON-NLS-1$ Shell popupChild; /** - * A Rectangle which, if specified, denotes an area where child widgets - * should not be drawn. Only relevant if such child widgets are being + * If set to {@code true}, child widgets with negative y coordinate GTK allocation + * will not be drawn. Only relevant if such child widgets are being * drawn via propagateDraw(), such as Tree/Table editing widgets. * - * See bug 535978. + * See bug 535978 and bug 547986. */ - Rectangle noChildDrawing = null; + boolean noChildDrawing = false; /** * A HashMap of child widgets that keeps track of which child has had their * GdkWindow lowered/raised. Only relevant if such child widgets are being @@ -1433,7 +1433,7 @@ void propagateDraw (long container, long cairo) { if (child != 0) { Widget widget = display.getWidget (child); if (widget != this) { - if (noChildDrawing != null) { + if (noChildDrawing) { Boolean childLowered = childrenLowered.get(widget); if (childLowered == null) { childrenLowered.put(widget, false); @@ -1441,7 +1441,7 @@ void propagateDraw (long container, long cairo) { } GtkAllocation allocation = new GtkAllocation (); GTK.gtk_widget_get_allocation(child, allocation); - if ((allocation.y + allocation.height) < noChildDrawing.height) { + if (allocation.y < 0) { if (!childLowered) { if (GTK.GTK4) { long surface = gtk_widget_get_surface(child); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java index 4a539aba02..2cb84f7a88 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java @@ -2535,7 +2535,7 @@ void propagateDraw (long container, long cairo) { * "noChildDrawing" widgets might still be partially drawn. */ super.propagateDraw(container, cairo); - if (headerVisible && noChildDrawing != null && wasScrolled) { + if (headerVisible && noChildDrawing && wasScrolled) { for (TableColumn column : columns) { if (column != null) { GTK.gtk_widget_queue_draw(column.buttonHandle); @@ -4175,15 +4175,12 @@ long windowProc (long handle, long arg0, long user_data) { */ if (hasChildren) { /* - * If headers are visible, set noChildDrawing to their - * dimensions -- this will prevent any child widgets from drawing + * If headers are visible, set noChildDrawing to true + * this will prevent any child widgets from drawing * over the header buttons. See bug 535978. */ if (headerVisible) { - GdkRectangle rect = new GdkRectangle (); - GDK.gdk_cairo_get_clip_rectangle (arg0, rect); - // -1's is for the 1px of padding between the fixedHandle and handle - noChildDrawing = new Rectangle(0, 0, rect.width - 1, this.headerHeight - 1); + noChildDrawing = true; } propagateDraw(handle, arg0); } 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 af67fbb6c6..0ef25d72fa 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 @@ -2723,7 +2723,7 @@ void propagateDraw (long container, long cairo) { * "noChildDrawing" widgets might still be partially drawn. */ super.propagateDraw(container, cairo); - if (headerVisible && noChildDrawing != null && wasScrolled) { + if (headerVisible && noChildDrawing && wasScrolled) { for (TreeColumn column : columns) { if (column != null) { GTK.gtk_widget_queue_draw(column.buttonHandle); @@ -4149,15 +4149,12 @@ long windowProc (long handle, long arg0, long user_data) { */ if (hasChildren) { /* - * If headers are visible, set noChildDrawing to their - * dimensions -- this will prevent any child widgets from drawing + * If headers are visible, set noChildDrawing to true + * this will prevent any child widgets from drawing * over the header buttons. See bug 535978. */ if (headerVisible) { - GdkRectangle rect = new GdkRectangle (); - GDK.gdk_cairo_get_clip_rectangle (arg0, rect); - // -1's is for the 1px of padding between the fixedHandle and handle - noChildDrawing = new Rectangle(0, 0, rect.width - 1, this.headerHeight - 1); + noChildDrawing = true; } propagateDraw(handle, arg0); } |