| Summary: | [GTK3] Combo improvements in background/foreground for gtk3 | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Leo Ufimtsev <lufimtse> | ||||
| Component: | SWT | Assignee: | Leo Ufimtsev <lufimtse> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Leo Ufimtsev <lufimtse> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | akurtako, akurtakov, Lars.Vogel, platform-swt-inbox | ||||
| Version: | 4.4 | ||||||
| Target Milestone: | 4.5 M7 | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| See Also: |
https://git.eclipse.org/r/43481 https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=f33dffd35460bbb5ed61c774ae7f89f06ed9eb7f https://git.eclipse.org/r/45415 https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=41bdd68738c0b4aa849e6a0d483da956ec49ea3d https://bugs.eclipse.org/bugs/show_bug.cgi?id=531573 |
||||||
| Whiteboard: | |||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 464228 | ||||||
| Attachments: |
|
||||||
|
Description
Leo Ufimtsev
Submitted single patch that addresses both as functionality was very similar. Incremental change to make Combo use rgba for foreground on Gtk3. This also fixes combo's background for Gtk3, so that the Junit test now works in gtk3. object_set_..rgba required special attention. I added a line to os.h so that it would also compile on gtk2 (as the GdkRGBA in the paramater list is gtk3 only). (As per suggestion of Alex.K) Also introducing PRE_GTK3 constant for code clarity and readability. Please review: https://git.eclipse.org/r/43481 Removed code from the patch that wasn't directly related to the fix. Gerrit change https://git.eclipse.org/r/43481 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=f33dffd35460bbb5ed61c774ae7f89f06ed9eb7f patch was merged. (In reply to Leo Ufimtsev from comment #4) > patch was merged. I think this does not work. Here is a small snippet to check that the background of the combo is not set: /******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.snippets; /* * CCombo example snippet: create a CCombo (read-only, flat) * * For a list of all SWT example snippets see * http://www.eclipse.org/swt/snippets/ */ import org.eclipse.swt.*; import org.eclipse.swt.custom.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class Snippet39 { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); Combo combo = new Combo(shell, SWT.READ_ONLY | SWT.FLAT | SWT.BORDER); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); for (int i = 0; i < 5; i++) { combo.add("item" + i); } combo.setText("item0"); Color red = new Color (Display.getCurrent(), 255, 0, 0); combo.setBackground(red); combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { System.out.println("Item selected"); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } Created attachment 251695 [details]
Screenshot
Aha, the problem is visible for read only combos. It works for non-readonly. I'll investigate It seems that an SWT.Combo READ_ONLY is made up of nested Gtk Widgets:
GtkComboBoxText and inside it a:
GtkToggleButton
Applying a color to GtkComboBoxText doesn't perculate down to the GtkToggleButton inside.
A fix would be to manually force it down to it's children like:
GtkComboBoxText GtkToggleButton {
background: yellow;
}
I wonder if this is a Gtk bug.
I'll continue to research this.
New Gerrit change created: https://git.eclipse.org/r/45415 I wrote patch #2: https://git.eclipse.org/r/#/c/45415/ This fixes background for - read-only combos - partially colors the background in the drop down menu. Now Eclipse looks like this with Dark OS theme and Dark Eclipse theme: - Dark buttons - Dark Read-only combo-boxes https://coffeeorientedprogramming.files.wordpress.com/2015/04/eclipse-dark-looks.png Limitations: - That said, GtkComboBoxText is composed of multiple widgets and some of those are tucked away in a private struct. As such, we can't style all of SWT combo. For instance we can style the Entry and the background of the text in the menu, but we can't style the down-button and can't style the menu background of the pop-up menu. Those can only be styled by global CSS. So if combo's menu/button doesn't look right, the OS's CSS needs to be changed. I wrote an elaborate article on this for those interested in the details: https://coffeeorientedprogramming.wordpress.com/2015/04/07/eclipse-dark-theme-and-gtk-what-eclipse-can-theme-and-what-needs-to-be-themed-by-the-os/ Any feedback is appreciated. (In reply to Leo Ufimtsev from comment #11) > I wrote patch #2: > https://git.eclipse.org/r/#/c/45415/ > > This fixes background for > - read-only combos > - partially colors the background in the drop down menu. > > Now Eclipse looks like this with Dark OS theme and Dark Eclipse theme: > - Dark buttons > - Dark Read-only combo-boxes > https://coffeeorientedprogramming.files.wordpress.com/2015/04/eclipse-dark- > looks.png Beautiful. Please merge this, this is an amazing enhancement. Gerrit change https://git.eclipse.org/r/45415 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=41bdd68738c0b4aa849e6a0d483da956ec49ea3d Nice one. In master now. |