mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
accent color and light/dark mode into the theme, and use with flatlaf
This commit is contained in:
@@ -35,6 +35,9 @@ import java.util.Map.Entry;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
|
||||
import com.formdev.flatlaf.FlatDarkLaf;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.FlatLightLaf;
|
||||
import processing.app.contrib.*;
|
||||
import processing.app.tools.Tool;
|
||||
import processing.app.ui.*;
|
||||
@@ -270,6 +273,7 @@ public class Base {
|
||||
Messages.log("About to create Base..."); //$NON-NLS-1$
|
||||
try {
|
||||
final Base base = new Base(args);
|
||||
base.updateTheme();
|
||||
Messages.log("Base() constructor succeeded");
|
||||
// t6 = System.currentTimeMillis();
|
||||
|
||||
@@ -299,6 +303,18 @@ public class Base {
|
||||
|
||||
|
||||
public void updateTheme() {
|
||||
try {
|
||||
FlatLaf laf = "dark".equals(Theme.get("laf.mode")) ?
|
||||
new FlatDarkLaf() : new FlatLightLaf();
|
||||
laf.setExtraDefaults(Collections.singletonMap("@accentColor",
|
||||
Theme.get("laf.accent.color")));
|
||||
//UIManager.setLookAndFeel(laf);
|
||||
FlatLaf.setup(laf);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ContributionManager.updateTheme();
|
||||
for (Editor editor : getEditors()) {
|
||||
editor.updateTheme();
|
||||
|
||||
@@ -32,11 +32,15 @@ import javax.swing.UIManager;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
import javax.swing.text.StyleContext;
|
||||
|
||||
import com.formdev.flatlaf.FlatDarkLaf;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.FlatLightLaf;
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Preferences;
|
||||
import processing.app.ui.Theme;
|
||||
import processing.app.ui.Toolkit;
|
||||
import processing.awt.ShimAWT;
|
||||
import processing.core.PApplet;
|
||||
@@ -111,13 +115,20 @@ public class DefaultPlatform {
|
||||
String laf = Preferences.get("editor.laf");
|
||||
if (laf == null || laf.length() == 0) { // normal situation
|
||||
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
// Default was 8x8, but that's not enough with the insets and rounded rect
|
||||
// https://github.com/processing/processing4/issues/473
|
||||
//System.out.println(UIManager.get("ScrollBar.minimumThumbSize"));
|
||||
//UIManager.put("ScrollBar.minimumThumbSize", new Dimension(16, 24));
|
||||
|
||||
// dummy font call so that it's registered for the LaF
|
||||
Toolkit.getSansFont(12, Font.PLAIN);
|
||||
|
||||
com.formdev.flatlaf.FlatLaf.registerCustomDefaultsSource("processing.app.ui");
|
||||
UIManager.setLookAndFeel(new com.formdev.flatlaf.FlatLightLaf());
|
||||
|
||||
FlatLaf.registerCustomDefaultsSource("processing.app.ui");
|
||||
//if ("dark".equals(Theme.get("laf.mode"))) {
|
||||
//UIManager.setLookAndFeel(new FlatDarkLaf());
|
||||
//} else {
|
||||
UIManager.setLookAndFeel(new FlatLightLaf());
|
||||
//}
|
||||
UIManager.put("ScrollBar.width", 16);
|
||||
|
||||
} else {
|
||||
@@ -145,11 +156,6 @@ public class DefaultPlatform {
|
||||
// Font font = new Font(fontName, Font.PLAIN, fontSize).deriveFont(attributes);
|
||||
// setUIFont(new FontUIResource(font));
|
||||
}
|
||||
|
||||
// Default was 8x8, but that's not enough with the insets and rounded rect
|
||||
// https://github.com/processing/processing4/issues/473
|
||||
//System.out.println(UIManager.get("ScrollBar.minimumThumbSize"));
|
||||
UIManager.put("ScrollBar.minimumThumbSize", new Dimension(16, 24));
|
||||
}
|
||||
|
||||
// // Adapted from https://stackoverflow.com/a/64667581/18247494
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
# The gradient.top and gradient.bottom lines are used by makeGradient(),
|
||||
# so search for makeGradient() calls to see whether they're still in use.
|
||||
|
||||
## Look-and-Feel Entries ##
|
||||
|
||||
laf.mode = dark
|
||||
laf.accent.color = #cc0000
|
||||
|
||||
|
||||
## EditorToolbar ##
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ X rewrite language selector to use fallback fonts
|
||||
X add manager.panel constants for colors
|
||||
X status panel not updating in updateTheme()
|
||||
X StatusPanel.getBodyStyle() has hard-coded fonts/sizes
|
||||
_ accent color and light/dark mode into the theme, and use with flatlaf
|
||||
X accent color and light/dark mode into the theme, and use with flatlaf
|
||||
_ monochrome icon for foundation
|
||||
_ icons for contrib manager list entries (green/orange PNGs won't do)
|
||||
_ remove ability to rearrange columns in contrib manager
|
||||
|
||||
Reference in New Issue
Block a user