Skip to content

Commit 2db52c2

Browse files
committed
save/restore style in onPause/onResume
1 parent b98e37a commit 2db52c2

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

core/src/processing/core/PApplet.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ static public class RendererChangeException extends RuntimeException { }
446446
// https://github.com/processing/processing/issues/2297
447447
int windowColor = 0xffDDDDDD;
448448

449+
PStyle savedStyle;
449450

450451
//////////////////////////////////////////////////////////////
451452
//////////////////////////////////////////////////////////////
@@ -686,6 +687,14 @@ public void onResume() {
686687
// surfaceView.onResume();
687688
if (DEBUG) System.out.println("PApplet.onResume() called");
688689
paused = false;
690+
691+
// TODO need to bring back app state here!
692+
// At least we restore the current style.
693+
if (savedStyle != null && g != null) {
694+
g.style(savedStyle);
695+
savedStyle = null;
696+
}
697+
689698
handleMethods("resume");
690699
//start(); // kick the thread back on
691700
resume();
@@ -699,7 +708,12 @@ public void onPause() {
699708
setFullScreenVisibility();
700709

701710
// TODO need to save all application state here!
702-
// System.out.println("PApplet.onPause() called");
711+
// At least we save the current style.
712+
if (g != null) {
713+
savedStyle = new PStyle();
714+
g.getStyle(savedStyle);
715+
}
716+
703717
paused = true;
704718
handleMethods("pause");
705719
pause(); // handler for others to write

0 commit comments

Comments
 (0)