From 04b01512c124c76f3b3d99ba07ef30ea6a90b52f Mon Sep 17 00:00:00 2001 From: 2xsaiko Date: Fri, 24 Apr 2020 18:39:57 +0200 Subject: Add a configurable scale factor (#230) * Add swing-dpi dependency * Implement scale factor * Improve custom scale dialog, fix crash * Remove use of $ in identifiers * Use custom functional interface for scale listeners * Bump version Co-authored-by: modmuss50 --- src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java | 7 ++++--- src/main/java/cuchaz/enigma/gui/panels/PanelIdentifier.java | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/main/java/cuchaz/enigma/gui/panels') diff --git a/src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java b/src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java index 1a34edf..8296842 100644 --- a/src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java +++ b/src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java @@ -7,6 +7,7 @@ import cuchaz.enigma.gui.BrowserCaret; import cuchaz.enigma.gui.Gui; import cuchaz.enigma.translation.representation.entry.ClassEntry; import cuchaz.enigma.translation.representation.entry.Entry; +import cuchaz.enigma.gui.util.ScaleUtil; import javax.swing.*; import java.awt.*; @@ -23,7 +24,7 @@ public class PanelEditor extends JEditorPane { this.setEditable(false); this.setSelectionColor(new Color(31, 46, 90)); this.setCaret(new BrowserCaret()); - this.setFont(new Font(this.getFont().getFontName(), Font.PLAIN, this.fontSize)); + this.setFont(ScaleUtil.getFont(this.getFont().getFontName(), Font.PLAIN, this.fontSize)); this.addCaretListener(event -> gui.onCaretMove(event.getDot(), mouseIsPressed)); final PanelEditor self = this; this.addMouseListener(new MouseAdapter() { @@ -154,13 +155,13 @@ public class PanelEditor extends JEditorPane { int newResult = this.fontSize + zoomAmount; if (newResult > 8 && newResult < 72) { this.fontSize = newResult; - this.setFont(new Font(this.getFont().getFontName(), Font.PLAIN, this.fontSize)); + this.setFont(ScaleUtil.getFont(this.getFont().getFontName(), Font.PLAIN, this.fontSize)); } } public void resetEditorZoom() { this.fontSize = 12; - this.setFont(new Font(this.getFont().getFontName(), Font.PLAIN, this.fontSize)); + this.setFont(ScaleUtil.getFont(this.getFont().getFontName(), Font.PLAIN, this.fontSize)); } @Override diff --git a/src/main/java/cuchaz/enigma/gui/panels/PanelIdentifier.java b/src/main/java/cuchaz/enigma/gui/panels/PanelIdentifier.java index 0cca40d..de069bc 100644 --- a/src/main/java/cuchaz/enigma/gui/panels/PanelIdentifier.java +++ b/src/main/java/cuchaz/enigma/gui/panels/PanelIdentifier.java @@ -2,6 +2,7 @@ package cuchaz.enigma.gui.panels; import cuchaz.enigma.gui.Gui; import cuchaz.enigma.utils.I18n; +import cuchaz.enigma.gui.util.ScaleUtil; import cuchaz.enigma.utils.Utils; import javax.swing.*; @@ -15,7 +16,7 @@ public class PanelIdentifier extends JPanel { this.gui = gui; this.setLayout(new GridLayout(4, 1, 0, 0)); - this.setPreferredSize(new Dimension(0, 100)); + this.setPreferredSize(ScaleUtil.getDimension(0, 100)); this.setBorder(BorderFactory.createTitledBorder(I18n.translate("info_panel.identifier"))); } -- cgit v1.2.3