Skip to content

Commit

Permalink
Application: Fix default theme; fix text antialiasing in custom controls
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadelessFox committed Jun 23, 2024
1 parent 9100c02 commit 0095f26
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.shade.decima.ui;

import com.formdev.flatlaf.FlatLightLaf;
import com.shade.platform.model.Service;
import com.shade.platform.model.app.ApplicationManager;
import com.shade.platform.model.messages.Topic;
Expand All @@ -13,7 +14,7 @@
public class ApplicationSettings implements PersistableComponent<ApplicationSettings> {
public static final Topic<ApplicationSettingsChangeListener> SETTINGS = Topic.create("application settings", ApplicationSettingsChangeListener.class);

public String themeClassName;
public String themeClassName = FlatLightLaf.class.getName();
public String customFontFamily;
public int customFontSize;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.shade.platform.ui.util;

import com.formdev.flatlaf.FlatClientProperties;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.shade.platform.ui.UIColor;
import com.shade.platform.ui.controls.validation.InputValidator;
import com.shade.platform.ui.controls.validation.Validation;
Expand Down Expand Up @@ -49,7 +48,23 @@ public static int getSmallerFontSize() {
}

public static void setRenderingHints(@NotNull Graphics g) {
FlatUIUtils.setRenderingHints(g);
Graphics2D g2 = (Graphics2D) g;

Object aaHint = UIManager.get(RenderingHints.KEY_TEXT_ANTIALIASING);
if (aaHint != null) {
Object oldAA = g2.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
if (aaHint != oldAA) {
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, aaHint);
}
}

Object contrastHint = UIManager.get(RenderingHints.KEY_TEXT_LCD_CONTRAST);
if (contrastHint != null) {
Object oldContrast = g2.getRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST);
if (contrastHint != oldContrast) {
g2.setRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST, contrastHint);
}
}
}

public static void removeFrom(@NotNull Rectangle rect, @Nullable Insets insets) {
Expand Down

0 comments on commit 0095f26

Please sign in to comment.