Community
Participate
Working Groups
Here is the snippet that helps reproducing the bug: import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; public class button_test { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setSize(200, 200); shell.setText("Dialogs"); shell.open(); final Button opener = new Button(shell, SWT.PUSH); opener.setText("Click Me"); opener.setBounds(20, 20, 50, 25); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } Try running it in GTK2 and GTK3 and you will see that in GTK3 button is clipped to the right. I think this could be connected with calculation of the default (maybe minimal) button sizing. I would be glad if someone could take a look at this issue.
Update: If you take a look at the snippet I have provided there is one more issues: Button is clipped at the bottom as well. Here is update to the snippet that shows this problem more clearly: import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; public class button_test { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setSize(200, 200); shell.setText("Button Clipped"); shell.open(); final Button opener = new Button(shell, SWT.TOGGLE); opener.setBounds(30, 30, 50, 25); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } This issue arises because of difference in default size calculation of button and GtkLabel in GTK2 and GTK3. To solve this problem I have used CSS provider to set button default properties to zero thus button is properly shown. (works for SWT.PUSH as well as for SWT.TOGGLE). Here is the patch I propose : http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=add_css (this patch does not solve clipping-to-the-right issue but it is definitely a step forward in solving clipping issues as it solved button height clipping issue)
Pushed as it affects GTK 3 only. Thanks for the patch. Fixing one thing is still better than both being broken.
(In reply to comment #1) > Update: > > If you take a look at the snippet I have provided there is one more issues: > Button is clipped at the bottom as well. > > Here is update to the snippet that shows this problem more clearly: > > import org.eclipse.swt.*; > import org.eclipse.swt.widgets.*; > public class button_test { > > public static void main(String[] args) { > Display display = new Display(); > Shell shell = new Shell(display); > shell.setSize(200, 200); > shell.setText("Button Clipped"); > shell.open(); > > final Button opener = new Button(shell, SWT.TOGGLE); > opener.setBounds(30, 30, 50, 25); > > > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) > display.sleep(); > } > display.dispose(); > } > } > > > This issue arises because of difference in default size calculation of > button and GtkLabel in GTK2 and GTK3. > To solve this problem I have used CSS provider to set button default > properties to zero thus button is properly shown. (works for SWT.PUSH as > well as for SWT.TOGGLE). > > Here is the patch I propose : > > http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/ > commit/?h=add_css > > (this patch does not solve clipping-to-the-right issue but it is definitely > a step forward in solving clipping issues as it solved button height > clipping issue) The current patch has a problem, as it was pointed out by Aleksandr Kurtakov, it affects not only Button but also Toolitem, which probably should have different CSS style initialization. Also, as css_provider was added to SCREEN, it slowed down loading of ControlExample. What I have done to solve issues stated above: 1. Switched from adding css_provider to screen, to adding css_provider as a GtkStyleContex for widgets that require styling. 2. Added helper function initButtonStyle(), where I have put all the implementation. It is done because css styling should be added in multiple places (SWT.PUSH and SWT.TOGGLE), and it looks cleaner if implementation is in separate method. As a result Toolitem is not affected, button height-clipping issue is resolved and as style is not added to screen ControlExample loads with the same speed. Please find patch below: http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=button_init_style
Fixed http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=84c0976432fbbed8dec67966f85ffe2e213c592a This is happening because the SWTFixed was always setting the preferred size to its children. The function gtk_widget_get_preferred_size() behaves different than gtk_widget_get_child_requisition() in that it does not return the size set with gtk_widget_set_size_request(). This is how Control.resizeHandle() forces the size of the handle to match the fixedHandle (in GTK2). The fix emulates this behavior with non-deprecated API.