Skip to content

Commit

Permalink
More improvements to the management of fonts and colors
Browse files Browse the repository at this point in the history
In dialogs, parameters, side controls, and inspectors.
  • Loading branch information
AlexisDrogoul committed Jul 18, 2021
1 parent 8567531 commit 6e8ece3
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 214 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.osgi.service.prefs.BackingStoreException;
import msi.gama.common.preferences.Pref;
import msi.gaml.types.IType;
import ummisco.gama.dev.utils.DEBUG;

public class ThemeHelper {

Expand All @@ -35,6 +36,10 @@ public class ThemeHelper {

private static final List<IThemeListener> listeners = new ArrayList<>();

static {
DEBUG.ON();
}

public static final Pref<Boolean> CORE_THEME_FOLLOW =
create("pref_theme_follow", "Follow OS theme", followOSTheme(), IType.BOOL, false).in(NAME, APPEARANCE)
.restartRequired().deactivates("pref_theme_light").onChange(yes -> {
Expand Down Expand Up @@ -63,9 +68,14 @@ private static IEclipseContext getContext() {
private static Boolean followOSTheme() {
final var prefs = getSwtRendererPreferences();
final var val = prefs.get(THEME_FOLLOW_PROPERTY, null);
if ( val != null )
return Boolean.valueOf(val);
return Boolean.valueOf(System.getProperty(THEME_FOLLOW_PROPERTY, "true"));
Boolean result;
if ( val != null ) {
result = Boolean.valueOf(val);
} else {
result = Boolean.valueOf(System.getProperty(THEME_FOLLOW_PROPERTY, "true"));
}
DEBUG.OUT("Follow OS Theme: " + result);
return result;
}

private static void followOSTheme(final Boolean follow) {
Expand All @@ -81,6 +91,7 @@ private static void followOSTheme(final Boolean follow) {
}

public static boolean isDark() {
// DEBUG.OUT("Asks for isDark(): ", false);
String id;
final var themeEngine = getContext().get(IThemeEngine.class);
if ( themeEngine == null ) {
Expand All @@ -95,6 +106,7 @@ public static boolean isDark() {
final var theme = themeEngine.getActiveTheme();
id = theme == null ? null : theme.getId();
}
// DEBUG.OUT(" " + (id != null && id.contains("dark")) + " and OS is dark = " + isSystemDarkTheme());
return id != null && id.contains("dark");
}

Expand Down Expand Up @@ -146,10 +158,8 @@ private static boolean changeTo(final String id) {
if ( themeEngine == null )
return true;
final var theme = themeEngine.getActiveTheme();
if ( theme != null ) {
if ( theme.getId().startsWith(id) )
return false;
}
if ( theme != null && theme.getId().startsWith(id) )
return false;
themeEngine.setTheme(id, true);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public Label createLeftLabel(final Composite parent, final String title, final S
d.minimumWidth = 70;
d.horizontalIndent = isSubParameter ? 30 : 0;
label.setLayoutData(d);
// label.setFont(GamaFonts.getLabelfont());
label.setText(title);
label.setToolTipText(tooltip);
return label;
Expand All @@ -119,8 +118,7 @@ public Label createLeftLabel(final Composite parent, final String title, final S
@Override
protected Composite createItemContentsFor(final IAgent agent) {
final Composite attributes = super.createItemContentsFor(agent);
final Label l = createLeftLabel(attributes, "Actions", "", false);
// l.setFont(GamaFonts.getExpandfont());
createLeftLabel(attributes, "Actions", "", false);
final Composite composite = new Composite(attributes, SWT.NONE);
composite.setBackground(attributes.getBackground());
final GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
Expand Down

0 comments on commit 6e8ece3

Please sign in to comment.