diff options
| author | 2020-04-24 18:39:57 +0200 | |
|---|---|---|
| committer | 2020-04-24 17:39:57 +0100 | |
| commit | 04b01512c124c76f3b3d99ba07ef30ea6a90b52f (patch) | |
| tree | 33ffbe9fba1fd762cc7a7997db9764b181f29d7b /src/main/java/cuchaz/enigma/gui/panels | |
| parent | Update darcula to fix dark theme (diff) | |
| download | enigma-fork-04b01512c124c76f3b3d99ba07ef30ea6a90b52f.tar.gz enigma-fork-04b01512c124c76f3b3d99ba07ef30ea6a90b52f.tar.xz enigma-fork-04b01512c124c76f3b3d99ba07ef30ea6a90b52f.zip | |
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 <modmuss50@gmail.com>
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/panels')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java | 7 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/panels/PanelIdentifier.java | 3 |
2 files changed, 6 insertions, 4 deletions
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; | |||
| 7 | import cuchaz.enigma.gui.Gui; | 7 | import cuchaz.enigma.gui.Gui; |
| 8 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 8 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 9 | import cuchaz.enigma.translation.representation.entry.Entry; | 9 | import cuchaz.enigma.translation.representation.entry.Entry; |
| 10 | import cuchaz.enigma.gui.util.ScaleUtil; | ||
| 10 | 11 | ||
| 11 | import javax.swing.*; | 12 | import javax.swing.*; |
| 12 | import java.awt.*; | 13 | import java.awt.*; |
| @@ -23,7 +24,7 @@ public class PanelEditor extends JEditorPane { | |||
| 23 | this.setEditable(false); | 24 | this.setEditable(false); |
| 24 | this.setSelectionColor(new Color(31, 46, 90)); | 25 | this.setSelectionColor(new Color(31, 46, 90)); |
| 25 | this.setCaret(new BrowserCaret()); | 26 | this.setCaret(new BrowserCaret()); |
| 26 | this.setFont(new Font(this.getFont().getFontName(), Font.PLAIN, this.fontSize)); | 27 | this.setFont(ScaleUtil.getFont(this.getFont().getFontName(), Font.PLAIN, this.fontSize)); |
| 27 | this.addCaretListener(event -> gui.onCaretMove(event.getDot(), mouseIsPressed)); | 28 | this.addCaretListener(event -> gui.onCaretMove(event.getDot(), mouseIsPressed)); |
| 28 | final PanelEditor self = this; | 29 | final PanelEditor self = this; |
| 29 | this.addMouseListener(new MouseAdapter() { | 30 | this.addMouseListener(new MouseAdapter() { |
| @@ -154,13 +155,13 @@ public class PanelEditor extends JEditorPane { | |||
| 154 | int newResult = this.fontSize + zoomAmount; | 155 | int newResult = this.fontSize + zoomAmount; |
| 155 | if (newResult > 8 && newResult < 72) { | 156 | if (newResult > 8 && newResult < 72) { |
| 156 | this.fontSize = newResult; | 157 | this.fontSize = newResult; |
| 157 | this.setFont(new Font(this.getFont().getFontName(), Font.PLAIN, this.fontSize)); | 158 | this.setFont(ScaleUtil.getFont(this.getFont().getFontName(), Font.PLAIN, this.fontSize)); |
| 158 | } | 159 | } |
| 159 | } | 160 | } |
| 160 | 161 | ||
| 161 | public void resetEditorZoom() { | 162 | public void resetEditorZoom() { |
| 162 | this.fontSize = 12; | 163 | this.fontSize = 12; |
| 163 | this.setFont(new Font(this.getFont().getFontName(), Font.PLAIN, this.fontSize)); | 164 | this.setFont(ScaleUtil.getFont(this.getFont().getFontName(), Font.PLAIN, this.fontSize)); |
| 164 | } | 165 | } |
| 165 | 166 | ||
| 166 | @Override | 167 | @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; | |||
| 2 | 2 | ||
| 3 | import cuchaz.enigma.gui.Gui; | 3 | import cuchaz.enigma.gui.Gui; |
| 4 | import cuchaz.enigma.utils.I18n; | 4 | import cuchaz.enigma.utils.I18n; |
| 5 | import cuchaz.enigma.gui.util.ScaleUtil; | ||
| 5 | import cuchaz.enigma.utils.Utils; | 6 | import cuchaz.enigma.utils.Utils; |
| 6 | 7 | ||
| 7 | import javax.swing.*; | 8 | import javax.swing.*; |
| @@ -15,7 +16,7 @@ public class PanelIdentifier extends JPanel { | |||
| 15 | this.gui = gui; | 16 | this.gui = gui; |
| 16 | 17 | ||
| 17 | this.setLayout(new GridLayout(4, 1, 0, 0)); | 18 | this.setLayout(new GridLayout(4, 1, 0, 0)); |
| 18 | this.setPreferredSize(new Dimension(0, 100)); | 19 | this.setPreferredSize(ScaleUtil.getDimension(0, 100)); |
| 19 | this.setBorder(BorderFactory.createTitledBorder(I18n.translate("info_panel.identifier"))); | 20 | this.setBorder(BorderFactory.createTitledBorder(I18n.translate("info_panel.identifier"))); |
| 20 | } | 21 | } |
| 21 | 22 | ||