Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolbar Items with text using different font colors on Windows and Mac #1696

Open
tobiasmelcher opened this issue Dec 27, 2024 · 4 comments
Open

Comments

@tobiasmelcher
Copy link
Contributor

Following SWT code snippet is creating a label and a toolbar with one item.

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.resource.ImageDescriptor;

public class ToolbarExample {
	public static void main(String[] args) {
		Display display= new Display();

		Shell shell= new Shell(display);
		shell.setText("Toolbar Example");
		shell.setLayout(new GridLayout(1, false));

		Label label= new Label(shell, SWT.NONE);
		label.setText("Label");

		var tm= new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
		var action= new Action("Toolbar Action") {
			@Override
			public void run() {
			}
		};
		action.setImageDescriptor(ImageDescriptor.createFromImage(display.getSystemImage(SWT.ICON_INFORMATION)));
		var aci= new ActionContributionItem(action);
		aci.setMode(ActionContributionItem.MODE_FORCE_TEXT);
		tm.add(aci);

		ToolBar fToolBar= tm.createControl(shell);
		GridData gd= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
		fToolBar.setLayoutData(gd);

		shell.pack();
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		display.dispose();
	}
}

The result looks different on Windows on Mac:

Windows:
toolbar_windows

Mac:
toolbar_mac

Why is using the Mac SWT implementation a different font color for the toolbar item compared to Windows? For the label, both implementations are using a black font.
Are all toolbar item texts on Mac rendered with a gray-isch font? So, is it intended that toolbars are rendered differently with a native look and feel on each platform?
I personally think that the toolbar item texts should be rendered with the same color on each platform. What do you think?

@BeckerWdf
Copy link
Contributor

So in the IDE we can see this e.g. in the "perspective switcher" (when the "show text" option is turned on), correct?

@tobiasmelcher
Copy link
Contributor Author

tobiasmelcher commented Dec 30, 2024

yes, exactly, here some more screenshots from the perspective switcher.

Windows Light Mode:
windows_light

MacOS Light Mode:
mac_light

Black color is used as foreground for the View title text (Outline, Variabl...) on both platforms consistently; but not for the texts in the perspective switcher (Debug, Java). Why?

Windows Dark Mode:
windows_dark

MacOS Dark Mode:
mac_dark

In dark mode both platforms use a white color as foreground in the perspective switcher texts. (On windows, the text cannot be read in dark mode, but this is worth for another issue)
So, why using different foreground colors in light mode on Windows and MacOS but not in dark mode?

@BeckerWdf
Copy link
Contributor

In dark mode both platforms use a white color as foreground in the perspective switcher texts. (On windows, the text cannot be read in dark mode, but this is worth for another issue)

I think it's this: eclipse-platform/eclipse.platform.ui#2570

@MikeMCrank
Copy link

MikeMCrank commented Jan 2, 2025

I've been exploring possible solutions for eclipse-platform/eclipse.platform.ui#2570, looks like I have a bit more work to do in order to handle text in toolbar buttons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants