Skip to content

Commit ece11f9

Browse files
committed
Clean up the footer writer section of the preprocessor for easier reading but also fix adding and looking for --full-screen which appears to have been left off at some point.
1 parent fa8eef0 commit ece11f9

File tree

5 files changed

+79
-7
lines changed

5 files changed

+79
-7
lines changed

core/src/processing/core/PApplet.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10277,6 +10277,7 @@ static public void runSketch(final String[] args,
1027710277

1027810278
int displayNum = -1; // use default
1027910279
boolean present = false;
10280+
boolean fullScreen = false;
1028010281
float uiScale = 0;
1028110282

1028210283
String param, value;
@@ -10343,6 +10344,9 @@ static public void runSketch(final String[] args,
1034310344
} else if (args[argIndex].equals(ARGS_EXTERNAL)) {
1034410345
external = true;
1034510346

10347+
} else if (args[argIndex].equals(ARGS_FULL_SCREEN)) {
10348+
fullScreen = true;
10349+
1034610350
} else {
1034710351
name = args[argIndex];
1034810352
break; // because of break, argIndex won't increment again
@@ -10418,6 +10422,7 @@ static public void runSketch(final String[] args,
1041810422
sketch.display = displayNum;
1041910423

1042010424
sketch.present = present;
10425+
sketch.fullScreen = fullScreen;
1042110426

1042210427
// For 3.0.1, moved this above handleSettings() so that loadImage() can be
1042310428
// used inside settings(). Sets a terrible precedent, but the alternative

java/src/processing/mode/java/preproc/PdeParseTreeListener.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,21 +1227,29 @@ protected void writeMain(PrintWriterWithEditGen footerWriter,
12271227
footerWriter.addCodeLine(indent1 + "static public void main(String[] passedArgs) {");
12281228
footerWriter.addCode(indent2 + "String[] appletArgs = new String[] { ");
12291229

1230+
1231+
12301232
{ // assemble line with applet args
1231-
if (Preferences.getBoolean("export.application.fullscreen")) {
1232-
footerWriter.addCode("\"" + PApplet.ARGS_FULL_SCREEN + "\", ");
1233+
StringJoiner argsJoiner = new StringJoiner(", ");
1234+
1235+
boolean shouldFullScreen = Preferences.getBoolean("export.application.present");
1236+
shouldFullScreen = shouldFullScreen || Preferences.getBoolean("export.application.fullscreen");
1237+
if (shouldFullScreen) {
1238+
argsJoiner.add("\"" + PApplet.ARGS_FULL_SCREEN + "\"");
12331239

12341240
String bgColor = Preferences.get("run.present.bgcolor");
1235-
footerWriter.addCode("\"" + PApplet.ARGS_BGCOLOR + "=" + bgColor + "\", ");
1241+
argsJoiner.add("\"" + PApplet.ARGS_BGCOLOR + "=" + bgColor + "\"");
12361242

12371243
if (Preferences.getBoolean("export.application.stop")) {
12381244
String stopColor = Preferences.get("run.present.stop.color");
1239-
footerWriter.addCode("\"" + PApplet.ARGS_STOP_COLOR + "=" + stopColor + "\", ");
1245+
argsJoiner.add("\"" + PApplet.ARGS_STOP_COLOR + "=" + stopColor + "\"");
12401246
} else {
1241-
footerWriter.addCode("\"" + PApplet.ARGS_HIDE_STOP + "\", ");
1247+
argsJoiner.add("\"" + PApplet.ARGS_HIDE_STOP + "\"");
12421248
}
12431249
}
1244-
footerWriter.addCode("\"" + sketchName + "\"");
1250+
1251+
argsJoiner.add("\"" + sketchName + "\"");
1252+
footerWriter.addCode(argsJoiner.toString());
12451253
}
12461254

12471255
footerWriter.addCodeLine(" };");

java/test/processing/mode/java/ParserTests.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
import java.util.Optional;
1212

1313
import org.junit.BeforeClass;
14+
import org.junit.Before;
1415
import org.junit.Test;
1516

17+
import processing.app.Preferences;
1618
import processing.app.SketchException;
1719
import processing.mode.java.preproc.PreprocessorResult;
1820
import processing.mode.java.preproc.PdePreprocessIssueException;
@@ -25,6 +27,11 @@ public static void init() {
2527
ProcessingTestUtil.init();
2628
}
2729

30+
@Before
31+
public void before() {
32+
Preferences.setBoolean("export.application.fullscreen", false);
33+
}
34+
2835
static void expectRecognitionException(final String id,
2936
final int expectedLine) {
3037

@@ -432,7 +439,8 @@ public void testMultilineStringClass() {
432439

433440
@Test
434441
public void testMultiMultilineString() {
435-
expectGood("multimultilinestr");
442+
Preferences.setBoolean("export.application.fullscreen", true);
443+
expectGood("fullscreen_export");
436444
}
437445

438446
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import processing.core.*;
2+
import processing.data.*;
3+
import processing.event.*;
4+
import processing.opengl.*;
5+
6+
import java.util.HashMap;
7+
import java.util.ArrayList;
8+
import java.io.File;
9+
import java.io.BufferedReader;
10+
import java.io.PrintWriter;
11+
import java.io.InputStream;
12+
import java.io.OutputStream;
13+
import java.io.IOException;
14+
15+
public class fullscreen_export extends PApplet {
16+
17+
int x = 0;
18+
19+
public void setup() {
20+
background(0);
21+
noStroke();
22+
fill(102);
23+
}
24+
25+
public void draw() {
26+
rect(x, height*0.2f, 1, height*0.6f);
27+
x = x + 2;
28+
}
29+
30+
31+
static public void main(String[] passedArgs) {
32+
String[] appletArgs = new String[] { "--full-screen", "--bgcolor=null", "--hide-stop", "fullscreen_export" };
33+
if (passedArgs != null) {
34+
PApplet.main(concat(appletArgs, passedArgs));
35+
} else {
36+
PApplet.main(appletArgs);
37+
}
38+
}
39+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
int x = 0;
2+
3+
void setup() {
4+
background(0);
5+
noStroke();
6+
fill(102);
7+
}
8+
9+
void draw() {
10+
rect(x, height*0.2, 1, height*0.6);
11+
x = x + 2;
12+
}

0 commit comments

Comments
 (0)