From 24d83b7798d112d095fa30684a01c2c7bc1d8a7a Mon Sep 17 00:00:00 2001 From: ix0rai Date: Sat, 9 Dec 2023 23:10:18 -0600 Subject: [PATCH] strip out some pointless laf stuff --- .../main/java/org/quiltmc/enigma/gui/Gui.java | 2 +- .../org/quiltmc/enigma/gui/config/Config.java | 14 +++++----- .../enigma/gui/config/theme/Themes.java | 12 --------- .../enigma/gui/element/EditorTabbedPane.java | 1 - .../quiltmc/enigma/gui/panel/EditorPanel.java | 26 +------------------ 5 files changed, 9 insertions(+), 46 deletions(-) diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/Gui.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/Gui.java index 3dccc76b1..f8e676d58 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/Gui.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/Gui.java @@ -131,7 +131,7 @@ public Gui(EnigmaProfile profile, Set editableTypes, boolean visib this.setupUi(); LanguageUtil.addListener(this::retranslateUi); - Themes.addListener((lookAndFeel, boxHighlightPainters) -> SwingUtilities.updateComponentTreeUI(this.getFrame())); + //Themes.addListener((lookAndFeel, boxHighlightPainters) -> SwingUtilities.updateComponentTreeUI(this.getFrame())); this.mainWindow.setVisible(visible); } diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/Config.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/Config.java index 3626e2c05..742154ab3 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/Config.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/Config.java @@ -97,11 +97,11 @@ public static DecompilerConfig decompiler() { public static Theme currentTheme() { return switch (activeLookAndFeel) { - case DEFAULT -> MAIN.defaultTheme; - case DARCULA -> MAIN.darculaTheme; - case METAL -> MAIN.metalTheme; - case SYSTEM -> MAIN.systemTheme; - case NONE -> MAIN.noneTheme; + case DEFAULT -> main().defaultTheme; + case DARCULA -> main().darculaTheme; + case METAL -> main().metalTheme; + case SYSTEM -> main().systemTheme; + case NONE -> main().noneTheme; }; } @@ -114,11 +114,11 @@ public static Theme.Fonts currentFonts() { } public static void insertRecentProject(String jarPath, String mappingsPath) { - MAIN.recentProjects.value().add(0, new RecentProject(jarPath, mappingsPath)); + main().recentProjects.value().add(0, new RecentProject(jarPath, mappingsPath)); } public static RecentProject getMostRecentProject() { - return MAIN.recentProjects.value().get(0); + return main().recentProjects.value().get(0); } public record RecentProject(String jarPath, String mappingsPath) implements ConfigSerializableObject> { diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/theme/Themes.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/theme/Themes.java index 2ac0d20cd..bd29f6ba2 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/theme/Themes.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/theme/Themes.java @@ -15,8 +15,6 @@ import javax.swing.UIManager; public class Themes { - private static final Set listeners = new HashSet<>(); - // Calling this after the UI is initialized (e.g. when the user changes // theme settings) is currently not functional. public static void setupTheme() { @@ -27,8 +25,6 @@ public static void setupTheme() { Themes.setFonts(); UIManager.put("ScrollBar.showButtons", true); JEditorPane.registerEditorKitForContentType("text/enigma-sources", JavaSyntaxKit.class.getName()); - Map boxHighlightPainters = getBoxHighlightPainters(); - listeners.forEach(l -> l.onThemeChanged(laf, boxHighlightPainters)); ScaleUtil.applyScaling(); Config.updateSyntaxpain(); } @@ -88,12 +84,4 @@ public static Map getBoxHighlightPainters() { TokenType.DEBUG, BoxHighlightPainter.create(Config.currentColors().debugToken.value(), Config.currentColors().debugTokenOutline.value()) ); } - - public static void addListener(ThemeChangeListener listener) { - listeners.add(listener); - } - - public static void removeListener(ThemeChangeListener listener) { - listeners.remove(listener); - } } diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/element/EditorTabbedPane.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/element/EditorTabbedPane.java index 31fd56aa6..7c491659f 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/element/EditorTabbedPane.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/element/EditorTabbedPane.java @@ -43,7 +43,6 @@ public EditorPanel openClass(ClassEntry entry) { if (ch == null) return null; this.navigator = new NavigatorPanel(this.gui); EditorPanel ed = new EditorPanel(this.gui, this.navigator); - ed.setup(); ed.setClassHandle(ch); this.openFiles.addTab(ed.getFileName(), ed.getUi()); diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/panel/EditorPanel.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/panel/EditorPanel.java index 2a061ad4d..66707473d 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/panel/EditorPanel.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/panel/EditorPanel.java @@ -9,14 +9,12 @@ import org.quiltmc.enigma.gui.EditableType; import org.quiltmc.enigma.gui.Gui; import org.quiltmc.enigma.gui.GuiController; -import org.quiltmc.enigma.gui.config.theme.LookAndFeel; import org.quiltmc.enigma.gui.config.theme.Themes; import org.quiltmc.enigma.gui.config.Config; import org.quiltmc.enigma.gui.config.keybind.KeyBinds; import org.quiltmc.enigma.gui.element.EditorPopupMenu; import org.quiltmc.enigma.gui.element.NavigatorPanel; import org.quiltmc.enigma.gui.event.EditorActionListener; -import org.quiltmc.enigma.gui.event.ThemeChangeListener; import org.quiltmc.enigma.gui.highlight.BoxHighlightPainter; import org.quiltmc.enigma.gui.highlight.SelectionHighlightPainter; import org.quiltmc.enigma.gui.util.GridBagConstraintsBuilder; @@ -97,14 +95,11 @@ public class EditorPanel { private boolean mouseIsPressed = false; private boolean shouldNavigateOnClick; - public LookAndFeel editorLaf; private int fontSize = 12; - private Map boxHighlightPainters; + private final Map boxHighlightPainters; private final List listeners = new ArrayList<>(); - private final ThemeChangeListener themeChangeListener; - private ClassHandle classHandle; private DecompiledClassSource source; private boolean settingSource; @@ -210,20 +205,6 @@ public void keyReleased(KeyEvent event) { this.retryButton.addActionListener(e -> this.redecompileClass()); - this.themeChangeListener = (laf, boxHighlightPainters) -> { - if ((this.editorLaf == null || this.editorLaf != laf)) { - this.editor.updateUI(); - this.editor.setBackground(Config.currentColors().editorBackground.value()); - if (this.editorLaf != null) { - this.classHandle.invalidateMapped(); - } - - this.editorLaf = laf; - } - - this.boxHighlightPainters = boxHighlightPainters; - }; - this.ui.putClientProperty(EditorPanel.class, this); } @@ -289,12 +270,7 @@ public void onDeleted(ClassHandle h) { this.listeners.forEach(l -> l.onClassHandleChanged(this, old, handle)); } - public void setup() { - Themes.addListener(this.themeChangeListener); - } - public void destroy() { - Themes.removeListener(this.themeChangeListener); this.classHandle.close(); }