From b255bd092560636b677b347a4da2e3e51ae9e754 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 28 Jun 2015 15:03:47 -0400 Subject: [PATCH] add callbacks for subclassing init process, use class name not full package for title --- core/src/processing/core/PApplet.java | 40 +++++++++++++++++---------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index e766a2f8d..44ea61124 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -10152,30 +10152,40 @@ public class PApplet implements PConstants { surface.placeWindow(location, editorLocation); } -// EventQueue.invokeLater(new Runnable() { -// public void run() { - - // Helps avoid this code being duplicated 2x per surface class. - // Andres is testing to make sure this doesn't cause trouble. - if (sketch.getGraphics().displayable()) { - surface.setVisible(true); - } - // not always running externally when in present mode + // moved above setVisible() in 3.0 alpha 11 if (sketch.external) { surface.setupExternalMessages(); } + sketch.showSurface(); + sketch.startSurface(); + /* + if (sketch.getGraphics().displayable()) { + surface.setVisible(true); + } + //sketch.init(); surface.startThread(); - -// } -// }); + */ } - protected PSurface initSurface() {/*int backgroundColor, int displayNum, - boolean fullScreen, boolean spanDisplays) {*/ + /** Danger: available for advanced subclassing, but here be dragons. */ + protected void showSurface() { + if (getGraphics().displayable()) { + surface.setVisible(true); + } + } + + + /** See warning in showSurface() */ + protected void startSurface() { + surface.startThread(); + } + + + protected PSurface initSurface() { g = createPrimaryGraphics(); surface = g.createSurface(); @@ -10229,7 +10239,7 @@ public class PApplet implements PConstants { }; surface.initFrame(this); //, backgroundColor, displayNum, fullScreen, spanDisplays); - surface.setTitle(getClass().getName()); + surface.setTitle(getClass().getSimpleName()); } else { surface.initOffscreen(this); // for PDF/PSurfaceNone and friends