summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/gui/panels
diff options
context:
space:
mode:
authorGravatar Samir Mokiem2020-04-15 05:30:26 +0200
committerGravatar GitHub2020-04-14 23:30:26 -0400
commit4e2e6aada308ee416b18998282504a3c87c0d0e9 (patch)
tree5495be6dc5eec1cf7b1ab72f5de29fe9044abf3b /src/main/java/cuchaz/enigma/gui/panels
parentConvert javadoc escape codes into raw characters when loading Tiny v2 mapping... (diff)
downloadenigma-fork-4e2e6aada308ee416b18998282504a3c87c0d0e9.tar.gz
enigma-fork-4e2e6aada308ee416b18998282504a3c87c0d0e9.tar.xz
enigma-fork-4e2e6aada308ee416b18998282504a3c87c0d0e9.zip
Added zoom for PanelEditor (#209)
* Added zoom for PanelEditor * Updated french zoom translations. Renamed zoom function, Integer to int
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/panels')
-rw-r--r--src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java b/src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java
index 71ee34c..bbb839e 100644
--- a/src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java
+++ b/src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java
@@ -17,11 +17,13 @@ import java.awt.event.MouseEvent;
17 17
18public class PanelEditor extends JEditorPane { 18public class PanelEditor extends JEditorPane {
19 private boolean mouseIsPressed = false; 19 private boolean mouseIsPressed = false;
20 public int fontSize = 12;
20 21
21 public PanelEditor(Gui gui) { 22 public PanelEditor(Gui gui) {
22 this.setEditable(false); 23 this.setEditable(false);
23 this.setSelectionColor(new Color(31, 46, 90)); 24 this.setSelectionColor(new Color(31, 46, 90));
24 this.setCaret(new BrowserCaret()); 25 this.setCaret(new BrowserCaret());
26 this.setFont(new Font(this.getFont().getFontName(), Font.PLAIN, this.fontSize));
25 this.addCaretListener(event -> gui.onCaretMove(event.getDot(), mouseIsPressed)); 27 this.addCaretListener(event -> gui.onCaretMove(event.getDot(), mouseIsPressed));
26 final PanelEditor self = this; 28 final PanelEditor self = this;
27 this.addMouseListener(new MouseAdapter() { 29 this.addMouseListener(new MouseAdapter() {
@@ -53,7 +55,6 @@ public class PanelEditor extends JEditorPane {
53 public void keyPressed(KeyEvent event) { 55 public void keyPressed(KeyEvent event) {
54 if (event.isControlDown()) { 56 if (event.isControlDown()) {
55 gui.setShouldNavigateOnClick(false); 57 gui.setShouldNavigateOnClick(false);
56
57 switch (event.getKeyCode()) { 58 switch (event.getKeyCode()) {
58 case KeyEvent.VK_I: 59 case KeyEvent.VK_I:
59 gui.popupMenu.showInheritanceMenu.doClick(); 60 gui.popupMenu.showInheritanceMenu.doClick();
@@ -99,6 +100,16 @@ public class PanelEditor extends JEditorPane {
99 // prevent navigating on click when quick find activated 100 // prevent navigating on click when quick find activated
100 break; 101 break;
101 102
103 case KeyEvent.VK_ADD:
104 case KeyEvent.VK_EQUALS:
105 case KeyEvent.VK_PLUS:
106 self.offsetEditorZoom(2);
107 break;
108 case KeyEvent.VK_SUBTRACT:
109 case KeyEvent.VK_MINUS:
110 self.offsetEditorZoom(-2);
111 break;
112
102 default: 113 default:
103 gui.setShouldNavigateOnClick(true); // CTRL 114 gui.setShouldNavigateOnClick(true); // CTRL
104 break; 115 break;
@@ -135,6 +146,19 @@ public class PanelEditor extends JEditorPane {
135 }); 146 });
136 } 147 }
137 148
149 public void offsetEditorZoom(int zoomAmount) {
150 int newResult = this.fontSize + zoomAmount;
151 if (newResult > 8 && newResult < 72) {
152 this.fontSize = newResult;
153 this.setFont(new Font(this.getFont().getFontName(), Font.PLAIN, this.fontSize));
154 }
155 }
156
157 public void resetEditorZoom() {
158 this.fontSize = 12;
159 this.setFont(new Font(this.getFont().getFontName(), Font.PLAIN, this.fontSize));
160 }
161
138 @Override 162 @Override
139 public Color getCaretColor() { 163 public Color getCaretColor() {
140 return new Color(Config.getInstance().caretColor); 164 return new Color(Config.getInstance().caretColor);