mirror of
https://github.com/processing/processing4.git
synced 2026-04-17 17:59:18 +02:00
add gui for setting the zoom level
This commit is contained in:
@@ -49,7 +49,6 @@ public class PreferencesFrame {
|
||||
GroupLayout layout;
|
||||
|
||||
static final Integer[] FONT_SIZES = { 10, 12, 14, 18, 24, 36, 48 };
|
||||
static final String[] ZOOM_OPTIONS = { "100%", "150%", "200%", "300%" };
|
||||
|
||||
JTextField sketchbookLocationField;
|
||||
JTextField presentColor;
|
||||
@@ -167,7 +166,7 @@ public class PreferencesFrame {
|
||||
|
||||
JLabel zoomLabel = new JLabel(Language.text("preferences.zoom") + ": ");
|
||||
zoomSelectionBox = new JComboBox<String>();
|
||||
zoomSelectionBox.setModel(new DefaultComboBoxModel<String>(ZOOM_OPTIONS));
|
||||
zoomSelectionBox.setModel(new DefaultComboBoxModel<String>(Toolkit.zoomOptions.array()));
|
||||
zoomRestartLabel = new JLabel(" (" + Language.text("preferences.requires_restart") + ")");
|
||||
|
||||
|
||||
@@ -658,6 +657,9 @@ public class PreferencesFrame {
|
||||
fontSizeField.setSelectedItem(Preferences.getInteger("editor.font.size"));
|
||||
}
|
||||
|
||||
Preferences.set("editor.zoom",
|
||||
String.valueOf(zoomSelectionBox.getSelectedItem()));
|
||||
|
||||
try {
|
||||
Object selection = consoleFontSizeField.getSelectedItem();
|
||||
if (selection instanceof String) {
|
||||
@@ -727,6 +729,14 @@ public class PreferencesFrame {
|
||||
fontSizeField.setSelectedItem(Preferences.getInteger("editor.font.size"));
|
||||
consoleFontSizeField.setSelectedItem(Preferences.getInteger("console.font.size"));
|
||||
|
||||
String zoomSel = Preferences.get("editor.zoom");
|
||||
int zoomIndex = Toolkit.zoomOptions.index(zoomSel);
|
||||
if (zoomIndex != -1) {
|
||||
zoomSelectionBox.setSelectedIndex(zoomIndex);
|
||||
} else {
|
||||
zoomSelectionBox.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
presentColor.setBackground(Preferences.getColor("run.present.bgcolor"));
|
||||
presentColorHex.setText(Preferences.get("run.present.bgcolor").substring(1));
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ import processing.app.Messages;
|
||||
import processing.app.Platform;
|
||||
import processing.app.Preferences;
|
||||
import processing.app.Util;
|
||||
import processing.core.PApplet;
|
||||
import processing.data.StringList;
|
||||
|
||||
|
||||
@@ -809,7 +810,7 @@ public class Toolkit {
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
static float zoom = 3;
|
||||
static float zoom = 0;
|
||||
|
||||
|
||||
/*
|
||||
@@ -832,11 +833,31 @@ public class Toolkit {
|
||||
*/
|
||||
|
||||
|
||||
static final StringList zoomOptions =
|
||||
new StringList("100%", "150%", "200%", "300%");
|
||||
|
||||
static public int zoom(int pixels) {
|
||||
if (zoom == 0) {
|
||||
zoom = parseZoom();
|
||||
}
|
||||
return (int) (zoom * pixels);
|
||||
}
|
||||
|
||||
|
||||
static private float parseZoom() {
|
||||
String zoomSel = Preferences.get("editor.zoom");
|
||||
if (zoomOptions.hasValue(zoomSel)) {
|
||||
// shave off the % symbol at the end
|
||||
zoomSel = zoomSel.substring(0, zoomSel.length() - 1);
|
||||
return PApplet.parseInt(zoomSel, 100) / 100f;
|
||||
|
||||
} else {
|
||||
Preferences.set("editor.zoom", "100%");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static BasicStroke zoomStroke;
|
||||
|
||||
static private void zoomStroke(Graphics2D g2) {
|
||||
|
||||
@@ -105,6 +105,9 @@ editor.window.height.min.windows = 530
|
||||
# tested with Raspberry Pi display
|
||||
editor.window.height.min.linux = 480
|
||||
|
||||
# scaling for the interface (to handle Windows and Linux HiDPI displays)
|
||||
editor.zoom = 100%
|
||||
|
||||
# font size for editor
|
||||
#editor.font = Monospaced,plain,12
|
||||
# Monaco is nicer on Mac OS X, so use that explicitly
|
||||
|
||||
Reference in New Issue
Block a user