Skip to content

Commit

Permalink
Improves toolbar appearance for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Sep 12, 2021
1 parent a029a49 commit 35a2fd3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Expand Up @@ -36,7 +36,9 @@
import org.eclipse.ui.swt.IFocusService;

import msi.gama.lang.gaml.ui.editor.GamlEditor;
import msi.gama.application.workbench.ThemeHelper;
import ummisco.gama.ui.bindings.GamaKeyBindings;
import ummisco.gama.ui.resources.GamaColors;
import ummisco.gama.ui.resources.IGamaColors;
import ummisco.gama.ui.utils.PlatformHelper;
import ummisco.gama.ui.views.toolbar.GamaToolbarSimple;
Expand Down Expand Up @@ -81,6 +83,7 @@ public EditorSearchControls(final GamlEditor editor) {
*/
public EditorSearchControls fill(final GamaToolbarSimple toolbar) {
Composite parent = toolbar;
Color c = parent.getBackground();
if (PlatformHelper.isWindows()) {
parent = new Composite(toolbar, SWT.NONE);
final GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
Expand All @@ -89,6 +92,7 @@ public EditorSearchControls fill(final GamaToolbarSimple toolbar) {
parent.setLayoutData(data);
final GridLayout layout = new GridLayout();
parent.setLayout(layout);
GamaColors.setBackground(parent, c);
}
find = new Text(parent, SWT.SEARCH | SWT.ICON_SEARCH);
final IFocusService focusService = editor.getSite().getService(IFocusService.class);
Expand All @@ -112,9 +116,10 @@ public void focusLost(final FocusEvent e) {
public void focusGained(final FocusEvent e) {
adjustEnablement(false, null);
incrementalOffset = -1;
}
}
});

GamaColors.setBackground(find, c);
GamaColors.setForeground(find, ThemeHelper.isDark() ? IGamaColors.VERY_LIGHT_GRAY.color() : IGamaColors.VERY_DARK_GRAY.color());
toolbar.control(parent == toolbar ? find : parent, 100);
find.addModifyListener(modifyListener);
find.addKeyListener(new KeyListener() {
Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
Expand All @@ -32,10 +33,13 @@
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.swt.IFocusService;

import msi.gama.application.workbench.ThemeHelper;
import one.util.streamex.StreamEx;
import ummisco.gama.ui.navigator.contents.ResourceManager;
import ummisco.gama.ui.navigator.contents.VirtualContent;
import ummisco.gama.ui.navigator.contents.WrappedGamaFile;
import ummisco.gama.ui.resources.GamaColors;
import ummisco.gama.ui.resources.IGamaColors;
import ummisco.gama.ui.utils.PlatformHelper;
import ummisco.gama.ui.views.toolbar.GamaToolbarSimple;

Expand Down Expand Up @@ -182,6 +186,7 @@ public void initialize() {
*/
public NavigatorSearchControl fill(final GamaToolbarSimple toolbar) {
Composite parent = toolbar;
Color c = parent.getBackground();
if (PlatformHelper.isWindows()) {
parent = new Composite(toolbar, SWT.NONE);
final GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
Expand All @@ -190,6 +195,7 @@ public NavigatorSearchControl fill(final GamaToolbarSimple toolbar) {
parent.setLayoutData(data);
final GridLayout layout = new GridLayout();
parent.setLayout(layout);
GamaColors.setBackground(parent, c);
}

find = new Text(parent, SWT.SEARCH | SWT.ICON_SEARCH);
Expand All @@ -202,7 +208,11 @@ public NavigatorSearchControl fill(final GamaToolbarSimple toolbar) {
// find.setBackground(IGamaColors.WHITE.color());
// find.setForeground(IGamaColors.BLACK.color());
find.setMessage(EMPTY);


toolbar.control(parent == toolbar ? find : parent, 100);
GamaColors.setBackground(find, c);
GamaColors.setForeground(find, ThemeHelper.isDark() ? IGamaColors.VERY_LIGHT_GRAY.color() : IGamaColors.VERY_DARK_GRAY.color());
find.addModifyListener(modifyListener);
find.addKeyListener(new KeyListener() {

Expand Down
Expand Up @@ -538,7 +538,9 @@ private ToolItem create(final String image, final String text, final String tip,
button.setImage(im);
}
if (listener != null) { button.addSelectionListener(listener); }
if (control != null) { button.setControl(control); }
if (control != null) {
//GamaColors.setBackground(control, getBackground());
button.setControl(control); }
normalizeToolbars();

return button;
Expand Down

0 comments on commit 35a2fd3

Please sign in to comment.